easy local kubernetes cluster set-up for certification preparation via multipass, cloud init and kubeadm
- k8s control plane:
Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/ab2k/k8s-multipass/main/control-plane.yaml' | Select-Object -Expand Content | multipass launch -n k8s-control-plane --cpus 2 --mem 2G 18.04 --cloud-init -
- k8s worker node 1:
Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/ab2k/k8s-multipass/main/worker-node-1.yaml' | Select-Object -Expand Content | multipass launch -n k8s-worker-node-1 --cpus 2 --mem 4G --disk 10G 18.04 --cloud-init -
- k8s worker node 2:
Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/ab2k/k8s-multipass/main/worker-node-2.yaml' | Select-Object -Expand Content | multipass launch -n k8s-worker-node-2 --cpus 2 --mem 4G --disk 10G 18.04 --cloud-init -
- k8s control plane:
curl https://raw.githubusercontent.com/ab2k/k8s-multipass/main/control-plane.yaml | multipass launch -n k8s-control-plane --cpus 2 --mem 2G 18.04 --cloud-init -
- k8s worker node 1:
curl https://raw.githubusercontent.com/ab2k/k8s-multipass/main/worker-node-1.yaml | multipass launch -n k8s-worker-node-1 --cpus 2 --mem 4G --disk 10G 18.04 --cloud-init -
- k8s worker node 2:
curl https://raw.githubusercontent.com/ab2k/k8s-multipass/main/worker-node-2.yaml | multipass launch -n k8s-worker-node-2 --cpus 2 --mem 4G --disk 10G 18.04 --cloud-init -
- create a cluster
sudo kubeadm init --pod-network-cidr 192.168.0.0/16 --kubernetes-version 1.21.0
- copy config to user home directory to utilize kubectl
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
- add kubectl bash completion
echo 'source <(kubectl completion bash)' >>~/.bashrc
- add any desirable CNI, or just use Project Calico manifest
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
- get join token to use on worker nodes
kubeadm token create --print-join-command
sudo kubeadm join ...