apiVersion: apps/v1 kind: Deployment metadata: name: probe-web labels: app: probe-web spec: replicas: 1 selector: matchLabels: app: probe-web template: metadata: labels: app: probe-web spec: containers: - name: web image: python:3.12-alpine ports: - name: http containerPort: 8080 command: - /bin/sh - -c - | touch /tmp/ready /tmp/live python - <<'PY' from http.server import BaseHTTPRequestHandler, HTTPServer from pathlib import Path class Handler(BaseHTTPRequestHandler): def do_GET(self): checks = {"/ready": "/tmp/ready", "/live": "/tmp/live"} if self.path == "/": self.send_response(200) self.end_headers() self.wfile.write(b"app\n") return path = checks.get(self.path) if path and Path(path).exists(): self.send_response(200) self.end_headers() self.wfile.write(b"ok\n") return self.send_response(500 if path else 404) self.end_headers() self.wfile.write(b"fail\n") def log_message(self, format, *args): pass HTTPServer(("0.0.0.0", 8080), Handler).serve_forever() PY readinessProbe: httpGet: path: /ready port: http periodSeconds: 3 failureThreshold: 1 livenessProbe: httpGet: path: /live port: http initialDelaySeconds: 6 periodSeconds: 3 failureThreshold: 1 --- apiVersion: v1 kind: Service metadata: name: probe-web spec: selector: app: probe-web ports: - name: http port: 80 targetPort: http