ポッドのヘルスチェック
Liveness probe
問題を検知すると、コンテナを強制終了しして再び起動する
アプリケーション固有のロジックを使って、アプリケーションが単に動いているだけではなく正常に応答するかをチェックする
マニフェスト
code:yaml
apiVersion: v1
kind: Pod
metadata:
name: kuard
spec:
containers:
- image: kuard-amd64:1
imagePullPolicy: IfNotPresent
name: kuard
livenessProbe:
httpGet:
path: /healthy
port: 8080
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
ports:
- containerPort: 8080
name: http
protocol: TCP
initialDelaySeconds
Pod 内の全コンテナが作成されて 5 秒経過するまではリクエストを送らない
http://localhost:8080/-/liveness
fail 押すとリクエストが fail しだし、コンテナの再起動が実施される
code:web
Warning Unhealthy 55s (x3 over 75s) kubelet, docker-desktop Liveness probe failed: HTTP probe failed with statuscode: 500
Normal Killing 55s kubelet, docker-desktop Container kuard failed liveness probe, will be restarted
Normal Started 54s (x2 over 5m23s) kubelet, docker-desktop Started container kuard
Readiness probe
コンテナがユーザからのリクエストを処理できるまでポッドへのリクエストを停止する
#Kubernetes
#Pod