From 9ed92568568c804cde220abb16ac94bc6359f045 Mon Sep 17 00:00:00 2001 From: "adelorenzo@oe74.net" Date: Thu, 8 Jul 2021 14:11:46 -0600 Subject: [PATCH] first commit --- env_rebuild.sh | 38 ++++++++++++++++++++++++++++++++++++-- firstboot.sh | 9 ++++----- prog.sh | 6 ++++++ 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100755 prog.sh diff --git a/env_rebuild.sh b/env_rebuild.sh index 23a98fb..cb3f666 100755 --- a/env_rebuild.sh +++ b/env_rebuild.sh @@ -1,6 +1,40 @@ #!/bin/bash -sudo -u portainer docker start minikube minikube-m02 minikube-m03 -sudo -u portainer minikube start +#Delete previous setup +sudo -u portainer minikube delete +sudo -u portainer rm -rf /home/portainer/.minikube +docker stop portainer +docker rm portainer +docker volume rm portainer_data +#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 +http POST http://localhost:9000/api/users/admin/init Username="portainer" Password="portainer1234" + +#Start minikube +sudo -u portainer minikube start --nodes 3 --driver=docker --ports=":30778" --ports=":9001" + +#Add the metrics server to the minikube cluster +sudo -u portainer minikube addons enable metrics-server + +#Add Portainer Agent to the local kind Kubernetes cluster +sudo -u portainer curl -qL https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o /home/portainer/portainer-agent-k8s.yaml; sudo -u portainer kubectl apply -f /home/portainer/portainer-agent-k8s.yaml +sudo -u portainer rm /home/portainer/portainer-agent-k8s.yaml +sleep 15 + +#Get the admin JWT token +jwt=`http POST :9000/api/auth Username="portainer" Password="portainer1234" | jq '.jwt' | sed 's/^.//' | sed 's/.$//'` + +#Add local Docker endpoint +http --form POST :9000/api/endpoints "Authorization: Bearer $jwt" Name="docker" EndpointCreationType=1 + +#Get mapped 30778 port from control-plane +jwt=`http POST :9000/api/auth Username="portainer" Password="portainer1234" | jq '.jwt' | sed 's/^.//' | sed 's/.$//'` +port=`docker port minikube | grep 30778 | head -1 | awk '$1=$1' FS=":" OFS=" " | awk '{ print $4 }'` + +#Add local Kubernetes endpoint +sleep 20 +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" diff --git a/firstboot.sh b/firstboot.sh index fc5bf13..98948e6 100755 --- a/firstboot.sh +++ b/firstboot.sh @@ -18,10 +18,10 @@ echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https:/ apt-get update apt-get install -y kubectl -#Create a minikube +#Install minikube curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb -mv minikube_latest_amd64.deb /tmp -dpkg -i /tmp/minikube_latest_amd64.deb +mv minikube_latest_amd64.deb /usr/local/bin +dpkg -i /usr/local/bin\/minikube_latest_amd64.deb rm /tmp/minikube_latest_amd64.deb #Install httpie @@ -70,5 +70,4 @@ TLS="true" TLSSkipVerify="true" \ TLSSkipClientVerify="true" #Housekeeping -sed -i /@reboot/d /etc/crontab -reboot +#sed -i /@reboot/d /etc/crontab diff --git a/prog.sh b/prog.sh new file mode 100755 index 0000000..8261f4f --- /dev/null +++ b/prog.sh @@ -0,0 +1,6 @@ +echo -ne '... (33%)\r' +sleep 1 +echo -ne '...... (66%)\r' +sleep 1 +echo -ne '.......... (100%)\r' +echo -ne '\n'