Vagrantfile and Scripts to Automate Kubernetes Setup using Kubeadm [Practice Environment for CKA/CKAD and CKS Exams]
A fully automated setup for CKA, CKAD, and CKS practice labs is tested on the following systems:
- Windows
- Ubuntu Desktop
- Mac Intel-based systems
If you are MAC Silicon user, Please use the follwing repo.
As part of our commitment to helping the DevOps community save money on Kubernetes Certifications, we continuously update the latest voucher codes from the Linux Foundation
🚀 CKA, CKAD, CKS, or KCNA exam aspirants can save $100 today using code EARTHDAY24COM at https://kube.promo/devops. It is a limited-time offer from the Linux Foundation.
The following are the best bundles to save up to $419 with code EARTHDAY24COM
- CKA + CKAD + CKS Exam bundle ($419 Savings): kube.promo/k8s-bundle
- CKA + CKS Bundle ($283 Savings) kube.promo/bundle
- KCNA + CKA ( $229 Savings) kube.promo/kcka-bundle
- KCSA + CKS Exam Bundle ($229 Savings) kube.promo/kcsa-cks
- KCNA + KCSA Exam Bundle ($203 Savings) kube.promo/kcna-kcsa
Note: You have one year of validity to appear for the certification exam after registration
- A working Vagrant setup using Vagrant with VirtualBox or libvirt available
- If using libvirt user needs to be added to libvirt group (
sudo usermod -aG libvirt $(whoami))
Current k8s version for CKA, CKAD, and CKS exam: 1.29.
The setup is updated with 1.29 cluster version.
Refer to this link for documentation full: https://devopscube.com/kubernetes-cluster-vagrant/
- Working Vagrant setup
- 8 Gig + RAM workstation as the Vms use 3 vCPUS and 4+ GB RAM
To allow virtual machines to access NFS server on the host machine you will probably need to update firewall rules.
sudo firewall-cmd --permanent --new-zone=virtualbox \
&& sudo firewall-cmd --permanent --zone=virtualbox --add-interface=vboxnet0 \
&& sudo firewall-cmd --permanent --zone=virtualbox --add-interface=vboxnet1 \
&& sudo firewall-cmd --permanent --zone=virtualbox --add-service=nfs3 \
&& sudo firewall-cmd --permanent --zone=virtualbox --add-service=nfs \
&& sudo firewall-cmd --permanent --zone=virtualbox --add-service=rpc-bind \
&& sudo firewall-cmd --permanent --zone=virtualbox --add-service=mountd \
&& sudo firewall-cmd --reloadsudo firewall-cmd --permanent --zone=libvirt --add-service=nfs3 \
&& sudo firewall-cmd --permanent --zone=libvirt --add-service=nfs \
&& sudo firewall-cmd --permanent --zone=libvirt --add-service=rpc-bind \
&& sudo firewall-cmd --permanent --zone=libvirt --add-service=mountd \
&& sudo firewall-cmd --reloadThe latest version of Virtualbox for Mac/Linux can cause issues.
Create/edit the /etc/vbox/networks.conf file and add the following to avoid any network-related issues.
* 0.0.0.0/0 ::/0
or run below commands
sudo mkdir -p /etc/vbox/
echo "* 0.0.0.0/0 ::/0" | sudo tee -a /etc/vbox/networks.confSo that the host only networks can be in any range, not just 192.168.56.0/21 as described here: https://discuss.hashicorp.com/t/vagrant-2-2-18-osx-11-6-cannot-create-private-network/30984/23
To provision the cluster, execute the following commands.
git clone https://github.com/scriptcamp/vagrant-kubeadm-kubernetes.git
cd vagrant-kubeadm-kubernetes
cp settings.yaml.sample settings.yamlvagrant up --provider virtualboxvagrant up --provider libvirtcd vagrant-kubeadm-kubernetes
export KUBECONFIG=$(pwd)/configs/configor you can copy the config file to .kube directory.
cp configs/config ~/.kube/The dashboard is automatically installed by default, but it can be skipped by commenting out the dashboard version in settings.yaml before running vagrant up.
If you skip the dashboard installation, you can deploy it later by enabling it in settings.yaml and running the following:
vagrant ssh -c "/vagrant/scripts/dashboard.sh" controlplaneTo get the login token, copy it from config/token or run the following command:
kubectl -n kubernetes-dashboard get secret/admin-user -o go-template="{{.data.token | base64decode}}"Make the dashboard accessible:
kubectl proxyOpen the site in your browser:
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/loginvagrant haltvagrant upvagrant destroy -f