In the previous post we talked about Kubernetes Objects. The most important Kubernetes object is a pod.
What is a Kubernetes pod?
A Kubernetes pod is the most basic unit that can be deployed to a Kubernetes cluster. A pod consists of one or more containers. The most basic use case for Kubernetes is to deploy a single container per pod, however there are scenarios where you would want multiple containers in a pod.
For example, If you have a container that processes weather data, you could have another container that downloads weather data and puts it in a place that is accessible by both the containers. If a pod hosts multiple containers, they are always located on the same node and are scheduled together.
The pod also has its own unique IP and all containers within the pod share the same IP address and ports. Think of containers within the pod as sharing a linux namespace. Multiple containers within a pod can access shared data and data can be persisted using persistent volumes, which we will look at later.
The pods are managed by a controller and if one pod crashes, the controller immediately creates a new pod. Horizontal scaling of applications is achieved by creating multiple instances of the pod. The multiple instances are hosted on one or multiple nodes. A ReplicaSet is used to specify the number of instances. The controller ensures that the cluster contains the exact number of instances of the pod as specified in the ReplicaSet.
One thing to note about the pod is that it does not store data permanently. The filespace within the pod is available as long as the pod is alive. If a pod dies, its data goes away too and a new pod created will not have the data. To persist data use a Persistent Volume or a StatefulSet which we will look at later.
In the next post we will look at namespaces and some hands on tutorial too so that you can fire up your laptop again and get working.. see you in the next post.