This prompt is designed for platform engineers and SRE teams who need to diagnose and resolve pod scheduling failures in Kubernetes clusters. The core job-to-be-done is to take a pending pod's specification and the cluster's current node conditions, then propose a corrected set of scheduling rules—such as node affinity, tolerations, or topology spread constraints—that will allow the pod to be placed. It is not a general-purpose Kubernetes assistant; it is specifically scoped to failures caused by affinity/anti-affinity mismatches, taint/toleration conflicts, and topology constraint violations.
Prompt
Node Scheduling Failure Recovery Prompt

When to Use This Prompt
Defines the job-to-be-done, the ideal user, required context, and constraints for the Node Scheduling Failure Recovery Prompt.
Use this prompt when you have a concrete scheduling failure event: a pod stuck in Pending status with a clear FailedScheduling event message, and you can provide both the pod manifest and a snapshot of relevant node labels and taints. The prompt requires structured input, including the pod's current scheduling directives and the target node pool's topology. Do not use this prompt for generic pod startup failures, image pull errors, crash loops, or resource exhaustion issues where the scheduler is not the root cause. It is also unsuitable for clusters with custom schedulers that use non-standard plugin logic.
Before invoking this prompt, ensure you have extracted the exact scheduling error from kubectl describe pod and have a sanitized view of node metadata. The output should be treated as a suggested configuration, not an auto-applied fix. Always validate the proposed scheduling rules against your cluster's admission controllers and policy engines (e.g., OPA/Gatekeeper) before applying. For production clusters, route the generated diff through a peer review or a GitOps pull request rather than applying it directly.
Use Case Fit
Where the Node Scheduling Failure Recovery Prompt works, where it fails, and the operational preconditions required before wiring it into a production harness.
Good Fit: Constraint Solvability
Use when: The pending pod has a clear set of node selectors, affinities, taints, or topology constraints that can be satisfied by at least one node in the cluster. The prompt excels at reading the pod spec and node list to propose corrected rules when the current configuration is unsatisfiable. Guardrail: Always provide the full pod spec and a representative sample of node conditions—not just the error message—so the model can reason about alternatives.
Bad Fit: Resource Exhaustion
Avoid when: The scheduling failure is caused by genuine resource exhaustion—no nodes have sufficient CPU, memory, or GPU to run the pod regardless of constraint tuning. The prompt cannot create capacity. Guardrail: Pre-check cluster allocatable resources before invoking the recovery prompt. If total pending requests exceed cluster capacity, escalate to cluster autoscaling or capacity planning rather than retrying constraint rewrites.
Required Inputs
Required: The pending pod's full spec (affinity, tolerations, nodeSelector, topologySpreadConstraints), the scheduling error message from the event log, and a list of candidate nodes with their labels and taints. Guardrail: Without node conditions, the model cannot verify whether its proposed constraint changes are satisfiable. Build a pre-fetch step in the harness that runs kubectl describe nodes for the relevant node group before calling the prompt.
Operational Risk: Anti-Affinity Conflicts
Risk: The model proposes a scheduling rule that satisfies the immediate pod but violates anti-affinity rules with other workloads, creating a cascading placement problem. Guardrail: After generating corrected scheduling rules, run a dry-run simulation against the full workload set. Check that the proposed changes do not force existing pods into Pending state. Log any conflicts for human review before applying.
Operational Risk: Taint Misinterpretation
Risk: The model misreads a taint effect (e.g., treating NoExecute as NoSchedule) and proposes a toleration that does not actually permit scheduling. Guardrail: Validate every generated toleration against the target node's actual taint set. The harness must confirm that the toleration key, operator, value, and effect exactly match or exceed the taint before applying the change.
When to Skip the Prompt and Escalate
Avoid when: The scheduling failure involves custom scheduler plugins, dynamic admission controllers, or non-standard topology keys that the model has no context for. Guardrail: If the error message references an unknown plugin or the node conditions include custom extended resources without documentation, escalate to a human operator with the full audit log. Do not let the model guess at proprietary scheduling logic.
Copy-Ready Prompt Template
A reusable prompt template for diagnosing and correcting Kubernetes pod scheduling failures caused by affinity, taint, or topology constraints.
This prompt template is designed to be wired into an automated recovery harness. It receives a pending pod's specification and the current state of candidate nodes, then produces a corrected scheduling configuration. The output is structured JSON, making it suitable for direct consumption by a control loop or a human operator reviewing a suggested fix. The template uses square-bracket placeholders for all dynamic inputs, ensuring it can be adapted to different clusters and failure contexts without modification.
textYou are an expert Kubernetes scheduler debugger. Your task is to analyze a pod scheduling failure and propose a corrected pod specification or node configuration that will allow the pod to be scheduled. ## INPUT - Pending Pod Specification (YAML): [PENDING_POD_YAML] - Candidate Node Conditions (JSON list of node names, taints, labels, and allocatable resources): [NODE_CONDITIONS_JSON] - Scheduler Error Message (plain text from `kubectl describe pod`): [SCHEDULER_ERROR_MESSAGE] ## CONSTRAINTS - Do not change the pod's container images, command, or core application logic. - Prefer the least invasive fix: adjust pod scheduling directives before suggesting node-level changes. - If a node-level change is the only option, explicitly flag it as a cluster-admin action. - Ensure the proposed fix does not violate any explicit anti-affinity rules already in the pod spec. - If the failure is due to a resource shortage (CPU, memory), suggest a specific, minimal reduction in requests that aligns with the node's allocatable capacity. ## OUTPUT_SCHEMA Respond with a single JSON object conforming to this structure: { "diagnosis": "A concise, one-sentence summary of the root cause.", "proposed_fix_type": "One of: 'pod_spec_patch', 'node_label_patch', 'node_taint_patch', 'resource_adjustment', 'human_escalation'.", "corrected_pod_spec_yaml": "The full, corrected pod YAML if fix_type is 'pod_spec_patch' or 'resource_adjustment'; otherwise, null.", "node_patch_commands": ["A list of kubectl patch or taint commands if fix_type is 'node_label_patch' or 'node_taint_patch'; otherwise, an empty list."], "explanation": "A step-by-step explanation of why the fix resolves the specific error, referencing the constraints that were violated.", "risk_assessment": "One of: 'low', 'medium', 'high'. 'high' if the fix could affect other workloads on the node." } ## EXAMPLES [FEW_SHOT_EXAMPLES] ## RISK_LEVEL [RISK_LEVEL]
To adapt this template, replace the placeholders with data from your cluster's API. The [PENDING_POD_YAML] should be the exact output of kubectl get pod <name> -o yaml. The [NODE_CONDITIONS_JSON] is a critical input; construct it by querying nodes with kubectl get nodes -o json and filtering for the fields relevant to scheduling: spec.taints, metadata.labels, and status.allocatable. The [FEW_SHOT_EXAMPLES] placeholder should be populated with 2-3 worked examples of common scheduling failures and their correct fixes to improve model accuracy. For high-risk environments, set [RISK_LEVEL] to high to instruct the model to prefer the human_escalation fix type when node taints must be altered. The next step is to integrate this prompt into a validation harness that checks the proposed YAML against the target cluster's API version schema before applying any changes.
Prompt Variables
Required inputs for the Node Scheduling Failure Recovery Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how the harness should check input quality before incurring model cost.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[PENDING_POD_SPEC] | Full YAML or JSON spec of the pod that failed to schedule, including affinity, tolerations, and nodeSelector fields | apiVersion: v1 kind: Pod spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app: web topologyKey: kubernetes.io/hostname | Parse check: must be valid YAML or JSON. Schema check: must contain spec.affinity, spec.tolerations, or spec.nodeSelector. Reject if empty or missing spec. |
[NODE_CONDITIONS] | JSON array of node objects with their labels, taints, capacity, allocatable resources, and current conditions | [{"name":"node-1","labels":{"zone":"us-east-1a"},"taints":[{"key":"dedicated","effect":"NoSchedule"}],"conditions":[{"type":"MemoryPressure","status":"False"}]}] | Parse check: valid JSON array. Schema check: each node must have name, labels, taints, and conditions fields. Minimum 1 node required. Null allowed if cluster has no nodes. |
[SCHEDULING_ERROR_MESSAGE] | Exact error message from the Kubernetes scheduler event or kubectl describe output | 0/5 nodes are available: 3 node(s) had untolerated taint {dedicated: infra}, 2 node(s) didn't match pod anti-affinity rules. | Parse check: non-empty string. Content check: must contain node count and reason keywords (taint, affinity, selector, resources). Reject if generic timeout message without scheduling detail. |
[TOPOLOGY_CONSTRAINTS] | Cluster topology metadata including zones, regions, and node grouping labels relevant to scheduling | {"zones":["us-east-1a","us-east-1b"],"topologyKeys":["topology.kubernetes.io/zone","kubernetes.io/hostname"]} | Parse check: valid JSON object. Schema check: must include zones or topologyKeys array. Null allowed if topology is not a factor in the failure. |
[RESOURCE_REQUESTS] | The resource requests and limits from the pending pod's containers, extracted separately for clarity | {"containers":[{"name":"app","requests":{"cpu":"500m","memory":"1Gi"},"limits":{"cpu":"2","memory":"4Gi"}}]} | Parse check: valid JSON object. Schema check: must contain containers array with requests map. Reject if requests exceed cluster node capacity maximum. |
[EXISTING_SCHEDULING_POLICIES] | Current PriorityClass, schedulerName, or custom scheduler configuration applied to the namespace or pod | {"schedulerName":"default-scheduler","priorityClassName":"high-priority","preemptionPolicy":"PreemptLowerPriority"} | Parse check: valid JSON object. Null allowed if using default scheduler with no custom policies. Schema check: schedulerName must match a known scheduler in the cluster. |
[NAMESPACE_CONTEXT] | Namespace-level constraints including ResourceQuota, LimitRange, and NetworkPolicy that may block scheduling | {"namespace":"production","resourceQuotas":[{"hard":{"pods":"50"},"used":{"pods":"50"}}],"limitRanges":[{"max":{"cpu":"4"}}]} | Parse check: valid JSON object. Schema check: must include namespace name. Null allowed if no namespace-level constraints exist. Check for quota exhaustion before sending prompt. |
Implementation Harness Notes
How to wire the Node Scheduling Failure Recovery Prompt into an operational debugging workflow with validation, retries, and escalation.
This prompt is designed to be called within an automated triage pipeline, not as a standalone chat interaction. The harness should trigger when a pod remains in a Pending state beyond a configurable threshold (e.g., 5 minutes) and the scheduling event reason matches known failure classes (Unschedulable, FailedScheduling). The input assembly step must collect the full pod spec (kubectl get pod <name> -o yaml), the node list with taints and conditions (kubectl get nodes -o json), and the specific scheduling error message from kubectl describe pod. This context is packed into the [POD_SPEC], [NODE_CONDITIONS], and [SCHEDULING_ERROR] placeholders before the prompt is rendered.
After the model returns a proposed correction, the harness must not apply it automatically. First, validate the output structure: confirm the corrected_scheduling_rules block contains valid nodeSelectorTerms, affinity, or tolerations fields. Second, run a satisfiability check by using a dry-run scheduler or a lightweight constraint solver that tests whether at least one existing node matches the proposed rules. If no node satisfies the corrected constraints, increment a retry counter and re-invoke the prompt with the unsatisfiability reason appended to the error context. Implement a hard retry budget of 3 attempts; after the budget is exhausted, escalate to a human operator via your incident management system with the full chain of attempts and the original pod state.
Model choice matters here. Use a model with strong structured-output capabilities and a context window large enough to hold multiple node definitions. For production, prefer a model that supports JSON mode or function calling so you can enforce the output schema at the API level rather than relying solely on prompt instructions. Log every invocation—input context, raw output, validation result, and retry count—to your observability platform. This trace is essential for debugging prompt drift, model refusals, or unexpected constraint suggestions. Never apply the corrected scheduling rules directly to a running cluster without human approval unless the pod is in a pre-production namespace and the change is limited to soft preferences (preferredDuringScheduling) rather than hard requirements.
Expected Output Contract
Validate the structure and content of the model's recovery response before applying any suggested scheduling changes.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
recovery_summary | String (1-3 sentences) | Must describe the root cause of the scheduling failure by referencing specific node conditions, taints, or affinity rules from the input. | |
corrected_pod_spec | Valid Kubernetes PodSpec YAML block | Must be parseable by a YAML validator. The spec must differ from the original only in scheduling-related fields (affinity, tolerations, nodeSelector, topologySpreadConstraints). | |
change_explanation | Array of objects | Each object must contain 'field_path' (string), 'original_value' (string), 'new_value' (string), and 'rationale' (string). The 'field_path' must be a valid JSONPath to the changed field. | |
constraint_satisfiability_check | Boolean | Must be true. A post-generation check must confirm that no node in the provided node list simultaneously satisfies conflicting hard anti-affinity rules in the corrected spec. | |
anti_affinity_conflict_flag | Boolean | Must be false. If true, the harness must reject the output and retry. A separate validation pass must check for conflicting podAntiAffinity terms. | |
suggested_node_name | String or null | If provided, the node name must exist in the input node list and must satisfy all taints, tolerations, and resource requests in the corrected spec. Null is acceptable if no single node is suggested. | |
warnings | Array of strings | If present, each string must describe a non-fatal scheduling risk (e.g., 'Node [NAME] has low available memory'). Must not contain generic or hallucinated node names. |
Common Failure Modes
Node scheduling failures are rarely caused by a single bad line of YAML. They are often the result of conflicting constraints, misunderstood topology, or resource fragmentation. These cards cover the most common failure modes when using AI to recover from scheduling failures and how to guard against them.
Hallucinated Node Labels
Risk: The model invents node labels or topology keys that do not exist in the cluster, producing a corrected pod spec that still cannot schedule. Guardrail: Always provide the actual kubectl get nodes --show-labels output in the prompt context and validate any label referenced in the output against the live cluster before applying.
Anti-Affinity Deadlock
Risk: The model proposes podAntiAffinity rules that are so strict they prevent any pod from scheduling, or it fails to detect that the desired replica count exceeds the number of available topology domains. Guardrail: Include the number of available nodes per topology zone in the prompt. Validate that requiredDuringScheduling rules allow at least one feasible placement per replica.
Ignoring Taint-Toleration Mismatch
Risk: The model focuses on affinity rules but overlooks that the target nodes have taints without matching tolerations in the pod spec, or it proposes removing tolerations that are required for other workloads. Guardrail: Always include kubectl describe nodes output showing active taints. The harness must diff the original and proposed tolerations and flag any removal of existing tolerations for human review.
Resource Fragmentation Oversight
Risk: The model proposes a scheduling rule that is technically satisfiable but fails because no single node has enough contiguous CPU or memory to meet the pod's requests. The prompt corrects constraints without addressing the underlying resource shortage. Guardrail: Include kubectl describe nodes resource summaries. The harness should run a dry-run scheduler simulation or kubectl run --dry-run=server before returning the fix as complete.
Over-Correction to Broad Selectors
Risk: To resolve a scheduling failure, the model removes all node affinity rules or replaces specific selectors with a catch-all matchExpressions operator, causing the pod to land on inappropriate nodes and creating a worse operational problem. Guardrail: The prompt must instruct the model to preserve the original scheduling intent. The harness should diff the proposed spec and flag any removal of nodeAffinity or topologySpreadConstraints for explicit approval.
Stale Cluster State
Risk: The model operates on a snapshot of node conditions that is minutes old. Nodes may have become NotReady, cordoned, or had their labels changed between the time the error was captured and the fix is applied. Guardrail: The harness must re-fetch live node state immediately before applying any generated manifest. If the cluster state has changed, the prompt must be re-run with fresh context rather than applying a stale fix.
Evaluation Rubric
Criteria for evaluating the quality and correctness of a Node Scheduling Failure Recovery Prompt before deploying it into a production harness. Each criterion targets a specific failure mode common to scheduling constraint reasoning.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Constraint Satisfiability | Proposed nodeSelector, affinity, or tolerations resolve the scheduling failure without introducing new conflicts. | Output suggests a node label that does not exist or a taint that no node tolerates. | Parse the proposed spec fragment and run |
Anti-Affinity Conflict Avoidance | Corrected rules do not place pods from the same anti-affinity group on the same topology domain. | Output removes or weakens an anti-affinity rule that was required for high availability. | Simulate scheduling of the original and corrected specs with a scheduler simulator. Assert no two pods with conflicting anti-affinity land on the same node. |
Taint and Toleration Matching | Every taint on the target node has a matching toleration in the corrected pod spec. | Output adds a toleration with a mismatched | Extract taints from node description and tolerations from the prompt output. Assert for each taint, there exists a toleration where key matches and effect matches. |
Resource Request Feasibility | Corrected resource requests do not exceed allocatable resources on any candidate node. | Output suggests a node that lacks sufficient CPU, memory, or ephemeral storage. | Compare proposed |
Topology Spread Constraint Validity | Proposed topology spread constraints use valid | Output references a | Validate |
Output Schema Adherence | Output is valid JSON matching the expected schema with | Output is plain text, YAML, or JSON missing required fields. | Parse output with a strict JSON schema validator. Assert |
Explanation Traceability | Explanation references specific error messages, node conditions, or constraint violations from the input. | Explanation is generic, hallucinates error details not present in the input, or cites non-existent nodes. | Check that every claim in the explanation maps to a substring in the input error or node description. Assert no fabricated node names or error codes. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single pending pod spec and node list. Skip formal schema validation and rely on manual review of the output. Accept plain-text scheduling suggestions without requiring structured JSON output.
Prompt modification
- Remove [OUTPUT_SCHEMA] placeholder and ask for a bulleted list of corrections
- Replace [CONSTRAINTS] with a simple instruction: 'Suggest one change at a time'
- Drop eval harness integration; review output manually against
kubectl describe
Watch for
- Suggestions that violate existing anti-affinity rules already in place
- Overly broad taint tolerations that open scheduling to unintended nodes
- Missing topology spread constraint awareness when suggesting node selectors

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us