ืืฉืื ืื ื ืื ื ืืคืืขื StatefulSet ืื ืจืื:
ืืื ืื ืืฉืชืืฉืื ืืื ืืื ืฉืืื.
ื ืืฆืืจ ืงืืืฅ:
vi stateful-set.yaml
ืื ืื ืืก:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: demo-statefulset
spec:
serviceName: busybox # This can be any name (as mentioned in the lecture)
replicas: 2 # We want two replicas
selector:
matchLabels:
app: busybox # Defines which pods are managed by this StatefulSet
template:
metadata:
labels:
app: busybox # Must match the selector above
spec:
containers:
- name: busybox
image: busybox:1.36.1
command: ["sh", "-c", "sleep 3600"]
volumeMounts:
- name: local-storage
mountPath: /mnt/local # Mounted inside container
volumeClaimTemplates:
- metadata:
name: local-storage # This name MUST match volumeMounts.name
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 128Mi