Validating the Kubernetes cluster

MrDevSecOps
3 min readFeb 11, 2022

--

We will validate the K8s cluster configured using kubeadm in the previous article and we will also deploy the sample deployment and will ensure everything is working as it should be.

  1. Validating CMD Tools

Ensure kubeadm and kubectl version is as per your cluster setup.

$ kubeadm version
$ kubeadm version --short 

2. Validating Cluster Nodes

Ensure all nodes including Master and Worker nodes are Ready state.

$ kubectl get nodes 
$ kubectl get nodes -o wide

3. Validating Kubernetes Components

Ensure all K8s Master node components are in Running state.

$ kubectl get pods -n kube-system
$ kubectl get pods -n kube-system -o wide

4. Validating Services: Docker & Kubelet

Ensure Docker and Kubelet Services are “Active(Running) and Enabled on all nodes.

$ systemctl status docker 
$ systemctl status kubelet

5. Deploying the Nginx application.

a) Let's create a deployment on the master node named “Nginx-deploy” using YAML.

$ vi nginx-deploy.yaml

Deployment YAML file should like below

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx-app
spec:
replicas: 1
selector:
matchLabels:
app: nginx-app
template:
metadata:
labels:
app: nginx-app
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80

b) Let's create a pod using kubectl command

$ kubectl apply -f nginx-deploy.yaml

c) Let's check Pod status

$ kubectl get pods
$ kubectl get pods -o wide

d) Expose the Nginx deployment using Kubernetes NodePort (32001) service

$ vi nginx-service.yaml

e) Service YAML file

apiVersion: v1
kind: Service
metadata:
name: nginx-app
spec:
selector:
app: nginx-app
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 32001

f) Create a Service using the kubectl command

$ kubectl apply -f nginx-service.yaml

g) Check the service

$ kubectl get service

In my case pods are running, on worker node 1,

f) Now access the Nginx service by using worker node-1 IP and port 32001, make sure ports are open.

Also, check

Kubernetes Tutorials

--

--

MrDevSecOps

Integrating security into the software development lifecycle.