惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
爱范儿
爱范儿
The Cloudflare Blog
Y
Y Combinator Blog
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
G
Google Developers Blog
J
Java Code Geeks
P
Proofpoint News Feed
美团技术团队
Engineering at Meta
Engineering at Meta
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
有赞技术团队
有赞技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Deployment using all three Kubernetes probes
Diya · 2026-05-25 · via DEV Community

Full Example YAML

Here’s a deployment using all three Kubernetes probes:

containers:
  - name: api
    image: my-api:latest

    startupProbe:
      httpGet:
        path: /readyz
        port: 5000
      failureThreshold: 20
      periodSeconds: 15

    readinessProbe:
      httpGet:
        path: /readyz
        port: 5000
      initialDelaySeconds: 5
      periodSeconds: 10
      failureThreshold: 3

    livenessProbe:
      httpGet:
        path: /healthz
        port: 5000
      initialDelaySeconds: 30
      periodSeconds: 20
      failureThreshold: 3

Enter fullscreen mode Exit fullscreen mode

Now let’s break down what Kubernetes is actually doing here.


startupProbe

startupProbe:
  httpGet:
    path: /readyz
    port: 5000
  failureThreshold: 20
  periodSeconds: 15

Enter fullscreen mode Exit fullscreen mode

This tells Kubernetes:

Check /readyz every 15 seconds.
Allow 20 failures before killing the container.

Enter fullscreen mode Exit fullscreen mode

Calculation:

15 seconds × 20 failures = 300 seconds

Enter fullscreen mode Exit fullscreen mode

So Kubernetes gives the application:

5 minutes to fully start

Enter fullscreen mode Exit fullscreen mode

before deciding:

“The application failed to start.”

Default Values

If not specified, Kubernetes uses:

periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
successThreshold: 1

Enter fullscreen mode Exit fullscreen mode

Which means by default:

10 seconds × 3 failures = 30 seconds

Enter fullscreen mode Exit fullscreen mode

Your application may only get:

~30 seconds

Enter fullscreen mode Exit fullscreen mode

before Kubernetes decides startup failed.

This is why slow-starting applications often need a custom startupProbe.

Common Real-World Use Cases

  • Java applications
  • ML workloads
  • applications loading huge caches
  • Python/Gunicorn services
  • applications waiting for database migrations

The important part:

A startup probe failure itself is NOT the issue.

The issue happens only when failures continue beyond the threshold.


readinessProbe

readinessProbe:
  httpGet:
    path: /readyz
    port: 5000
  initialDelaySeconds: 5
  periodSeconds: 10
  failureThreshold: 3

Enter fullscreen mode Exit fullscreen mode

This tells Kubernetes:

Wait 5 seconds after container start.
Then check /readyz every 10 seconds.
If it fails 3 consecutive times:
remove the pod from Service traffic.

Enter fullscreen mode Exit fullscreen mode

Calculation:

10 seconds × 3 failures = 30 seconds

Enter fullscreen mode Exit fullscreen mode

If the application cannot respond successfully for:

30 continuous seconds

Enter fullscreen mode Exit fullscreen mode

the pod becomes:

NotReady

Enter fullscreen mode Exit fullscreen mode

But importantly:

The container is NOT restarted.

Enter fullscreen mode Exit fullscreen mode

Traffic simply stops flowing to it temporarily.

Default Values

If not configured, Kubernetes defaults to:

initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
successThreshold: 1

Enter fullscreen mode Exit fullscreen mode

This means Kubernetes starts checking almost immediately.

That can become dangerous for applications that:

  • take time to boot
  • warm caches
  • establish DB connections
  • initialize workers

Important Concept

A readiness failure usually means:

"Do not send traffic right now."

Enter fullscreen mode Exit fullscreen mode

It does NOT mean:

"The application is dead."

Enter fullscreen mode Exit fullscreen mode

This distinction is extremely important in production.


livenessProbe

livenessProbe:
  httpGet:
    path: /healthz
    port: 5000
  initialDelaySeconds: 30
  periodSeconds: 20
  failureThreshold: 3

Enter fullscreen mode Exit fullscreen mode

This tells Kubernetes:

Wait 30 seconds before starting checks.
Then check /healthz every 20 seconds.
If it fails 3 consecutive times:
restart the container.

Enter fullscreen mode Exit fullscreen mode

Calculation:

20 seconds × 3 failures = 60 seconds

Enter fullscreen mode Exit fullscreen mode

If health checks fail continuously for:

60 seconds

Enter fullscreen mode Exit fullscreen mode

Kubernetes assumes:

“The application is unhealthy or stuck.”

and restarts the container automatically.

Default Values

Kubernetes defaults:

initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
successThreshold: 1

Enter fullscreen mode Exit fullscreen mode

Which effectively means:

10 seconds × 3 failures = 30 seconds

Enter fullscreen mode Exit fullscreen mode

before restart behavior begins.

Common Mistake

Many teams configure aggressive liveness probes like:

timeoutSeconds: 1

Enter fullscreen mode Exit fullscreen mode

During:

  • CPU spikes
  • GC pauses
  • dependency slowness
  • temporary latency

the application may briefly respond slowly.

This can accidentally trigger unnecessary restarts.


The Most Important Thing to Understand

Many engineers panic immediately when they see:

Readiness probe failed

Enter fullscreen mode Exit fullscreen mode

or:

Liveness probe failed

Enter fullscreen mode Exit fullscreen mode

But probes are designed to fail occasionally.

The real question is:

Did the failures exceed the threshold?

Enter fullscreen mode Exit fullscreen mode

Because Kubernetes only takes action after repeated failures over time.

That’s why these settings matter so much:

failureThreshold
periodSeconds
timeoutSeconds
initialDelaySeconds

Enter fullscreen mode Exit fullscreen mode

Together, they control:

  • how patient Kubernetes should be
  • when traffic should stop
  • when restarts should happen
  • how tolerant the system should be during spikes

Probe What Happens on Failure?
startupProbe Container may be killed if startup takes too long
readinessProbe Pod stops receiving traffic
livenessProbe Container gets restarted

Kubernetes probes are not meant to punish applications.

They are safety mechanisms.

The goal is to:

  • avoid sending traffic to unhealthy pods
  • restart stuck applications
  • allow slow startups safely

Once you understand probe thresholds, Kubernetes behavior suddenly becomes much easier to debug.