Wprowadzenie do Kubernetes
Frank Heilmann
Platform Architect and Freelance Instructor
Aplikacje stanowe:
Po przerwaniu lub zatrzymaniu nowa replika (Pod) może odczytać zapisany stan i kontynuować działanie
apiVersion, kind, metadata, spec, templatereplicas definiuje liczbę Podów w StatefulSetselector w dalszej częściapiVersion: 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 jest wdrażany podobnie jak Deployment:
kubectl apply -f <manifest.yml>StatefulSet jest tworzony inaczej niż Deployment:pod-0, pod-1, pod-2 itd.StatefulSet o różnych tożsamościach
mogą pełnić różne role w aplikacjireplicas w manifeście i ponownie zastosować,kubectl scale statefulsets ...pod-0, pod-1, pod-2, potem pod-3,
następnie pod-4pod-4, potem pod-3kubectlkubectl get pods zwraca wszystkie Pody StatefulSetu
z ich bieżącym statusemkubectl get services zwraca wszystkie usługi
używane przez StatefulSetWprowadzenie do Kubernetes