Learn to deploy a Kubernetes cluster in 30 minutes using KubeAdm
Pre-Requisites:Â
Create 3 VMs with 2 core 8 GB and 10-100 GB HDD
1. Docker set up in master and nodes
1a. Login into master and update your existing list of packages Â
1b. Install the prerequisite packages which let apt to use packages over HTTPSÂ
1c. Add the GPG key for the official Docker repository to your system Â
1d. Add the Docker repository to APT sources  Â
1e. Update the packages with the Docker packages from the newly added repo
1f. Make sure you are about to install from the Docker repo
1g. Run the following command to install Docker  Â
1h. Run the following command to check if the docker is running  Â
1i. To avoid sudo requirement in executing the docker command, add your user to docker group  Â
1j. To apply the new group membership, run the following command  Â
You will be prompted to enter your user password to continue
1k. Confirm that your user is now added to the docker group by typing Â
Repeat the above steps for both the nodes.
2. Kubernetes master set up
2a. Login to the master and install kubelet, kubeadm and kubectl
2b. Initialise kubeadm
Your Kubernetes master has initialized successfully!
2c. To start using your cluster, you need to run the following command as a regular user:Â Â
Copy the join command and make a note of it.
For example:
2d. Set up Flannel
2e. Verify the creation of the master in the cluster.
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-XX-X-X-XXX Ready master 3m53s v1.18.15
$ kubectl get pods --all-namespaces NAMESPACE   NAME                  READY STATUS RESTART AGE kube-system  coredns-54ff9cd656-ww6sw        1/1  Running 0    4m2s kube-system  coredns-54ff9cd656-xlrdr        1/1  Running 0    4m2s kube-system  etcd-ip-XX-X-X-XXX           1/1  Running 0    2m59s kube-system  kube-apiserver-ip-XX-X-X-XXX      1/1  Running 0    3m11s kube-system  kube-controller-manager-ip-XX-X-X-XXX  1/1  Running 0    3m15s kube-system  kube-flannel-ds-amd64-4rl8d       1/1  Running 0    45s kube-system  kube-proxy-jpp7w            1/1  Running 0    4m2s kube-system  kube-scheduler-ip-XX-X-X-XXX      1/1  Running 0    3m23s
3. Kubernetes node set up
3a. Login into node 1 and install kubelet, kubeadm and kubectl
3b. Join cluster from the command copied above in the master.
This node has joined the cluster:
Repeat the steps for node 2.
4. Verify creation of nodes in cluster.
Login into master and verify the cluster
$ kubectl get nodes NAME      STATUS   ROLES  AGE  VERSION ip-XX-X-X-XXX  Ready    105m  v1.18.15 ip-XXX-X-X-XX  Ready   master  123m  v1.18.15 ip-XX-X-X-XX  Ready    111m  v1.18.15
4. Deploying the nginx with nodeport service
Use the following yaml for deploying nginx with nodeport service to test the cluster
4.Test the deployment
About The Author
A. Nagesh
SR Cloud Dev-Ops Engineer | Cloud Control
Senior Cloud DevOps Engineer with more than five years of experience in supporting, automating, and optimizing deployments to hybrid cloud platforms using DevOps processes, CI/CD, containers and Kubernetes in both Production and Development environments