Skip to content

Conversation

@ioquatix
Copy link
Member

@ioquatix ioquatix commented Feb 27, 2025

Kubernetes has an out-of-band readiness probe, which does not follow the sd_notify model. To integrate async-container controllers with Kubernetes, readiness notifications can now be written to a log file, which Kubernetes can check using a readiness probe.

Usage

To enable this feature, set the NOTIFY_LOG environment variable when running a containerized application:

NOTIFY_LOG=/tmp/notify.log falcon host

During startup, the process logs structured JSON messages:

{"status":"Initializing..."}
{"ready":true}

Once the log contains {"ready":true}, Kubernetes can detect that the process is ready.

Example: Kubernetes Deployment Configuration

The following Kubernetes deployment defines an exec-based readiness probe to check for the readiness message in the log file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: falcon
spec:
  replicas: 1
  selector:
    matchLabels:
      app: falcon
  template:
    metadata:
      labels:
        app: falcon
    spec:
      containers:
        - name: falcon
          image: your-container-image
          env:
            - name: NOTIFY_LOG
              value: "/tmp/notify.log"
          command: ["falcon", "host"]
          readinessProbe:
            exec:
              command: ["sh", "-c", "grep -q '\"ready\":true' /tmp/notify.log"]
            initialDelaySeconds: 5
            periodSeconds: 5
            failureThreshold: 3

How It Works

  1. The process writes readiness messages to /tmp/notify.log.
  2. Kubernetes executes grep -q '\"ready\":true' /tmp/notify.log every 5 seconds.
  3. If the message is found, the pod is marked Ready.
  4. If the message is missing, the pod remains in Not Ready state.
  5. If the probe fails three times, Kubernetes considers the pod unhealthy.

This allows async-container controllers to integrate with Kubernetes readiness probes without requiring systemd or additional dependencies.

Types of Changes

  • New feature.

Contribution

@ioquatix ioquatix self-assigned this Feb 27, 2025
@ioquatix ioquatix merged commit a3512ce into main Feb 27, 2025
40 of 48 checks passed
@ioquatix ioquatix deleted the notify-log branch February 27, 2025 06:46
@ioquatix ioquatix added this to the v0.23.0 milestone Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants