
- A pod is a group of one or more containers
- A container is a package with software and all its dependencies required to run the application bundled together.
- Containers are grouped as pods and they are the smallest execution unit in Kubernetes
- Kubernetes work with pods.
- All the containers in a pod run in a shared context and are always co-located on the same physical or virtual machine in the cluster
- All containers in a pod share the same network namespace and therefore they can locate each other and communicate via localhost
- A pod can have a single container or multiple containers which will form an application unit. Example a web application and a redis containers can form a multiple container pod
- Example of a multi container pod yaml
apiVersion: "v1"
kind: Pod
metadata:
name: web1
labels:
name: web
app: demo
spec:
containers:
- name: redis
image: redis
ports:
- containerPort: 6379
name: redis
protocol: TCP
- name: python
image: nolaraj/py-red
env:
- name: "REDIS_HOST"
value: "localhost"
ports:
- containerPort: 5000
name: http
protocol: TCP
- Pods are created using the create command .
kubectl create -f FILENAME
- When a pod is created it is assigned its own unique IP address. If there are multiple containers within the pod, they can communicate between each other simply by using localhost
- A pod represents a single instance of a given application and to scale an application we need to run multiple instances of the pod.
- In Kubernetes, this is known as replication.
- Pods run on nodes in a Kubernetes cluster and they remain on the node until its process is complete, or its deleted or evicted due to lack of resources.
kubectl get pod
command is used to inspect the running status of a Pod. A pod can be in one of the following phase- Pending: Pod has been created and accepted by the cluster, but one or more of its containers are not yet running.
- Running: Pod has been bound to a node, and all of the containers have been created.
- Succeeded: All containers in the Pod have terminated successfully.
- Failed: All containers in the Pod have terminated, and at least one container has terminated in failure.
- Unknown: The state of the Pod cannot be determined.
- Pending: Pod has been created and accepted by the cluster, but one or more of its containers are not yet running.
- The phase of a Pod is a high-level summary of where the Pod is in its lifecycle.
- When a Pod starts running, it requests an amount of CPU and memory. This helps Kubernetes schedule the Pod onto an appropriate node to run the workload.
- A Pod will not be scheduled onto a node that doesn’t have the resources to honor the Pod’s request. A request is the minimum amount of CPU or memory that Kubernetes guarantees to a Pod.
- By default, a Pod has no upper bound on the maximum amount of CPU or memory it can use on a node. You can set limits to control the amount of CPU or memory your Pod can use on a node. A limit is the maximum amount of CPU or memory that Kubernetes guarantees to a Pod.
Thank You !!
Nice blog,
Write something about git, suggestion on how to manage our repository in micro services and CICD world.
🙂
Thanks Santosh. I write only about easy subjects 😛
🙂
Nіce post. I ԝas checking constantly this blog and I am impressed!
Very useful info particularly tһe last part 🙂 Ι caгe for such information a lot.
I was seeking this particuⅼar info for a lօng time.
Thank you and best of luϲk.