0Pricing
Docker & Kubernetes for Developers · Lekcja

Kontrole kondycji: sondy liveness, readiness i startup

Użyj sond Kubernetes do wykrywania niesprawnych kontenerów, kierowania ruchu dopiero po gotowości aplikacji oraz zapewnienia wolno uruchamiającym się aplikacjom czasu na start.

Kontrole kondycji: sondy liveness, readiness i startup to bezpłatna lekcja Docker & Kubernetes for Developers na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Docker & Kubernetes for Developers, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Docker & Kubernetes for Developers zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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.

Często zadawane pytania

Czy lekcja „Kontrole kondycji: sondy liveness, readiness i startup” jest bezpłatna?

Tak — pełny tekst „Kontrole kondycji: sondy liveness, readiness i startup” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Docker & Kubernetes for Developers, przejdź na CoddyKit PRO. Kurs Docker & Kubernetes for Developers zawiera 4 lekcji w sumie.

Co nauczysz się w „Kontrole kondycji: sondy liveness, readiness i startup”?

Użyj sond Kubernetes do wykrywania niesprawnych kontenerów, kierowania ruchu dopiero po gotowości aplikacji oraz zapewnienia wolno uruchamiającym się aplikacjom czasu na start. Ćwiczysz Docker & Kubernetes for Developers z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Docker & Kubernetes for Developers?

Nie wymagamy żadnego doświadczenia. Docker & Kubernetes for Developers w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Kontrole kondycji: sondy liveness, readiness i startup”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Docker & Kubernetes for Developers?

Tak. Każda lekcja Docker & Kubernetes for Developers zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Strategie logowania w Kubernetes
  2. Monitorowanie za pomocą Prometheus i Grafana
  3. Rozwiązywanie typowych problemów K8s
  4. Kontrole kondycji: sondy liveness, readiness i startup
← Powrót do Docker & Kubernetes for Developers