Kubernetes pods are the smallest units in the ecosystem. A pod is basically a container of containers. Kinda confused? yeh! Containers or Docker containers contain your app and know how to deploy it in an ideal situation.
Before Kubernetes can help you scale your app to your desired amount of users. We need to have our app and its docker file ready to deploy.
Pods refer to the smallest unit in the Kubernetes ecosystem as I mentioned earlier or we can say that this is a bag of docker containers that enclose our application instance.
A single node can hold a lot of pods till it’s filled. Once a node is filled another node is created to make sure that applications availability isn’t affected.
Let’s say we have a node application that use’s Redis for caching and our app is ready a pod is a complete collection of these containers that you make your whole app.
That’s the basic concept of pods. Now let’s see how to quickly make a few pods in our cluster.
Pods in action.
The command below will create a pod named Nginx and deploy the Nginx image from the docker hub.
root@controlplane:~ kubectl run nginx --image=nginx pod/nginx created root@controlplane:~ kubectl get pods NAME READY STATUS RESTARTS AGE nginx 1/1 Running 0 115s root@controlplane:~# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx 1/1 Running 0 2m3s 10.244.0.4 controlplane <none> <none> root@controlplane:~
Kubectl get pods will show us the pods that are running and wide options shows the IP address and a few more details about the pods.
If we want even more details then we can use the kubectl describe pod command.
root@controlplane:~# kubectl describe pod nginx Name: nginx Namespace: default Priority: 0 Node: controlplane/10.7.187.9 Start Time: Tue, 28 Sep 2021 05:37:22 +0000 Labels: run=nginx Annotations: <none> Status: Running IP: 10.244.0.4 IPs: IP: 10.244.0.4 Containers: nginx: Container ID: docker://f54fec50c632399275671956961b32d53dddadd956fd7e1e6dcf215e4542b8da Image: nginx Image ID: docker-pullable://nginx@sha256:3f1b44820597d0e6b763ff104bc04c11b9e51238f3e0d6109e1ed1ecf58ffad5 Port: <none> Host Port: <none> State: Running Started: Tue, 28 Sep 2021 05:37:35 +0000 Ready: True Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-6nzg7 (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: default-token-6nzg7: Type: Secret (a volume populated by a Secret) SecretName: default-token-6nzg7 Optional: false QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 5m4s default-scheduler Successfully assigned default/nginx to controlplane Normal Pulling 5m2s kubelet Pulling image "nginx" Normal Pulled 4m51s kubelet Successfully pulled image "nginx" in 10.960110215s Normal Created 4m51s kubelet Created container nginx Normal Started 4m51s kubelet Started container nginx
This provides all the things we need to know about the pod. Like the node and node IP address and pod IP address container ids etc.
We can also see where the Nginx image was pulled from in this case it was docker hub. All the events a pod went through before it deployed can be seen in the last paragraph under events.
Thats all about pods see you in the next post about writing YAML files for Kubernetes. You may also like the post I wrote earlier on locally setting up Kubernetes and if you would like to know more about Kubernetes pods you can reference Kubernetes.io.