This prompt is for platform engineers, DevOps teams, and internal developer platform builders who need to translate natural language routing requirements into valid, deployable Kubernetes Ingress or Gateway API HTTPRoute YAML. The job-to-be-done is reducing the cognitive load and syntax errors that come from hand-writing routing manifests—correct path matching, backend service references, TLS configuration, and rewrite rules. The ideal user already understands their cluster's networking model and needs a reliable scaffold that survives kubectl apply --dry-run=server or a Gateway API controller's validation webhook on the first pass, not a tutorial on how Ingress works.
Prompt
Ingress and Gateway API Route Prompt Template

When to Use This Prompt
Understand the job-to-be-done, the ideal user, and the hard boundaries for this Ingress and Gateway API route generation prompt.
Use this prompt when you are working inside a GitOps pipeline, an internal developer platform, or an infrastructure automation workflow where YAML correctness is a hard gate. It is appropriate when you can provide concrete inputs: a list of backend services with their names and ports, the desired hostnames, TLS secret names if you are terminating TLS, and any path rewriting or header modification rules. The prompt template is designed to be wired into a larger system that can supply these variables programmatically, such as a service catalog or a deployment orchestrator. It is not a replacement for understanding your specific Gateway API controller's implementation—some controllers support a subset of filters or have specific TLS passthrough behaviors that the prompt cannot know unless you include those constraints explicitly.
Do not use this prompt as a substitute for a security review of your routing policies. It will generate technically valid YAML, but it cannot reason about whether exposing a particular backend via a specific path creates an unintended authorization bypass or violates your network segmentation policy. Similarly, do not use it to generate routes for controllers you have not validated against—if your cluster runs an older version of a Gateway API controller that does not support HTTPRouteMatch with regular expressions, the generated YAML will fail at runtime even if it passes schema validation. The next step after reading this section is to review the prompt template, identify which variables your system must supply, and build the validation harness described in the implementation section before putting this into production.
Use Case Fit
Where this prompt works and where it does not. Understand the operational boundaries before wiring it into a production pipeline.
Good Fit: Standard Gateway API Resources
Use when: generating HTTPRoute, TLSRoute, or TCPRoute YAML for Gateway API v1.0+ with standard path matching, header-based routing, and backend service references. The prompt excels at producing spec-compliant manifests that pass gwctl or kubectl apply --dry-run=server validation. Guardrail: Pin the Gateway API version in the prompt instructions to prevent generation against deprecated or alpha CRD fields.
Bad Fit: Proprietary Ingress Controllers
Avoid when: generating YAML for vendor-specific Ingress resources with non-standard annotations (NGINX snippet configs, Traefik middleware CRDs, or AWS ALB custom actions). The prompt lacks the training density to reliably produce correct annotation syntax for every controller variant. Guardrail: Route these requests to a dedicated controller-specific prompt template or require human review of all annotation blocks before apply.
Required Inputs: Service Names and Ports
Risk: The model will hallucinate backend service names or port numbers if not explicitly provided, producing YAML that references non-existent Kubernetes Services. Guardrail: Require a validated input schema with [SERVICE_NAME], [SERVICE_PORT], and [NAMESPACE] fields. Reject generation if any backend reference is missing. Validate generated Service names against a live cluster or a provided service registry before deployment.
Operational Risk: Host Collision
Risk: The prompt may generate a route with a hostname that already exists in another HTTPRoute, creating a silent conflict where Gateway API merges routes unpredictably or rejects the newer resource. Guardrail: Implement a pre-apply check that queries the target cluster for existing HTTPRoutes with overlapping hostnames. Flag conflicts for human resolution before the manifest is applied.
Operational Risk: TLS Certificate Mismatch
Risk: The generated route may reference a TLS certificate Secret that does not exist in the specified namespace, causing the Gateway to fail to serve HTTPS traffic. Guardrail: Add a validation step that verifies the referenced certificateRef Secret exists in the target namespace. If the Secret is managed by cert-manager, confirm the corresponding Certificate resource is in a Ready state.
Operational Risk: Rewrite Rule Breakage
Risk: URL rewrite or redirect filters can produce infinite loops or break client-side routing if the path prefix replacement is misconfigured. The model may generate syntactically valid but logically broken rewrite rules. Guardrail: Include a test harness that sends synthetic requests against the generated route definition and asserts the expected rewritten path and response code. Flag any rewrite that results in a redirect loop or a 404 from the backend.
Copy-Ready Prompt Template
A production-ready prompt template that generates valid Gateway API HTTPRoute YAML from structured routing specifications.
This prompt template is designed for platform engineers who need to generate Kubernetes Gateway API HTTPRoute manifests from routing specifications. It accepts structured inputs for hostnames, path rules, backend services, TLS configuration, and rewrite rules, then produces parseable YAML that conforms to the Gateway API schema. The template enforces strict output formatting—only valid YAML inside a fenced code block with no commentary—making it safe to pipe directly into kubectl apply or GitOps pipelines without manual cleanup.
textGenerate a Kubernetes Gateway API HTTPRoute YAML manifest from the following routing specification. Output only valid YAML inside a yaml fenced code block. Do not include commentary, explanations, or markdown outside the code block. The YAML must parse without errors against the Gateway API [API_VERSION] schema. Use correct indentation with 2-space increments. Include all required fields: apiVersion, kind, metadata, spec. Follow these constraints: [CONSTRAINTS]. Hostnames: [HOSTNAMES]. Path rules: [PATH_RULES]. Backend services: [BACKEND_SERVICES]. TLS configuration: [TLS_CONFIG]. Rewrite and filter rules: [REWRITE_RULES]. Namespace: [NAMESPACE]. Route name prefix: [ROUTE_NAME_PREFIX]. Additional labels: [LABELS].
Adapt this template by replacing each square-bracket placeholder with concrete values from your routing specification. For [API_VERSION], use the exact Gateway API version your cluster supports (e.g., gateway.networking.k8s.io/v1). The [CONSTRAINTS] field should include explicit rules like 'do not use regular expression path matching' or 'all backends must reference Services in the same namespace.' For [PATH_RULES], provide structured path definitions with match types (Prefix, Exact, PathPrefix) and corresponding backend references. The [BACKEND_SERVICES] placeholder expects service names, ports, and optional weight values for traffic splitting. [TLS_CONFIG] should specify certificate references, hostname verification mode, or passthrough settings. [REWRITE_RULES] covers URL rewrites, header modifications, and request/response filtering. Always validate the generated YAML with kubectl apply --dry-run=server or a schema validation tool like kubeconform before deploying. For production use, add a post-generation validation step that checks for hostname collisions with existing routes, verifies backend service existence, and confirms TLS certificate availability in the target namespace.
Prompt Variables
Placeholders required by the Ingress and Gateway API Route prompt template. Replace each placeholder with concrete values before sending the prompt. Validation notes describe what the application layer should check before and after generation.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[ROUTE_SPECIFICATION] | Natural language description of the desired routing behavior, including path matching, backend services, TLS settings, and rewrite rules | Route traffic for api.example.com/v2/* to the inventory-service backend on port 8080 with TLS termination and a prefix rewrite to / | Check for non-empty string. Must contain at least one backend service reference and one path matching rule description. Reject if only hostname provided without path or backend. |
[GATEWAY_API_VERSION] | Target Gateway API version for schema compliance | v1 | Must match a valid Gateway API version string: v1, v1beta1, v1alpha2. Validate against supported versions list before prompt assembly. Default to v1 if not specified. |
[INGRESS_CLASS] | Ingress controller or Gateway class name to target | nginx | Must be a non-empty string matching a known ingress class or gateway class in the target cluster. Validate against allowed class names list. Reject unknown or empty values. |
[TLS_CERTIFICATE_SECRET] | Name of the Kubernetes TLS secret for certificate reference | api-example-tls | Must follow Kubernetes secret naming conventions: lowercase RFC 1123 subdomain, max 253 characters. Check for existence in target namespace if pre-deployment validation is available. |
[BACKEND_SERVICES] | List of backend service names, ports, and optional weights for traffic splitting | [{"name": "inventory-v1", "port": 8080, "weight": 80}, {"name": "inventory-v2", "port": 8080, "weight": 20}] | Must be a valid JSON array. Each entry requires name (string), port (integer 1-65535), and optional weight (integer 0-100). Sum of weights must equal 100 if canary routing is specified. Validate service names against cluster if available. |
[NAMESPACE] | Target Kubernetes namespace for the route resource | production | Must be a valid Kubernetes namespace name: lowercase RFC 1123 label, max 63 characters. Check namespace exists in target cluster if pre-deployment validation is available. Reject empty or default namespace if policy requires explicit namespaces. |
[HOSTNAME] | Primary hostname for the route rule | api.example.com | Must be a valid DNS hostname: max 253 characters, valid characters per RFC 1123. Check for wildcard prefix only at start of hostname. Validate against allowed hostname suffix list if domain ownership enforcement is required. Reject IP addresses. |
[PATH_MATCH_TYPE] | Path matching strategy for HTTPRoute | Prefix | Must be one of: Exact, PathPrefix, RegularExpression. If RegularExpression, validate regex syntax before prompt assembly. Reject ImplementationSpecific without explicit controller documentation reference. |
Implementation Harness Notes
Wire this prompt into an application with YAML extraction, strict parsing, dry-run validation, retry logic, and human approval gates before any Kubernetes API interaction.
The prompt template produces a fenced YAML code block inside a model response. Your application must extract that block reliably before the YAML ever touches a Kubernetes API. Build an extraction function that locates the first ```yaml fenced block in the model output, strips the fences, and passes the raw string to a strict YAML parser such as PyYAML (Python) or js-yaml (Node.js). Do not attempt to parse the YAML with regex or manual string splitting—strict parsers catch indentation errors, duplicate keys, and invalid type coercions that regex-based approaches miss. If the model response contains no fenced YAML block, treat it as a generation failure and do not proceed to validation.
After parsing succeeds, run the resulting manifest through a dry-run validator before any apply operation. Use kubectl apply --dry-run=server against the target cluster or a schema validator like kubeconform with the appropriate Gateway API CRD schemas. For Gateway API HTTPRoute resources, validate against the installed CRD version in your cluster (v1, v1beta1, or v1alpha2) to catch field name changes and removed API versions. If validation fails, capture the full error message and feed it back into a retry prompt that includes the original specification, the previously generated YAML, and the specific validation error. Structure the retry prompt to instruct the model to fix only the reported error while preserving the rest of the manifest. Set a maximum of 3 retry attempts. After the third failure, escalate to a platform engineer with the full generation history, all validation errors, and the original specification for manual review.
Log every generation attempt with structured metadata: the input variables passed to the prompt template, the raw model output, the extracted YAML, the validation result (pass/fail), any error messages, and the retry count. Store these logs in your observability platform with a correlation ID that ties together all attempts for a single generation request. For production systems, require human approval on any generated route that exposes a new backend service or modifies TLS configuration. Implement this as a review queue where generated manifests are held in a pending state until a platform engineer approves them. Store approved manifests in version control with the prompt variables and approval metadata as commit metadata, creating an audit trail that links every deployed route back to its generation request.
Implement host collision detection before applying generated HTTPRoute resources. Query the target namespace for existing HTTPRoute objects and extract their hostnames from the spec.hostnames field. Compare the proposed hostnames against the existing set. If a collision is detected, either reject the generation and notify the requester, or route to a human approval step that explicitly acknowledges the shared hostname configuration. This prevents accidental route conflicts where a newly generated manifest would silently override or conflict with existing traffic routing. For Gateway API resources that reference TLS certificates via spec.tls.certificateRefs, verify that the referenced Secret exists in the target namespace before applying the route, and flag missing Secrets as a pre-validation failure that does not count against the retry budget.
Expected Output Contract
Validation rules for the generated Ingress or Gateway API HTTPRoute YAML. Use this contract to build automated post-generation checks before the manifest enters a GitOps pipeline or kubectl apply.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
apiVersion | string (e.g., networking.k8s.io/v1, gateway.networking.k8s.io/v1) | Must match a supported Kubernetes or Gateway API version. Parse and check against an allowlist of known stable API versions. | |
kind | string (Ingress, HTTPRoute) | Must be exactly 'Ingress' or 'HTTPRoute'. Case-sensitive enum check. Reject any other resource kind. | |
metadata.name | string (RFC 1123 DNS subdomain) | Must be non-empty, <= 253 characters, lowercase alphanumeric, '-' or '.'. Validate with DNS-1123 regex. Reject if missing. | |
spec.rules[].host | string (FQDN or wildcard) | If present, must be a valid hostname. Check for collision with existing hosts in the same namespace. Wildcard only in first label. | |
spec.rules[].http.paths[].pathType | string (Prefix, Exact, ImplementationSpecific) | Must be one of the three allowed values. Enum check. Reject if missing or unrecognized. | |
spec.rules[].http.paths[].backend.service.name | string (RFC 1123 service name) | Must be non-empty. Validate service exists in the same namespace via a lookup or dry-run. Reject if service reference is missing. | |
spec.rules[].http.paths[].backend.service.port.number | integer (1-65535) | Must be a valid port number. Check against the target service's defined ports. Reject if port is not exposed by the referenced service. | |
spec.tls[].hosts[] | array of strings | If TLS block present, hosts array must be non-empty. Each host must match a host in spec.rules. Cross-reference check required. |
Common Failure Modes
When generating Ingress and Gateway API route YAML, these failures surface most often in production. Each card explains the symptom, root cause, and a concrete guardrail to add before the manifest reaches a cluster.
Host Collision and Silent Route Shadowing
What to watch: The model generates a route with a hostname already claimed by another Ingress or HTTPRoute in the cluster. The new route silently shadows or conflicts with existing traffic without warning. Guardrail: Include a pre-flight instruction in the prompt to check for host uniqueness and append a [HOST_COLLISION_CHECK] placeholder that forces the operator to verify before apply.
Path Matching Precedence Errors
What to watch: The model orders prefix and exact path matches incorrectly, causing a catch-all / rule to consume traffic meant for a more specific /api/v2 route. Gateway API path match types (Exact, PathPrefix) are misapplied. Guardrail: Add a constraint in the prompt requiring exact matches to be listed before prefix matches and validate the generated YAML against the Gateway API v1 schema with a strict path ordering lint rule.
Backend Service Reference Drift
What to watch: The model hallucinates a backend service name or port number that does not exist in the namespace, or references a service in a namespace the route cannot reach. The route applies but returns 503 errors. Guardrail: Require the prompt to accept a [AVAILABLE_SERVICES] input block and instruct the model to only reference services from that list. Add a post-generation kubectl get svc dry-run validation step.
TLS Certificate and Secret Mismatch
What to watch: The model generates a TLS section referencing a Kubernetes Secret that does not exist, has the wrong type, or contains a certificate not valid for the specified host. Guardrail: Instruct the prompt to emit a [TLS_SECRET_REQUIRED] comment next to every TLS block, listing the expected secret name, type, and host. Pair with cert-manager annotation defaults to reduce manual secret creation errors.
Rewrite Rule Target Corruption
What to watch: The model generates a URL rewrite or header modification filter with an incorrect target path, stripping necessary prefixes or injecting malformed replacement strings that break backend routing. Guardrail: Add a [REWRITE_VERIFICATION] section to the prompt output that shows a before/after URL example for every rewrite rule. Validate with a regex check that the rewritten path matches the backend's expected route pattern.
API Version and CRD Schema Incompatibility
What to watch: The model outputs a manifest using networking.k8s.io/v1beta1 or an outdated Gateway API version that has been removed or changed in the target cluster. The manifest fails to apply with a schema validation error. Guardrail: Pin the prompt to a specific API version (e.g., gateway.networking.k8s.io/v1) and include a [API_VERSION_CHECK] instruction to validate against the cluster's available CRD versions before generation.
Evaluation Rubric
Use this rubric to test the quality of generated Ingress or Gateway API route YAML before integrating it into a deployment pipeline. Each criterion targets a specific failure mode common to AI-generated infrastructure manifests.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Schema Validation | Output passes strict validation against the target Gateway API version schema (e.g., gateway.networking.k8s.io/v1) without errors. | kubectl apply --dry-run=server or kubeconform returns schema violation errors. | Automated: Run kubeconform -schema-location against the generated YAML string. Assert exit code 0. |
Path Matching Correctness | All pathType values are valid (Exact, PathPrefix, RegularExpression) and match the user's routing intent described in [ROUTING_RULES]. | PathType is ImplementationSpecific or RegularExpression used without explicit user request; prefix overlaps cause ambiguous routing. | Automated: Parse YAML, extract all spec.rules[].matches[].path. Assert pathType is in allowed set and path value matches [ROUTING_RULES] pattern. |
Backend Service References | All backendRefs reference valid Service names and ports that exist in the provided [NAMESPACE] and [SERVICE_MAP]. | A backendRef points to a Service name not listed in [SERVICE_MAP] or uses a port number not defined for that Service. | Automated: Extract all backendRefs. Cross-reference name and port against [SERVICE_MAP]. Assert all references are resolved. |
TLS Configuration Integrity | If [TLS_CONFIG] is provided, the output includes a valid tls section with correct certificateRefs, mode (Terminate/Passthrough), and hostname alignment. | tls section is missing when [TLS_CONFIG] is specified; mode is Terminate but no certificateRefs are provided; hostnames in tls don't match listener hostnames. | Automated: If [TLS_CONFIG] is not null, assert tls section exists. Parse mode and certificateRefs. Assert hostname intersection between listeners and tls section. |
Host Collision Avoidance | Generated hostnames do not conflict with existing routes in [EXISTING_HOSTNAMES]. No duplicate exact host matches across listeners. | A generated hostname exactly matches an entry in [EXISTING_HOSTNAMES] without explicit user intent to merge or override. | Automated: Extract all spec.listeners[].hostname values. Assert no value is present in [EXISTING_HOSTNAMES] unless [ALLOW_OVERRIDE] is true. |
Rewrite and Filter Rule Validity | Any URL rewrite or request header filter rules use correct API structure (e.g., filters[].type, filters[].urlRewrite) and valid substitution patterns. | filters section contains an unrecognized type string; urlRewrite specifies both hostname and path in a way that creates an invalid redirect loop. | Automated: Parse filters array. Assert all type values are from the allowed set (RequestHeaderModifier, URLRewrite, RequestRedirect). Validate urlRewrite structure against Gateway API spec. |
Indentation and YAML Syntax | Output is parseable YAML with consistent indentation (2-space standard), no trailing whitespace, and no tab characters. | YAML parser throws a syntax error; inconsistent indentation causes incorrect nesting of spec fields. | Automated: Parse with a strict YAML parser (e.g., Python ruamel.yaml or yq). Assert no parse exceptions. Re-serialize and compare structural equality. |
Resource Naming and Label Conventions | Generated metadata.name and metadata.labels follow [NAMING_CONVENTION] and include required labels from [REQUIRED_LABELS]. | metadata.name exceeds 253 characters; required labels from [REQUIRED_LABELS] are missing; label values violate syntax rules (e.g., invalid characters). | Automated: Assert metadata.name length <= 253 and matches [NAMING_CONVENTION] regex. Assert all keys from [REQUIRED_LABELS] exist in metadata.labels with valid values. |
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
Add strict schema validation against the Gateway API CRD version in use. Include retry logic with validation feedback loops. Wire in kubectl dry-run or kubeconform as a post-generation check. Add structured logging for each generation attempt.
yaml# Add to prompt constraints [CONSTRAINTS] - Validate against gateway.networking.k8s.io/[API_VERSION] - All backendRefs must reference Services in namespace [NAMESPACE] - TLS configuration must reference an existing Secret in [NAMESPACE] - Hostnames must not collide with existing routes: [EXISTING_HOSTS] - Rewrite rules must specify both hostname and path rewrites when used together - Include retry logic: if validation fails, regenerate with error context
Watch for
- Silent format drift across model versions
- Missing namespace qualification on backend references
- Host collision with existing routes
- Rewrite filter ordering issues
- TLS section present but referencing non-existent Secrets

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