# A Deployment describes a desired state ("I want 1 copy of nginx running, # serving this ConfigMap's index.html") and hands it to Kubernetes, whose # job is to continuously make reality match that description. If the Pod # crashes, Kubernetes restarts it. If the node dies, Kubernetes (given more # than one node — see docs/09-growing-up.md) reschedules it elsewhere. # You never tell Kubernetes "start a container" directly; you describe the # end state and it does the work. This is what "declarative" means. apiVersion: apps/v1 kind: Deployment metadata: name: demo namespace: demo spec: replicas: 1 selector: # Tells the Deployment which Pods belong to it. Must match # spec.template.metadata.labels below, or Kubernetes won't know # this Deployment owns the Pods it creates. matchLabels: app: demo template: metadata: labels: app: demo spec: containers: - name: nginx image: nginx:1.27-alpine ports: - containerPort: 80 volumeMounts: # Mounts the ConfigMap's index.html over nginx's default page. - name: page mountPath: /usr/share/nginx/html volumes: - name: page configMap: name: demo-page