Skip to content

pushkarsharma/kubernetes-automated-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

kubernetes-automated-setup

Local Installation

To install KVM, libvirt:

chmod +x kvm.sh
./kvm.sh

🔴 Now, fix the error in KVM with the steps under KVM/QEMU & libvirt Verification

To install kubectl, minikube:

chmod +x start.sh kubectl.sh minikube.sh
./start.sh

(Optional) Set kvm2 as default driver for minikube:

minikube config set vm-driver kvm2

KVM, libvirt, kubectl, minikube should be installed now. Check their status with the steps ahead.

KVM/QEMU & libvirt Verification

KVM Installation Reference

After installing libvirt, you may verify the host validity to run the virtual machines with virt-host-validate tool, which is a part of libvirt.

sudo virt-host-validate

🔴IOMMU Error Reference: If you see error iommu appears to be disabled in kernel. add intel_iommu=on to kernel cmdline arguments then follow the following steps:

       Edit /etc/default/grub and add the option "intel_iommu=on" to GRUB_CMDLINE_LINUX or       GRUB_CMDLINE_LINUX_DEFAULT:

GRUB_CMDLINE_LINUX="intel_iommu=on"

These changes will take effect once you run:

sudo update-grub or grub-mkconfig -o /boot/grub/grub.cfg

Finally,

sudo reboot

Minikube Verification

After installation check Minikube status:

minikube version

Starting the cluster

To start the cluster:
If default vm-driver was set before.

minikube start

If default vm-driver was NOT set before.

minikube start --vm-driver kvm2

Verify the Kubernetes installation

Check if the Kubernetes cluster is up and running:

kubectl get nodes

Cluster Deployement

Steps for Deployement

Follow the steps below for cluster deployement:

  1. chmod +x start.sh kubernetes.sh docker.sh
  2. sudo su
  3. ./start.sh
  4. Comment out the line which has mention of swap partition in the file that opens (/etc/fstab).
  5. Add the hostnames of Master & Kubelets VMs in the next opened file (/etc/hostname).
  6. Add Environment="cgroup-driver=systemd/cgroup-driver=cgroupfs" in the next opened file (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)

Master VM

  1. Initiate the cluster: kubeadm init --apiserver-advertise-address=<ip-address-of-kmaster-vm> --pod-network-cidr=192.168.0.0/16

🔴It will give the join statement for kubelet nodes (KEEP IT!)
🔴The output will ask to execute the following commands (CROSS CHECK ALWAYS):

  1. Come back to regular user from SuperUser profile.
  2. mkdir -p $HOME/.kube
  3. cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  4. chown $(id -u):$(id -g) $HOME/.kube/config
  5. Verify the cluster with kubectl get pods -o wide --all-namespaces

🔴You will notice from the previous command, that all the pods are running except one: ‘kube-dns’. For resolving this we will install a pod network. To install the CALICO pod network, run the following command:

  1. kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml

Kubelet VM

  1. Connect the Kubelet to the cluster using the statement saved from 7 output that looks like: kubeadm join <IP>:<PORT> --token <TOKEN> --discovery-token-ca-cert-hash <SHA256-VALUE>
  2. Check nodes' health with kubectl get nodes.

Kubernetes cluster is deployed. Yay!

About

Automated Kubernetes setup for local (Minikube) and cluster deployment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages