Table of Contents
- Understanding the Top-Level Fields
- Pod Definition Skeleton
- Detailed Field Breakdown
- Deploying Your Pod
- Inspecting Your Pod
- Summary
- Links and References
Understanding the Top-Level Fields
Every Kubernetes manifest shares four mandatory top-level fields. These fields tell Kubernetes what to create, how to version it, and any additional identifying metadata or configuration details.| Field | Description | Example |
|---|---|---|
| apiVersion | API group and version for the resource | v1 |
| kind | Type of Kubernetes object (Pod, Deployment, Service, etc.) | Pod |
| metadata | Key/value pair metadata, including name and labels | name: myapp-pod |
| spec | Desired state specification, varies per resource type | containers: [...] |
YAML is indentation-sensitive. Always use spaces (not tabs) and ensure child elements are indented correctly under their parent keys.
Pod Definition Skeleton
Start with the minimal skeleton for a Pod manifest:Detailed Field Breakdown
apiVersion
Defines the API group and version that Kubernetes will use to process this resource.For Pods, it’s always:
kind
Specifies the type of object to create. For this tutorial:Deployment, Service, and ReplicaSet.
metadata
Contains identifying information such as the resource’s name and optional labels for grouping and selection.- name: A unique identifier for the Pod within its namespace.
- labels: Arbitrary key/value pairs for organizational or selection purposes.
spec
Defines the desired state. In a Pod, this means listing the containers it should run.containersis a YAML list; you can define multiple containers per Pod.- Each container requires at least a
nameandimage. - You can optionally define ports, environment variables, volume mounts, and more.
Kubernetes object names must:
- Contain only lowercase alphanumeric characters and
-. - Start and end with an alphanumeric character.
- Be unique within a namespace.
Deploying Your Pod
- Save your manifest to
pod-definition.yaml. - Run the following command to create the Pod:
Inspecting Your Pod
List All Pods
Describe a Pod
To view detailed status and event logs:Labels, Containers, Conditions, and recent Events.
Summary
In this lesson, you learned how to:- Structure a basic Kubernetes Pod manifest with the required top-level fields.
- Define metadata and container specifications in YAML.
- Deploy your Pod using
kubectl create. - Inspect status and logs with
kubectl getandkubectl describe.