A pod is the smallest building
block of Kubernetes object model. In a Kubernetes cluster, a pod represents a
running process. Inside a pod, you can have one or more containers. Those
containers all share a unique network IP, storage, network and any other
specification applied to the pod. Another way to think of a pod is that it is
an application-specific “logical host” that holds one or more containers that
that are tightly coupled. Let us take for example we have an “app-container”
and “logging-container” in a pod. “Logging-container’s” only job is to pull
logs from the “app-container”. You can see how having them in a pod eliminates
a lot of extra setup to get them to talk. They are co-located so everything is
local and they share all the same resources. This is the same thing as being
executed on the same physical server in a pre-container world.
<< Previous Next >>
Pod is also designed as mortal.
When pod dies for some reason, such as getting killed by Kubernetes controller
when lacking of resources, it won’t recover itself.
Pod Model Types
There are two model types of pod you can create.
“one-container-per-pod” and “multi-container-pod.
· One-container-per-pod.
This model is the most popular. The Pod acts as a wrapper for a single
container and since Pod is the smallest object Kubernetes knows, it manages the
Pods rather than the containers directly.
· Multi-container-pod.
With this model a pod might hold multiple co-located containers that are
tightly coupled and need to share resources. These containers work as a single
cohesive unit of service. The Pod wraps these containers and storage resources
together as a single unit. Some example use cases are sidecars, proxies,
logging.
Pod Life Cycle
A pod status tells us where the pod is in its
lifecycle. It is meant to give you an idea not for certain, therefore It is
good practice to debug if pod does not come up cleanly. There are 5 phases
during a pod lifecycle.
· Pending –
Pod has been accepted, but one or more of the Container images has not been
created.
· Running –
The Pod has been bound to a node, and all of the Containers have been created.
One Container is still running, or is in the process of starting or restarting.
· Succeeded –
All Containers in the Pod have terminated in success and will not be restarted.
· Failed –
All Containers in the Pod have terminated, and at least one Container has
terminated in failure. The Container exited with non-zero status.
· Unknown –
For some reason the state of the Pod could not be obtained.
Lab:
Deploy a Pod on your Kubernetes
cluster by running below command. This will deploy two containers in a single
pod.
Check status of pod.
kubectl get pods
In case if you want to apply
constraints on Pod level. These constraints will restrict pods from utilizing
additional resources like memory or cpu. we will discuss about constraint in
further tutorials deeply.
kubectl create -f https://raw.githubusercontent.com/mhausenblas/kbe/master/specs/pods/constraint-pod.yaml
To check pod configuration.
kubectl describe pod
constraintpod
<< Previous Next >>
No comments:
Post a Comment