codegurukool.com · Free coding tutorials & online compiler

Home › Kubernetes Tutorial › Pods and YAML manifests

Pods and YAML manifests

The smallest thing Kubernetes runs.

A Pod holds one or more containers that share a network and storage. You describe objects in YAML files called manifests. Every manifest has apiVersion, kind, metadata and spec. YAML uses indentation (2 spaces, never tabs) and - for list items. Save this as pod.yaml and run kubectl apply -f pod.yaml.

Example code

apiVersion: v1
kind: Pod
metadata:
  name: hello-pod
  labels:
    app: hello
spec:
  containers:
    - name: web
      image: nginx:1.27
      ports:
        - containerPort: 80

Run this code in the online editor

← kubectl and contextsInspect Pods: get, describe, logs →