Nhập môn Kubernetes
Frank Heilmann
Platform Architect and Freelance Instructor
Ứng dụng stateful:
Khi bị gián đoạn hoặc dừng, bản sao (Pod) mới có thể đọc trạng thái đã lưu và tiếp tục từ đó
apiVersion, kind, metadata, spec, templatereplicas xác định số Pod trong StatefulSetselector sauapiVersion: apps/v1
kind: StatefulSet
metadata:
name: <deployment name>
labels:
app: <a label for the application>
spec:
replicas: <number of initial replicas>
selector:
matchLabels:
app: <matches the label above>
template:
metadata:
labels:
app: <label to be given to each pod>
spec:
containers:
- name: <container name>
image: <the image to be used>
ports:
- containerPort: <ports for networking>
StatefulSet tương tự Deployments:
kubectl apply -f <manifest.yml>StatefulSet được tạo khác Deployment:pod-0, pod-1, pod-2, v.v.StatefulSet với danh tính khác
có thể đảm nhiệm vai trò khác nhau trong ứng dụngreplicas trong Manifest và áp dụng lại,kubectl scale statefulsets ...pod-0, pod-1, pod-2, trước pod-3,
rồi thêm pod-4pod-4 trước, rồi pod-3kubectl cho các tác vụ giám sát cơ bảnkubectl get pods trả về tất cả pod trong StatefulSet
cùng trạng thái hiện tạikubectl get services trả về các service mà
StatefulSet có thể dùngNhập môn Kubernetes