Cloud Fortgeschritten
Kubernetes Pod Lifecycle¶
KubernetesPodLifecycle 3 Min. Lesezeit
Pod-Lifecycle in Kubernetes. Phasen, Init-Container, Probes und Graceful Shutdown.
Pod-Phasen¶
- Pending — Scheduling, Image Pull
- Running — mindestens ein Container läuft
- Succeeded — alle Container erfolgreich beendet
- Failed — mindestens ein Container fehlgeschlagen
- Unknown — Status kann nicht ermittelt werden
Probes¶
spec:
containers:
- name: app
livenessProbe: # Lebt der Container?
httpGet: {path: /healthz, port: 8080}
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe: # Ist er bereit für Traffic?
httpGet: {path: /ready, port: 8080}
initialDelaySeconds: 5
startupProbe: # Für langsamen Start
httpGet: {path: /healthz, port: 8080}
failureThreshold: 30
periodSeconds: 10
Graceful Shutdown¶
Kubernetes sendet SIGTERM, wartet terminationGracePeriodSeconds (Standard 30s), dann SIGKILL.
process.on('SIGTERM', async () => {
console.log('Shutting down...');
server.close();
await db.disconnect();
process.exit(0);
});
Zusammenfassung¶
Korrekte Probes und Graceful Shutdown = Zero-Downtime-Deployment. Konfigurieren Sie immer eine Readiness Probe.
Brauchen Sie Hilfe bei der Implementierung?¶
Unser Team hat Erfahrung mit dem Entwurf und der Implementierung moderner Architekturen. Wir helfen Ihnen gerne.