Skip to content

Pods — Example Manifests

simple-pod.yaml — Basic single-container Pod

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: web
    environment: development
spec:
  containers:
    - name: nginx
      image: nginx:latest
      ports:
        - containerPort: 80
          name: http
          protocol: TCP
      env:
        - name: NGINX_PORT
          value: "80"

multi-container-pod.yaml — Pod with sidecar

apiVersion: v1
kind: Pod
metadata:
  name: web-with-logging
  labels:
    app: web-demo
spec:
  containers:
    # Main application container
    - name: nginx
      image: nginx:latest
      ports:
        - containerPort: 80
      volumeMounts:
        - name: logs
          mountPath: /var/log/nginx

    # Sidecar: Log processor
    - name: log-collector
      image: busybox:latest
      command: ['sh', '-c', 'tail -f /logs/access.log']
      volumeMounts:
        - name: logs
          mountPath: /logs

  # Shared volume between containers
  volumes:
    - name: logs
      emptyDir: {}

pod-with-resources.yaml — Pod with resource limits

apiVersion: v1
kind: Pod
metadata:
  name: resource-limited-pod
  labels:
    app: demo
spec:
  containers:
    - name: nginx
      image: nginx:latest
      ports:
        - containerPort: 80
      resources:
        requests:
          memory: "64Mi"
          cpu: "250m"
        limits:
          memory: "128Mi"
          cpu: "500m"

compose.yaml — Docker Compose comparison

# Docker Compose comparison for Pod concepts

version: '3'
services:
  # Simple single-container service
  web:
    image: nginx:latest
    container_name: nginx-pod
    ports:
      - "8080:80"
    environment:
      - NGINX_PORT=80

  # Multi-container example (similar to multi-container Pod)
  # In Docker Compose, you'd typically use separate services
  # In Kubernetes, these go in one Pod when they need to share resources

  app:
    image: nginx:latest
    volumes:
      - logs:/var/log/nginx

  log-collector:
    image: busybox:latest
    command: ['sh', '-c', 'tail -f /logs/access.log']
    volumes:
      - logs:/logs
    depends_on:
      - app

  # Resource-limited service
  limited:
    image: nginx:latest
    mem_limit: 128m
    cpus: 0.5
    mem_reservation: 64m

volumes:
  logs: