Kubernetes - Creating Multiple Container in a Pod
Last Updated :
23 Jul, 2025
Pre-requisite:- Kubernetes
Kubernetes is a container management tool and it automates container deployment, load balancing, and container scaling. It is open-source and developed by Google in 2014 and written in Golang. All cloud providers adopt Kubernetes. It is scheduled runs and manages isolated containers that are running on virtual, physical, and cloud machine
Kube API- Server - API - Server directly interacts with the user as per instruction written in the YAML file or JSON file and it is the front-end of the control plane
ETCD - It is a Consistent, highly available store and open-source distributed system. It stores the status of the cluster and metadata of all configurations as well as manages the critical data. The key feature of etcd:
- Secure
- Fully replicated
- Fast
- High Available
Controller Manager - The controller manager makes sure that the actual states of the cluster match to desired states
Kube - Scheduler - When the users make requests for the Creation and Management of pods, Kube-scheduler is going to take action on these requests. Kube-scheduler assigns any node to create and run pods
Pod - A pod is like a group of one or more containers deployed together on the same pod. IP address assignment with the pod, not the container that's why the good practice is to create one container in one pod. If a person has required then create multiple containers in the same pod.
Container - A running stage of the image with all required dependencies or software is called a container. It is lightweight and deployed within a minute. It does not require pre-allocation of RAM.
Kube-Proxy - Kube-Proxy assigns the unique IP address to each pod. In Kubernetes, the pod gets the address, not the container that's why it is a good practice to create one container in one pod.
Kubelet - Kubelet is running in the node and it is an agent. It manages and deployment the pods and nodes interact with the master with the help of Kubelet. It receives the instruction from the API server.
Create Multiple Containers in a Pod.
Step 1. Open your machine with successfully installed Kubernetes
Step 2. First of all, create a Manifest file. If a person wants to do anything in Kubernetes first required to create a Manifest. Manifest is a file using the YAML(Yet Another Markup Language)
$ vi multicontainer.yml
- Press enter button then the editor will open
- Then press the "i" button to type the YAML code in the editor
YAML Code for Creating Multiple Containers in a Pod:
kind: Pod
apiVersion: v1
metadata:
name: testpod1
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c",
"while true; do echo Hello-Coder; sleep 5 ; done"]
- name : c01
image: ubuntu
command: ["/bin/bash', "-c" ,
"while true; do echo Hello-Programmer; sleep 5 ; done"]
- Press the "ESC" button
- Then press the ":wq" to save the code and exit the editor
Step 3. Execute the file with the help of the command.
$ kubectl apply -f multicontainer.yml
Then it will show testpod1 created.
Step 4. Check whether your pod is ready or not
$ kubectl get pod
Output:Name - testpod1 , Ready- 2/2, Status - Running
It means the pod is ready with two container
- If a person wants to check both container one by one then used this command
- First container c00
$ kubectl logs -f testpod1 -c c00
Output-
- Check second container c01
$ kubectl logs -f testpod1 -c c01
Output:
Note: Pod name - testpod1
1st Container name - c00
2nd Container name - c01
Similar Reads
DevOps Tutorial DevOps is a combination of two words: "Development" and "Operations." Itâs a modern approach where software developers and software operations teams work together throughout the entire software life cycle.The goals of DevOps are:Faster and continuous software releases.Reduces manual errors through a
7 min read
Introduction
What is DevOps ?DevOps is a modern way of working in software development in which the development team (who writes the code and builds the software) and the operations team (which sets up, runs, and manages the software) work together as a single team.Before DevOps, the development and operations teams worked sepa
10 min read
DevOps LifecycleThe DevOps lifecycle is a structured approach that integrates development (Dev) and operations (Ops) teams to streamline software delivery. It focuses on collaboration, automation, and continuous feedback across key phases planning, coding, building, testing, releasing, deploying, operating, and mon
10 min read
The Evolution of DevOps - 3 Major Trends for FutureDevOps is a software engineering culture and practice that aims to unify software development and operations. It is an approach to software development that emphasizes collaboration, communication, and integration between software developers and IT operations. DevOps has come a long way since its in
7 min read
Version Control
Continuous Integration (CI) & Continuous Deployment (CD)
Containerization
Orchestration
Infrastructure as Code (IaC)
Monitoring and Logging
Microsoft Teams vs Slack Both Microsoft Teams and Slack are the communication channels used by organizations to communicate with their employees. Microsoft Teams was developed in 2017 whereas Slack was created in 2013. Microsoft Teams is mainly used in large organizations and is integrated with Office 365 enhancing the feat
4 min read
Security in DevOps