Concepts

POD

With Kubernetes, our ultimate aim is to deploy application in the form of containers on set of machines that are configured as worker nodes in a cluster.
However, kubernetes does not deploy containers directly on the worker node. The container is encapsulated into kubernetes object known as POD.
A POD is a single instance of an application. A POD is the smallest object that we can create in kubernetes.

In a single node kubernetes cluster with a single instance of our application running in a single container encapsulated in a POD. If the number of users accessing the application increase and we need to scale our application, We need to add additional instances of our application to share the load.
In this case, we create a new POD with new instance of the same application. Now, we have two instances of application running on two separate PODS of same kubernetes node. If the demand increases more and the current node has no further capacity, we can create a new POD with the new instance of an application on the new node of the kubernetes cluster. Therefore, to scale up, we create new PODS. To scale down, we delete existing POD.

Multi-Container PODs

PODs usually have one to one relationship with the container. But we are not restricted for having a single container in a single POD.
A single POD can have multiple container except that containers cannot be of same kind.
In order to scale up our application, we need to create additional PODs.
But in some scenarios, we can have helper containers (which will be supporting the application process) in the same POD of application container. In this case, helper containers live along side of the application container in the same POD.
When new application conatiner is created, helper is also created and when the new application container dies, helper container also dies as they are part of same POD.
These two containers can also communicate with each other directly by referring each other as localhost, since they share the same network space plus they can easily share the same storage space.

Kubectl

kubectl run command deploys a docker container by creating a POD

Kubectl run nginx
This first creates a POD automatocally and deploys an instance of the nginx docker image.

To get the application image we need to specify the image name. kubectl run nginx --image=nginx
In this case nginx image is downloaded from the docker hub repository. Here POD name can be anything, but image name should be the image that is available in the docker hub or any container registry.

kubectl get pods
To see the list of PODs in our cluster.

kubectl describe pod nginx
To get more information related to the POD

kubectl get pods -o wide
To get the status of the pod with additional information such as node where the pod is running and the IP address of the pod.