Files
k8s-starter-pack/apps/demo/deployment.yaml
T

47 lines
1.6 KiB
YAML
Raw Normal View History

2026-08-22 17:30:45 +01:00
# 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.
2026-08-22 17:30:45 +01:00
# 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
2026-09-03 03:29:28 +01:00
# Real, replicated storage from apps/demo/pvc.yaml — a harmless
# subdirectory nginx doesn't otherwise use, proving a Longhorn
# volume can actually be attached and written to.
- name: data
mountPath: /usr/share/nginx/html/data
2026-08-22 17:30:45 +01:00
volumes:
- name: page
configMap:
name: demo-page
2026-09-03 03:29:28 +01:00
- name: data
persistentVolumeClaim:
claimName: demo-data