Skip to main content

Command Palette

Search for a command to run...

Live, Ready, Deploy!

Updated
2 min read
A

DevOps engineer & developer passionate about building scalable, reliable systems. I design and automate pipelines, manage cloud infrastructure, and ensure deployments run smoothly. Turning complex workflows into seamless operations is my craft.

Implementing Liveness & Readiness Probes in Kubernetes with Docker & Helm


📖 Story Time

A few months back, I deployed a Flask app to Kubernetes and assumed everything was perfect — until it wasn’t. The pod crashed silently, and my cluster kept thinking it was healthy. Why? I never added liveness and readiness probes.

Now, I never deploy anything without them.

In this blog, you’ll:

  • Understand what probes actually do.

  • Add them to a real Flask app.

  • Package it with Docker.

  • Deploy it using Helm.

Let’s make your apps live, ready, and unstoppable.


🧪 What Are Liveness & Readiness Probes?

Probe TypeWhat It Does
LivenessChecks if your app is alive (healthy). If not, it restarts the container.
ReadinessChecks if your app is ready to receive traffic. If not, K8s removes it from the Service endpoints.

The App – A Simple Flask Service

app.py:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return "Welcome to the Live App"

@app.route('/healthz')
def healthz():
    return "OK", 200

@app.route('/readyz')
def readyz():
    return "READY", 200

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)

Dockerfile

FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]

requirements.txt:

flask

Helm Chart – With Probes Added

Helm chart folder: helm/flask-probe-app

values.yaml:

image:
  repository: your-dockerhub-username/flask-probe
  tag: latest
  pullPolicy: IfNotPresent

service:
  port: 80
  targetPort: 5000

livenessProbe:
  path: /healthz
  port: 5000
  initialDelaySeconds: 5
  periodSeconds: 10

readinessProbe:
  path: /readyz
  port: 5000
  initialDelaySeconds: 5
  periodSeconds: 10

templates/deployment.yaml (relevant part):

livenessProbe:
  httpGet:
    path: {{ .Values.livenessProbe.path }}
    port: {{ .Values.livenessProbe.port }}
  initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
  periodSeconds: {{ .Values.livenessProbe.periodSeconds }}

readinessProbe:
  httpGet:
    path: {{ .Values.readinessProbe.path }}
    port: {{ .Values.readinessProbe.port }}
  initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
  periodSeconds: {{ .Values.readinessProbe.periodSeconds }}

Build & Deploy

1. Build & Push Docker Image

docker build -t your-dockerhub-username/flask-probe .
docker push your-dockerhub-username/flask-probe

2. Install with Helm

helm install flask-app helm/flask-probe-app

3. Verify Health Probes

kubectl describe pod [your-pod-name]
kubectl get endpoints
kubectl logs [your-pod-name]

What You’ve Learned

  • How to make your app production-ready with probes

  • How to dockerize and Helm-deploy your app

  • How Kubernetes treats probe failures (restart vs remove from service)

Final Thoughts

Adding health probes isn’t just a good practice — it’s a lifesaver for production workloads. Next time your pod misbehaves, K8s will know exactly what to do.

More from this blog

Stack OverFlowed

14 posts