Docker & Kubernetes for Developers · Lezione

Controlli di salute: probe di liveness, readiness e startup

Usi le probe di Kubernetes per rilevare i container non funzionanti, bloccare il traffico finché le app non sono pronte e dare ai processi lenti il tempo di avviarsi.

Lezione 4 di 413 passaggi

Controlli di salute: probe di liveness, readiness e startup è una lezione Docker & Kubernetes for Developers gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Docker & Kubernetes for Developers, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Docker & Kubernetes for Developers include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Why Probes Matter

Kubernetes cannot know your app is healthy just because the process is running. Probes let you tell the kubelet how to check real application health.

The Three Probe Types

There are three: liveness (restart if broken), readiness (gate traffic), and startup (protect slow boots).

Liveness Probe

If the liveness probe fails, the kubelet restarts the container. Use it to recover from deadlocks the process cannot detect itself.

livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  initialDelaySeconds: 10
  periodSeconds: 10

Readiness Probe

If readiness fails, the Pod is removed from Service endpoints but NOT restarted. This stops traffic to a Pod that is temporarily unable to serve.

readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  periodSeconds: 5

Liveness vs Readiness

Liveness answers should I restart this; readiness answers should I send traffic. Using readiness as liveness causes needless restarts; the opposite causes failed requests.

Startup Probe

A startup probe disables liveness and readiness until the app finishes booting, perfect for slow-starting legacy apps.

startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  failureThreshold: 30
  periodSeconds: 10

Probe Mechanisms

Probes can use httpGet, a raw tcpSocket connection, or run a command with exec, succeeding when the command exits 0.

livenessProbe:
  exec:
    command: ["cat", "/tmp/healthy"]

Tuning Timing

Key knobs: initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, and successThreshold let you balance speed of detection against false positives.

Probes and Rollouts

Readiness probes make rolling updates safe: new Pods only receive traffic once ready, so a broken release does not serve users.

Debugging Failing Probes

Probe failures show up in events. Describe the Pod to see why it restarts or never becomes ready.

kubectl describe pod my-pod

Common Mistakes

Avoid heavy health endpoints that themselves cause timeouts, and avoid too-short initialDelaySeconds that restart Pods before they finish booting.

Quick Check

Test what you have learned.

Recap

You learned the three probe types: liveness restarts, readiness gates traffic, startup protects slow boots, the http/tcp/exec mechanisms, timing knobs, and how readiness keeps rollouts safe.

Gratis per iniziare

Impara Docker & Kubernetes for Developers con un tutor IA — gratis

Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.

Corsi
12
Lezioni
48

Domande Frequenti

La lezione «Controlli di salute: probe di liveness, readiness e startup» è gratuita?

Sì — il testo completo di «Controlli di salute: probe di liveness, readiness e startup» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Docker & Kubernetes for Developers, passa a CoddyKit PRO. Il corso Docker & Kubernetes for Developers include 4 lezioni in totale.

Cosa imparerò in «Controlli di salute: probe di liveness, readiness e startup»?

Usi le probe di Kubernetes per rilevare i container non funzionanti, bloccare il traffico finché le app non sono pronte e dare ai processi lenti il tempo di avviarsi. Eserciti Docker & Kubernetes for Developers con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Docker & Kubernetes for Developers?

Non è richiesta alcuna esperienza precedente. Docker & Kubernetes for Developers su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Controlli di salute: probe di liveness, readiness e startup»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Docker & Kubernetes for Developers?

Sì. Ogni lezione Docker & Kubernetes for Developers include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Strategie di logging in Kubernetes
  2. Monitoraggio con Prometheus e Grafana
  3. Risoluzione dei problemi comuni di K8s
  4. Controlli di salute: probe di liveness, readiness e startup
← Torna a Docker & Kubernetes for Developers