Working With Kubernetes

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.

Master Node

  • 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

Worker Node

  • 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.

vi /etc/sysctl.conf
net.bridge.bridge-nf-call-iptables = 1
sysctl -p

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 –token kxnfd3.a0g83o8jjioudpbc \
–discovery-token-ca-cert-hash sha256:5ed5884c8aefe300885d77ba761e0f3dee417d295f92b70d0616c9be32652273

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 Ready master 42h v1.18.2 Ready 41h v1.18.2 Ready 41h v1.18.2 Ready 41h v1.18.2

Deploying Applications

Let us deploy 2 applications now

  1. Nginx

2 Quagga router

Let us do deployment of NGINX using the NGINX image.

#kubectl describe deployment nginx
Name: nginx
Namespace: default
CreationTimestamp: Tue, 05 May 2020 12:41:19 +0530
Labels: app=nginx
Annotations: 1
Selector: app=nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=nginx
Image: nginx
Host Port:
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
apiVersion: v1

  • cluster:
    certificate-authority-data: DATA+OMITTED
    name: kubernetes
  • context:
    cluster: kubernetes
    user: kubernetes-admin
    name: kubernetes-admin@kubernetes
    current-context: kubernetes-admin@kubernetes
    kind: Config
    preferences: {}
  • name: kubernetes-admin
    client-certificate-data: REDACTED
    client-key-data: REDACTED

# kubectl cluster-info
Kubernetes master is running at
KubeDNS is running at

#kubectl describe pod my-nginx

Name: my-nginx
Namespace: default
Priority: 0
Start Time: Sun, 03 May 2020 19:17:32 +0530
Labels: run=my-nginx
Status: Running
Container ID: docker://55f1ef5ea958664196bf2a64d1653a281fa8beeae96d692359ee7d846ea29f0f
Image: nginx
Image ID: docker-pullable://
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Tue, 05 May 2020 07:10:51 +0530
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Sun, 03 May 2020 19:17:46 +0530
Finished: Sun, 03 May 2020 19:19:08 +0530
Ready: True
Restart Count: 1
/var/run/secrets/ from default-token-72dlf (ro)
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Type: Secret (a volume populated by a Secret)
SecretName: default-token-72dlf
Optional: false
QoS Class: BestEffort
Tolerations: for 300s for 300s
Type Reason Age From Message
—- —— —- —- ——-
Normal Scheduled 41h default-scheduler Successfully assigned default/my-nginx to
Normal Pulling 41h kubelet, Pulling image “nginx”
Normal Pulled 41h kubelet, Successfully pulled image “nginx”
Normal Created 41h kubelet, Created container my-nginx
Normal Started 41h kubelet, Started container my-nginx
Normal SandboxChanged 6h (x5 over 6h) kubelet, Pod sandbox changed, it will be killed and re-created.
Normal Pulling 6h kubelet, Pulling image “nginx”
Normal Pulled 6h kubelet, Successfully pulled image “nginx”
Normal Created 6h kubelet, Created container my-nginx
Normal Started 6h kubelet, Started container my-nginx

Leave a Reply

Your email address will not be published. Required fields are marked *