User Tools

Site Tools


k8s:core:spec

spec

spec defines the desired state of the object.

This is the most important part of any Kubernetes YAML.

What it contains

Depends on the object:

  • Pod → containers
  • Deployment → replicas + pod template
  • Service → ports + selector
  • Volume → storage config

Example (Pod)

spec: containers: - name: nginx image: nginx

Example (Deployment)

spec: replicas: 3 selector: matchLabels: app: web

Real-world analogy

spec = “what you want the system to achieve”

Example:

  • “I want 3 running pods”
  • “I want nginx container”
  • “I want traffic exposed on port 80”

Key idea

spec is the instruction set for Kubernetes reconciliation loop

k8s/core/spec.txt · Last modified: by phong2018