Exercise Pods Basics and Multi-Container Pods
Table of Contents
Introduction
In this lab, let us explore the basics of Kubernetes Pods, including how to create single-container Pods and multicontainer Pods. We will also cover the key fields in a Pod definition file.
Task 1: Nginx Pod
Create a YAML specification for an Nginx Pod:
Name:
nginx-podContainer:
nginxwith imagenginx:1.14.2
Create a file named nginx-pod.yaml using the vi editor:
Add the following content to nginx-pod.yaml:
Apply the Pod configuration using the following command:
Check the status of the Pod:
Task 2: Busybox Pod
Create a YAML specification for a Busybox Pod:
Name:
busybox-podContainer:
busyboxwith imagebusybox:1.33.1Command: Run a simple sleep command (e.g.,
sleep 3600)
Create a file named busybox-pod.yaml using the vi editor:
Add the following content to busybox-pod.yaml:
Apply the Pod configuration using the following command:
Check the status of the Pod:
Task 3: Multicontainer Pod
Create a YAML specification for a multicontainer Pod:
Name:
multicontainer-podContainers:
nginx-containerwith imagenginx:1.14.2busybox-containerwith imagebusybox:1.33.1Command: Run a simple sleep command (e.g.,
sleep 3600) in thebusybox-container
Create a file named multicontainer-pod.yaml using the vi editor:
Add the following content to multicontainer-pod.yaml:
Apply the Pod configuration using the following command:
Check the status of the Pod:
Fields in a Pod Definition File
apiVersion: Specifies the version of the Kubernetes API to use.
kind: Indicates the type of resource (e.g., "Pod").
metadata: Contains information about the Pod, such as its name, labels, and annotations.
spec: Describes the desired state of the Pod, including the containers, volumes, and other settings.
For detailed information, refer to the official Kubernetes documentation on Pods.
For more insights on this topic, have a look on my blog post on Walking Through Pods.
Multi-Container Pods
A multi-container Pod in Kubernetes is a Pod that contains two or more related containers. These containers share resources such as network space, shared volumes, and work together as a single unit. Multi-container Pods are useful for scenarios where tightly coupled processes need to run together or when containers must share resources within the same logical host.
References
Last updated