first commit

This commit is contained in:
Adolfo Delorenzo 2021-07-08 19:48:24 -06:00
parent 14de71cac8
commit 81e3553c73
2 changed files with 21 additions and 3 deletions

View File

@ -70,4 +70,4 @@ TLS="true" TLSSkipVerify="true" \
TLSSkipClientVerify="true"
#Housekeeping
#sed -i /@reboot/d /etc/crontab
sed -i /@reboot/d /etc/crontab

View File

@ -2,10 +2,11 @@
#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
docker container kill $(docker ps -q)
docker container rm $(docker ps -a -q)
#Install Portainer
docker volume create portainer_data
@ -26,14 +27,31 @@ sudo -u portainer minikube start --nodes 2 --driver=docker --ports=":30778" --po
#Add the metrics server to the minikube cluster
sudo -u portainer minikube addons enable metrics-server
#Add ingress to the minikube cluster
sudo -u portainer minikube addons enable ingress
#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 20
#Check if the Portainer Agent is running
echo ""
echo ""
while true
do
agent_state=`sudo -u portainer kubectl get pod -n portainer | awk '{ print $3 }' | tail -1`
if [ "$agent_state" != "Running" ]; then
echo -ne '⚡ Portainer Agent Not Running yet\r'
else
break
fi
sleep 1
done
#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 5
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"