Cloud Pokročilý
Kubernetes Pod Lifecycle¶
KubernetesPodLifecycle 3 min čtení
Životní cyklus podu v Kubernetes. Fáze, init kontejnery, probes a graceful shutdown.
Fáze podu¶
- Pending — scheduling, image pull
- Running — alespoň jeden kontejner běží
- Succeeded — všechny kontejnery úspěšně skončily
- Failed — alespoň jeden kontejner selhal
- Unknown — nelze zjistit stav
Probes¶
spec:
containers:
- name: app
livenessProbe: # Je kontejner živý?
httpGet: {path: /healthz, port: 8080}
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe: # Je připraven přijímat traffic?
httpGet: {path: /ready, port: 8080}
initialDelaySeconds: 5
startupProbe: # Pro pomalý start
httpGet: {path: /healthz, port: 8080}
failureThreshold: 30
periodSeconds: 10
Graceful Shutdown¶
Kubernetes pošle SIGTERM, čeká terminationGracePeriodSeconds (default 30s), pak SIGKILL.
process.on('SIGTERM', async () => {
console.log('Shutting down...');
server.close();
await db.disconnect();
process.exit(0);
});
Shrnutí¶
Správné probes a graceful shutdown = zero-downtime deployment. Vždy konfigurujte readiness probe.
Potřebujete pomoct s implementací?¶
Náš tým má zkušenosti s návrhem a implementací moderních architektur. Rádi vám pomůžeme.