How to create a pod in Kubernetes.
Pods:
Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.
A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. A Pod's contents are always co-located and co-scheduled, and run in a shared context. A Pod models an application-specific "logical host": it contains one or more application containers which are relatively tightly coupled. In non-cloud contexts, applications executed on the same physical or virtual machine are analogous to cloud applications executed on the same logical host.
What is a Pod?
The shared context of a Pod is a set of Linux namespaces, cgroups, and potentially other facets of isolation - the same things that isolate a container. Within a Pod's context, the individual applications may have further sub-isolations applied.
A Pod is similar to a set of containers with shared namespaces and shared filesystem volumes.
Creating a pod using yaml file:
The following is an example of a Pod which consists of a container running the image: docker.io/httpd and save this yaml code in a file.
apiVersion: v1
kind: Pod
metadata:
name: mypod #name of the pod
labels:
class: cka #labels
spec:
containers:
- name: httpd #name of the conatiner
image: docker.io/httpd #container image
ports:
- containerPort: 80
- To run this yaml file use command:
kubectl create -f (filename)
- To check if the pods are in a running state or have some issue
kubectl get pods
- To go inside the pod and use terminal
kubectl exec -it (podname) bash
- To delete a pod
kubectl delete pod (podname)
Subscribe to my newsletter
Read articles from Dinesh Jagdish Verma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Dinesh Jagdish Verma
Dinesh Jagdish Verma
Passionate about technology and its endless possibilities, I am a BCA graduate who embarked on a journey to explore the world of IT. With a strong foundation in Linux and a keen interest in cloud computing, I delved into the realms of Docker, Podman, and AWS, honing my skills along the way. As a constant learner, I am currently immersing myself in the intricacies of Kubernetes, eager to unlock its full potential for scalable and efficient application deployment. My goal is to leverage this powerful container orchestration platform to streamline DevOps processes and drive seamless digital transformations. With a solid understanding of system administration, containerization, and cloud infrastructure, I am equipped to tackle complex challenges and deliver innovative solutions. I thrive in collaborative environments, leveraging my communication skills to effectively bridge the gap between technical complexities and business objectives. Driven by curiosity and fueled by a growth mindset, I continuously seek out new technologies and industry trends. I am excited to connect with like-minded professionals, exchange knowledge, and contribute to the ever-evolving tech landscape. If you're looking for a dedicated and adaptable IT professional who can navigate the dynamic world of containers, cloud, and beyond, let's connect and embark on a transformative journey together.