Kubernetes入門
Frank Heilmann
Platform Architect and Freelance Instructor
ステートフルアプリ:
中断や停止時、新しいレプリカ(Pod)が保存状態を読み取り、そこから継続可能
apiVersion, kind, metadata, spec, templatereplicas は StatefulSet の Pod 数を定義selector は後ほど説明apiVersion: 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 のデプロイは Deployment と同様:
kubectl apply -f <manifest.yml>Deployment と異なるpod-0, pod-1, pod-2 のような予測可能な名前になるStatefulSet 内でも異なる ID の Pod が別の役割を担えるreplicas を変更して再適用kubectl scale statefulsets ... を使用pod-0, pod-1, pod-2、次に pod-3、
その後 pod-4 が追加pod-4、次に pod-3kubectl で基本的な監視を行うkubectl get pods は StatefulSet の全 Pod と現状を返すkubectl get services は StatefulSet が利用する可能性のある全 Service を返すKubernetes入門