Probes (Health Checks)¶
ohMyHelm unterstützt livenessProbe, readinessProbe und startupProbe für den Haupt-Container (container) und den Sidecar (sidecar). Die Konfiguration entspricht der Kubernetes-Probe-Spezifikation.
Seit Version 1.18.0 ist startupProbe für Deployment, StatefulSet und DaemonSet verfügbar.
Haupt-Container¶
chart:
container:
livenessProbe:
initialDelaySeconds: 120
failureThreshold: 3
periodSeconds: 10
timeoutSeconds: 3
httpGet:
path: /healthz
port: http
readinessProbe:
initialDelaySeconds: 120
failureThreshold: 3
periodSeconds: 10
timeoutSeconds: 3
httpGet:
path: /healthz
port: http
startupProbe:
failureThreshold: 30
periodSeconds: 10
httpGet:
path: /healthz
port: http
Sidecar¶
chart:
sidecar:
enabled: true
livenessProbe:
initialDelaySeconds: 120
failureThreshold: 3
periodSeconds: 10
timeoutSeconds: 3
httpGet:
path: /healthz
port: http
readinessProbe:
initialDelaySeconds: 120
failureThreshold: 3
periodSeconds: 10
timeoutSeconds: 3
httpGet:
path: /healthz
port: http
startupProbe:
failureThreshold: 30
periodSeconds: 10
httpGet:
path: /healthz
port: http
Probe-Typen¶
| Probe | Zweck |
|---|---|
livenessProbe | Prüft, ob der Container noch läuft. Bei Fehlschlag wird der Container neu gestartet. |
readinessProbe | Prüft, ob der Container Traffic empfangen kann. Bei Fehlschlag wird der Pod aus dem Service entfernt. |
startupProbe | Schützt langsam startende Container. Solange die Startup-Probe fehlschlägt, werden Liveness- und Readiness-Probes nicht ausgewertet. |
Hinweise¶
- Der
port-Wert kann ein Port-Name (z. B.http) oder eine Port-Nummer sein. - Neben
httpGetsind auchtcpSocketundexecals Probe-Handler möglich. - Probes sind optional. Wenn sie nicht gesetzt sind, werden keine Probe-Blöcke im Manifest erzeugt.
Beispiel mit exec-Probe¶
chart:
container:
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
Vollständiges Beispiel: Startup Probe¶
Basierend auf omh-startupProbe-values.yaml:
chart:
enabled: true
deployment: true
fullnameOverride: "startup-probe-demo"
container:
image: nginx:latest
ports:
- name: http
containerPort: 80
protocol: TCP
startupProbe:
failureThreshold: 30
periodSeconds: 10
httpGet:
path: /
port: http
Wann startupProbe verwenden?
Setzen Sie eine Startup-Probe, wenn Ihre Anwendung länger als die Standard-Liveness-Probe braucht, um bereit zu sein. Die Startup-Probe verhindert vorzeitige Neustarts durch die Liveness-Probe während des Hochfahrens.