added script and readme

This commit is contained in:
2025-06-29 16:46:20 +02:00
parent 60c1665adb
commit 994a857b5d
5 changed files with 93 additions and 1 deletions

25
init-deploy.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
KUBE_USER="kevin"
KUBE_CP="k8s-control-plane"
KUBE_W1="k8s-worker1"
KUBE_W2="k8s-worker2"
ANSIBLE_DIR="ansible"
## Prepare all of the nodes with k8s using the ansible playbooks I prepared
ansible-playbook -i ./"$ANSIBLE_DIR"/inventory.ini ./"$ANSIBLE_DIR"/master-k8s.yaml
## Fetch the configuration from the freshly installed cluster. BEWARE THAT ANY EXISTING CONFIG WILL BE OVERWRITTEN
scp "$KUBE_USER@$KUBE_CP":"$HOME"/.kube/config "$HOME"/.kube/config
## Now join the workers to the cluster
JOIN_TOKEN=$(ssh "$KUBE_USER@$KUBE_CP" "kubeadm token create --print-join-command")
for NODE in "$KUBE_W1" "$KUBE_W2"; do
echo "Joining $NODE"
ssh "$KUBE_USER@$NODE" "sudo $JOIN_TOKEN"
done