Course contentsShow
← Cloud and Infrastructure
Lesson 1424 of 2,98929. Kubernetes ObservabilityFree lesson

TCP Socket Probes

Implement TCP socket probes for services that don't expose HTTP endpoints.

TCP Socket Probes

What you'll learn: How to configure TCP socket probes to health-check services that communicate over raw TCP connections without HTTP endpoints.

Why TCP Socket Probes Matter

Not all services speak HTTP. Databases like Redis, message queues like RabbitMQ, and custom TCP services need health checks too, but they don't expose HTTP endpoints for probes to query. This is where TCP socket probes come in—they simply attempt to open a TCP connection to verify the service is listening and accepting connections.

Think of it like knocking on a door. An HTTP probe is like ringing the doorbell and waiting for someone to answer with a specific message. A TCP socket probe just checks if the door opens at all—if the connection succeeds, the service is considered healthy.

Configuring TCP Socket Probes

TCP socket probes work with liveness, readiness, and startup probes. You specify the port number, and Kubernetes attempts to establish a TCP connection:

livenessProbe:
  tcpSocket:
    port: 6379  # Redis default port
  initialDelaySeconds: 15
  periodSeconds: 10

readinessProbe:
  tcpSocket:
    port: 6379
  initialDelaySeconds: 5
  periodSeconds: 5

If the connection succeeds, the probe passes. If it times out or is refused, the probe fails. This makes TCP probes perfect for services where simply accepting connections indicates health.

When to Use TCP Socket Probes

Use TCP socket probes when:

  • Your service doesn't have an HTTP interface
  • Connection acceptance itself indicates readiness (databases, caches)
  • You need lightweight health checks without application-level logic

Key Takeaway: TCP socket probes health-check non-HTTP services by attempting to establish TCP connections—if the port accepts the connection, the container is considered healthy, making them ideal for databases and other TCP-based services.