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

  1. Create a YAML specification for an Nginx Pod:

    • Name: nginx-pod

    • Container: nginx with image nginx: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

  1. Create a YAML specification for a Busybox Pod:

    • Name: busybox-pod

    • Container: busybox with image busybox:1.33.1

    • Command: 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

  1. Create a YAML specification for a multicontainer Pod:

    • Name: multicontainer-pod

    • Containers:

      • nginx-container with image nginx:1.14.2

      • busybox-container with image busybox:1.33.1

      • Command: Run a simple sleep command (e.g., sleep 3600) in the busybox-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

  1. apiVersion: Specifies the version of the Kubernetes API to use.

  2. kind: Indicates the type of resource (e.g., "Pod").

  3. metadata: Contains information about the Pod, such as its name, labels, and annotations.

  4. 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