Kubernetes is an open-source platform that helps you deploy, scale, and manage resources across multiple containers. A Kubernetes cluster would generally have a master node and several worker-nodes or Minions. The worker-nodes are then managed from the master node, thus ensuring that the cluster is managed from a central point.
- API Server – It provides kubernetes API using Jason / Yaml over http, states of API objects are stored in etcd
- Scheduler – It is a program on master node which performs the scheduling tasks like launching containers in worker nodes based on resource availability
- Controller Manager – Main Job of Controller manager is to monitor replication controllers and create pods to maintain desired state.
- etcd – It is a Key value pair data base. It stores configuration data of cluster and cluster state.
- Kubectl utility – It is a command line utility which connects to API Server on port 6443. It is used by administrators to create pods, services etc
- Kubelet – It is an agent which runs on every worker node, it connects to docker and takes care of creating, starting, deleting containers.
- Kube-Proxy – It routes the traffic to appropriate containers based on ip address and port number of the incoming request. In other words we can say it is used for port translation.
- Pod – Pod can be defined as a multi-tier or group of containers that are deployed on a single worker node or docker host.
In my setup we have 3 worker nodes (minion) and 1 master node. I have mentioned the components which will be installed on Master node and and Worker node.
I have created 4 VM’s on ESXI 5.5 version running Centos 7.4 on HP DL380 ,Gen 8 , Server. Each VM has 50 GB drive, 6GB Ram.
Let me give some initial tips so that it can save your troubleshooting time post installation.
Ensure all nodes are time synced , you need to configure NTP service Master and worker nodes ,this is very vital else worker node will fail to register with Master node.
Ensure that iptables is set to 1 in the sysctl.conf. Node may not register without this setting.
net.bridge.bridge-nf-call-iptables = 1
1) Preparing Hostname,Firewall,Selinux and the Repos
Prepare all the hosts, Master and work er nodes as mentioned below.
Setting UP Repository
Install Kubeadm and Docker
I installed kubedm unknowingly
Disable Swap Off
initialize and setup kubernetes master
Now that we have initialized Kubernetes successfully, lets us allow your user to start using the cluster.
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
You should now deploy a pod network to the cluster.
Run “kubectl apply -f [podnetwork].yaml” with one of the options listed at:
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.0.32:6443 –token kxnfd3.a0g83o8jjioudpbc \
For Sudo user and root
Verify kubectl command is activated.
To make the cluster status ready and kube-dns status running, deploy the pod network so that containers of different host communicated each other. POD network is the overlay network between the worker nodes.
Run the below command to deploy network.
Lets verify the status now
Join the Worker Node to the Kubernetes Cluster
# kubectl get nodes
NAME STATUS ROLES AGE VERSION
masternode.ranjeetbadhe.com Ready master 42h v1.18.2
workernode1.ranjeetbadhe.com Ready 41h v1.18.2
workernode2.ranjeetbadhe.com Ready 41h v1.18.2
workernode3.ranjeetbadhe.com Ready 41h v1.18.2
Let us deploy 2 applications now
2 Quagga router
Let us do deployment of NGINX using the NGINX image.
#kubectl describe deployment nginx
CreationTimestamp: Tue, 05 May 2020 12:41:19 +0530
Annotations: deployment.kubernetes.io/revision: 1
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Type Status Reason
—- —— ——
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
NewReplicaSet: nginx-f89759699 (1/1 replicas created)
Type Reason Age From Message
—- —— —- —- ——-
Normal ScalingReplicaSet 2m20s deployment-controller Scaled up replica set nginx-f89759699 to 1
Lets us access now our page from NGINX
On the Chrome Browser
So we have now successfully installed the NGINX on our Kubernettes!!!!
# kubectl config view
- name: kubernetes-admin
# kubectl cluster-info
Kubernetes master is running at https://192.168.0.32:6443
KubeDNS is running at https://192.168.0.32:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
#kubectl describe pod my-nginx
Start Time: Sun, 03 May 2020 19:17:32 +0530
Container ID: docker://55f1ef5ea958664196bf2a64d1653a281fa8beeae96d692359ee7d846ea29f0f
Image ID: docker-pullable://docker.io/nginx@sha256:86ae264c3f4acb99b2dee4d0098c40cb8c46dcf9e1148f05d3a51c4df6758c12
Host Port: 0/TCP
Started: Tue, 05 May 2020 07:10:51 +0530
Last State: Terminated
Exit Code: 0
Started: Sun, 03 May 2020 19:17:46 +0530
Finished: Sun, 03 May 2020 19:19:08 +0530
Restart Count: 1
/var/run/secrets/kubernetes.io/serviceaccount from default-token-72dlf (ro)
Type: Secret (a volume populated by a Secret)
QoS Class: BestEffort
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Type Reason Age From Message
—- —— —- —- ——-
Normal Scheduled 41h default-scheduler Successfully assigned default/my-nginx to workernode1.ranjeetbadhe.com
Normal Pulling 41h kubelet, workernode1.ranjeetbadhe.com Pulling image “nginx”
Normal Pulled 41h kubelet, workernode1.ranjeetbadhe.com Successfully pulled image “nginx”
Normal Created 41h kubelet, workernode1.ranjeetbadhe.com Created container my-nginx
Normal Started 41h kubelet, workernode1.ranjeetbadhe.com Started container my-nginx
Normal SandboxChanged 6h (x5 over 6h) kubelet, workernode1.ranjeetbadhe.com Pod sandbox changed, it will be killed and re-created.
Normal Pulling 6h kubelet, workernode1.ranjeetbadhe.com Pulling image “nginx”
Normal Pulled 6h kubelet, workernode1.ranjeetbadhe.com Successfully pulled image “nginx”
Normal Created 6h kubelet, workernode1.ranjeetbadhe.com Created container my-nginx
Normal Started 6h kubelet, workernode1.ranjeetbadhe.com Started container my-nginx