Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

OpenKruise AdvancedStatefulSet In-Place Update Stall Sentinel

Scrapes OpenKruise controller metrics to detect AdvancedStatefulSet in-place update stalls, image pull lag, and errors.

Categories
CloudInfrastructure

Automates continuous deployment health monitoring for OpenKruise AdvancedStatefulSet workloads across enterprise Kubernetes clusters. The workflow audits OpenKruise controller manager Prometheus metrics to detect in-place container image mutation stalls, persistent volume unready states, and container restart loops before stateful database clusters lose quorum.

How it works

  1. A schedule trigger executes the OpenKruise workload health audit workflow every 15 minutes.
  2. The Python task queries the OpenKruise controller manager Prometheus endpoint on port 8080.
  3. The script extracts in-place update durations, unready pod counts, and container mutation error totals.
  4. An evaluation gate determines whether in-place update times or unready pod tallies breach configured bounds.
  5. When in-place image mutation stalls or pod readiness times out, a high-priority Slack incident alert is dispatched.
  6. When container images update in place without pod recreation, nominal metrics are logged.
  7. A structured JSON audit manifest is emitted for cloud infrastructure governance and release compliance archives.

Architecture diagram

graph TD
    Trigger[Schedule Trigger: 15m] --> ScanMetrics[Python Script: Scrape OpenKruise Metrics]
    ScanMetrics --> EvalBreach{Duration > 600s OR Unready > 2 OR Errors > 0?}
    EvalBreach -- Yes --> SlackAlert[Slack: High-Urgency Workload Alert]
    EvalBreach -- No --> LogNominal[Log: Nominal OpenKruise State]
    SlackAlert --> EmitManifest[Debug Return: OpenKruise Audit Manifest]
    LogNominal --> EmitManifest

Architecture components

  • Trigger: Automated schedule polling at 15-minute recurring intervals.
  • Script Task: Scrapes OpenKruise controller Prometheus metrics using Docker container runners.
  • Decision Gate: Evaluates whether in-place update durations or unready replica counts exceed limits.
  • Notification Task: Dispatches structured Slack alerts with affected workload names and duration metrics.
  • Audit Manifest: Emits JSON execution payloads containing stateful workload health and timestamps.

Key capabilities

  • Continuous surveillance of OpenKruise AdvancedStatefulSet, BroadcastJob, and CloneSet custom resources.
  • Early warning detection for pod mutation webhook failures that prevent in-place container updates.
  • Automated tracking of stateful pod readiness gates ensuring traffic is cut during in-place restart.
  • Zero host dependency execution via isolated containerized Python runners.

What you get

  • Real-time visibility into high-performance stateful workload upgrades without IP change or volume remount.
  • Proactive alerts preventing stateful cluster degradation during database (Elasticsearch, Kafka, Redis) rollouts.
  • Standardized audit manifests containing exact mutation durations, unready pod counts, and error tallies.
  • Zero-overhead deployment compatible with OpenKruise on any production Kubernetes distribution.

Who it's for

  • Platform engineers managing massive stateful applications requiring fast in-place image updates.
  • Database Reliability Engineers (DBREs) upgrading persistent database engines without storage detachment.
  • Site Reliability Engineers ensuring strict application availability during rolling cluster upgrades.
  • DevOps engineers diagnosing container image pre-download delays and readiness gate deadlocks.

Why orchestrate this with Kestra

  • Serverless Docker Isolation: Executes telemetry scraping in ephemeral Docker environments without persistent workers.
  • Centralized Secrets Governance: Protects sensitive Slack webhooks using encrypted namespace secrets.
  • Declarative YAML Workflows: Manages stateful workload surveillance as versioned code in Git repositories.
  • Comprehensive Audit History: Preserves historical rolling update durations in searchable Kestra execution logs.

Use cases

  • Elasticsearch Engine Upgrade: Upgrades Elasticsearch image in place without rebuilding JVM caches.
  • Image Pre-download Timeout: Detects when node image pull daemon takes too long to fetch container layers.
  • Readiness Gate Deadlock: Catches workloads where custom readiness gate conditions are never satisfied.

Inputs

Name Type Default Description
kruise_metrics_url STRING http://kruise-controller-manager.kruise-system.svc.cluster.local:8080 Internal HTTP URL exposing Prometheus metrics for OpenKruise.
statefulset_name STRING es-cluster-data Target OpenKruise AdvancedStatefulSet workload monitored.
max_inplace_update_seconds INT 600 Maximum allowable seconds for in-place update before alerting.
max_unready_pods_threshold INT 2 Maximum allowable unready pod replicas during upgrade.
alert_on_pre_download_failure BOOL true Toggle whether container mutation errors trigger an alert.

Expected outputs

  • {{ outputs.scan_openkruise_telemetry.vars.inplace_update_duration_seconds }}: Observed in-place update duration in seconds.
  • {{ outputs.scan_openkruise_telemetry.vars.unready_pods_count }}: Count of unready pod replicas during the update.
  • {{ outputs.scan_openkruise_telemetry.vars.mutation_errors_total }}: Total count of container mutation errors recorded.
  • {{ outputs.scan_openkruise_telemetry.vars.is_alerting }}: Boolean flag indicating if workload bounds are breached.
  • {{ outputs.scan_openkruise_telemetry.vars.audit_timestamp }}: ISO-8601 UTC timestamp of the OpenKruise audit run.

Prerequisites

  • OpenKruise installed in the Kubernetes cluster with controller manager metrics enabled on port 8080.
  • Network connectivity from the Kestra worker to the OpenKruise controller manager service.
  • Configured Slack incoming webhook URL with permissions to post in platform alert channels.

Secrets

  • SLACK_WEBHOOK_URL: Secure webhook URL for routing workload alerts to the Platform Slack channel.

Quick start

  1. Verify that OpenKruise controller manager exposes Prometheus metrics on HTTP port 8080.
  2. Add the SLACK_WEBHOOK_URL secret within your Kestra namespace settings.
  3. Specify your target workload name in statefulset_name.
  4. Run a manual flow execution via the Kestra UI to validate metric ingestion.
  5. Enable the periodic_kruise_audit schedule trigger to establish automated monitoring.

Common pitfalls and troubleshooting

  • InPlaceUpdate ReadyGate Missing: In-place update requires the Kruise pod readiness gate injected by webhook.
  • Container RestartPolicy Conflict: In-place update is only supported on containers with RestartPolicy Always.
  • Volume Mount Changes: Modifying volume mounts or env vars cannot be done in-place and triggers pod recreate.
  • Node Disk Space Exhaustion: In-place image pulling fails silently if the node root filesystem is full.

How to extend

  • Automated Rollback Trigger: Trigger a Kestra Kubernetes CLI task to rollback the ASTS revision if stall persists.
  • PagerDuty Escalation: Escalate to on-call database engineers if unready pods exceed 50% of total replicas.
  • Multi-Workload Fleet Scan: Expand script parameters to monitor all declared AdvancedStatefulSets across clusters.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.