2021-07-07 01:02:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Install Docker
|
|
|
|
#apt update
|
|
|
|
#apt install curl apt-transport-https ca-certificates curl gnupg lsb-release -y
|
|
|
|
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
|
|
#echo \
|
|
|
|
# "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
|
|
|
|
# $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
#apt-get update
|
|
|
|
#apt-get install docker-ce docker-ce-cli containerd.io -y
|
|
|
|
|
|
|
|
#Install kubectl
|
|
|
|
#apt update
|
|
|
|
#apt-get install -y apt-transport-https ca-certificates curl
|
|
|
|
#curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
|
|
|
|
#echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
|
|
|
#apt-get update
|
|
|
|
#apt-get install -y kubectl
|
|
|
|
|
2021-07-07 01:28:47 +00:00
|
|
|
#Create a minikube
|
|
|
|
#curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
|
|
|
|
#dpkg -i minikube_latest_amd64.deb
|
2021-07-07 01:02:59 +00:00
|
|
|
|
|
|
|
#Install httpie
|
2021-07-07 01:28:47 +00:00
|
|
|
#apt -y install httpie
|
2021-07-07 01:02:59 +00:00
|
|
|
|
|
|
|
#Install Portainer
|
|
|
|
#docker volume create portainer_data
|
|
|
|
#docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
|
|
|
|
|
|
|
|
#Define Admin user and Password
|
2021-07-07 01:28:47 +00:00
|
|
|
#http POST http://localhost:9000/api/users/admin/init Username="portainer" Password="portainer1234"
|
|
|
|
|
|
|
|
#Add the portainer user to the docker group
|
2021-07-07 01:46:26 +00:00
|
|
|
#usermod -aG docker portainer && newgrp docker
|
2021-07-07 01:28:47 +00:00
|
|
|
|
|
|
|
#Start minikube
|
2021-07-07 01:46:26 +00:00
|
|
|
#sudo -u portainer minikube start --nodes 2 --driver=none
|
2021-07-07 01:28:47 +00:00
|
|
|
|
|
|
|
#Add the metrics server to the minikube cluster
|
2021-07-07 01:46:26 +00:00
|
|
|
#sudo -u portainer minikube addons enable metrics-server
|
2021-07-07 01:28:47 +00:00
|
|
|
|
2021-07-07 01:02:59 +00:00
|
|
|
#Add Portainer Agent to the local kind Kubernetes cluster
|
2021-07-07 01:28:47 +00:00
|
|
|
# curl -L https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml
|
2021-07-07 01:46:26 +00:00
|
|
|
#sleep 15
|
2021-07-07 01:02:59 +00:00
|
|
|
|
2021-07-07 01:46:26 +00:00
|
|
|
#Get the admin JWT token
|
|
|
|
#http POST :9000/api/auth Username="portainer" Password="portainer1234"
|
2021-07-07 03:05:07 +00:00
|
|
|
jwt=`http POST :9000/api/auth Username="portainer" Password="portainer1234" | jq '.jwt' | sed 's/^.//' | sed 's/.$//'`
|
2021-07-07 01:46:26 +00:00
|
|
|
|
|
|
|
#Add local Docker endpoint
|
2021-07-07 03:05:07 +00:00
|
|
|
http --form POST :9000/api/endpoints \
|
|
|
|
"Authorization: Bearer $jwt" \
|
|
|
|
Name="docker" EndpointCreationType=1
|
|
|
|
|
|
|
|
#Get mapped 30778 port from control-plane
|
|
|
|
port=`docker port minikube | grep 30778 | head -1 | awk '$1=$1' FS=":" OFS=" " | awk '{ print $4 }'`
|
2021-07-07 01:46:26 +00:00
|
|
|
|
|
|
|
#Add local Kubernetes endpoint
|
2021-07-07 03:05:07 +00:00
|
|
|
sudo -u portainer http --form POST :9000/api/endpoints \
|
|
|
|
"Authorization: Bearer $jwt" \
|
|
|
|
Name="kubernetes" URL="tcp://10.0.2.8:$port" EndpointCreationType=2 TLS="true" TLSSkipVerify="true" TLSSkipClientVerify="true"
|