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

Kueue Workload Admission Check and Quota Reservation Sentinel

Audits Kubernetes Kueue batch scheduler telemetry to detect pending workload admission backlogs, wait timeouts, and quota exhaustion.

Categories
CloudInfrastructure

Automates continuous health and queue admission surveillance for Kubernetes Kueue batch and AI/ML job schedulers.

How it works

  1. A schedule trigger executes the Kueue queue audit workflow every 15 minutes.
  2. The Python task queries the Kueue controller manager metrics endpoint on port 8080.
  3. The script extracts pending workload counts, admission queuing wait times, and resource flavor reservation ratios.
  4. An evaluation gate determines whether pending workloads, queuing delays, or quota exhaustion breach bounds.
  5. When batch scheduling stalls are detected, a high-priority Slack alert is dispatched to the Batch SRE team.
  6. When workloads admit cleanly into cluster queues within configured limits, nominal telemetry is logged.
  7. A structured JSON audit manifest is emitted for batch compute governance and AI cluster utilization records.

Architecture diagram

graph TD
    Trigger[Schedule Trigger: 15m] --> ScanMetrics[Python Script: Scrape Kueue Metrics]
    ScanMetrics --> EvalBreach{Pending > 50 OR Wait Time > 600s?}
    EvalBreach -- Yes --> SlackAlert[Slack: High-Urgency Batch Alert]
    EvalBreach -- No --> LogNominal[Log: Nominal Kueue State]
    SlackAlert --> EmitManifest[Debug Return: Batch Audit Manifest]
    LogNominal --> EmitManifest

Architecture components

  • Trigger: Automated schedule polling at 15-minute recurring intervals.
  • Script Task: Scrapes Kueue controller manager Prometheus metrics endpoints using Docker container runners.
  • Decision Gate: Evaluates whether pending workload counts or admission queuing delays exceed limits.
  • Notification Task: Dispatches structured Slack alerts with cluster queue identifier and wait metrics.
  • Audit Manifest: Emits JSON execution payloads containing batch queue health and timestamps.

Key capabilities

  • Continuous surveillance of Kueue ClusterQueue, LocalQueue, and Workload custom resource lifecycles.
  • Early warning detection for GPU, TPU, and CPU compute flavor quota saturation across namespaces.
  • Automated tracking of queue head-of-line blocking and fair-sharing borrowing limits.
  • Zero host dependency execution via isolated containerized Python runners.

What you get

  • Real-time visibility into enterprise AI/ML training job scheduling latency and cluster resource saturation.
  • Proactive alerts preventing batch job starvation caused by misconfigured resource flavor limits.
  • Standardized audit manifests containing exact admitted workload totals and execution timestamps.
  • Zero-overhead deployment compatible with Ray, Kubeflow, JobSet, and standard Kubernetes Batch Jobs.

Who it's for

  • AI platform engineers and MLOps teams managing high-cost GPU cluster scheduling with Kueue.
  • Platform SREs maintaining multi-tenant Kubernetes batch computing clusters and job queues.
  • Data platform architects enforcing departmental compute quotas and cross-queue borrowing rules.
  • Enterprise infrastructure leads optimizing cloud GPU/CPU cluster utilization and cost efficiency.

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 batch scheduler surveillance as versioned code in Git repositories.
  • Comprehensive Audit History: Preserves historical batch queuing telemetry in searchable Kestra execution logs.

Use cases

  • GPU Starvation Detection: Alerts ML platform engineers when pending LLM fine-tuning jobs exceed queue quotas.
  • Borrowing Limit Enforcement: Detects when secondary queues monopolize shared compute resource cohorts.
  • Admission Deadlock Prevention: Identifies conflicting admission checks that block gang-scheduled workloads.

Inputs

Name Type Default Description
kueue_metrics_url STRING http://kueue-controller-manager-metrics-service.kueue-system.svc.cluster.local:8080 Internal HTTP URL exposing Prometheus metrics for Kueue.
cluster_queue_name STRING batch-ai-training-queue Name of the target Kueue ClusterQueue resource.
max_pending_workloads_threshold INT 50 Maximum allowable pending workloads before raising an alert.
max_admission_wait_time_seconds INT 600 Maximum acceptable admission wait time in seconds.
alert_on_quota_reservation_exhaustion BOOL true Toggle whether quota saturation triggers an alert.

Expected outputs

  • {{ outputs.scan_kueue_telemetry.vars.pending_workloads_count }}: Count of pending workloads awaiting admission.
  • {{ outputs.scan_kueue_telemetry.vars.admission_wait_duration_seconds }}: Maximum observed queuing wait duration.
  • {{ outputs.scan_kueue_telemetry.vars.quota_reservation_percent }}: Percentage of cluster queue quota currently reserved.
  • {{ outputs.scan_kueue_telemetry.vars.is_alerting }}: Boolean flag indicating if batch scheduling SLA is breached.
  • {{ outputs.scan_kueue_telemetry.vars.audit_timestamp }}: ISO-8601 UTC timestamp of the batch audit run.

Prerequisites

  • Kubernetes Kueue 0.6+ deployed with Prometheus metrics enabled on port 8080.
  • Network connectivity from the Kestra worker to the Kueue controller metrics service.
  • Configured Slack incoming webhook URL with permissions to post in batch alert channels.

Secrets

  • SLACK_WEBHOOK_URL: Secure webhook URL for routing batch alerts to the Batch SRE Slack channel.

Quick start

  1. Verify that Kueue controller manager exposes Prometheus metrics on HTTP port 8080.
  2. Add the SLACK_WEBHOOK_URL secret within your Kestra namespace settings.
  3. Specify your cluster queue identifier in cluster_queue_name.
  4. Run a manual flow execution via the Kestra UI to validate metric ingestion.
  5. Enable the periodic_kueue_audit schedule trigger to establish automated monitoring.

Common pitfalls and troubleshooting

  • ResourceFlavor Mismatch: Workloads request resources that do not match any available ResourceFlavor in the queue.
  • Cohort Borrowing Limits: If cohorts lack borrowing limits, high-priority queues can be starved by background jobs.
  • Missing Workload PriorityClass: Ensure workloads specify appropriate PriorityClasses for fair preemption.
  • Controller Memory Leaks: In clusters with thousands of finished jobs, verify Kueue garbage collects Workload CRDs.

How to extend

  • Automated Queue Quota Elasticity: Dynamically expand ClusterQueue nominal quotas via Kestra during peak training hours.
  • PagerDuty Escalation: Escalate to on-call MLOps leads if GPU training jobs remain pending for over 60 minutes.
  • Cross-Queue Utilization Heatmap: Aggregate queuing wait times across all departmental queues for cost reporting.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.