devops
Kubernetes Manifest Generation Prompt
Kubernetes manifests have many interacting fields that are easy to misconfigure. This prompt generates four interdependent resources (Deployment, Service, Ingress, HPA) with consistent naming and labels, which is critical for Kubernetes to correctly associate them. The comment requirement makes the manifest self-documenting, which is essential for teams maintaining K8s configurations.
Prompt Template
You are a Kubernetes expert. Generate production-ready Kubernetes manifests for the following workload:
Application name: {{app_name}}
Container image: {{image}}
Replicas: {{replicas}}
Container port: {{port}}
CPU request / limit: {{cpu_request}} / {{cpu_limit}}
Memory request / limit: {{memory_request}} / {{memory_limit}}
Environment variables: {{env_vars}}
Ingress hostname: {{hostname}}
Namespace: {{namespace}}
Generate the following manifests:
1. Deployment — with readiness and liveness probes, and resource limits
2. Service — ClusterIP type
3. Ingress — with TLS termination via cert-manager
4. HorizontalPodAutoscaler — scale between {{replicas}} and {{max_replicas}} at 70% CPU
Include comments explaining key configuration choices, especially probe settings and resource limits.Variables
{{app_name}}Application name (used as label and prefix){{image}}Container image with tag, e.g., "myregistry/myapp:1.2.3"{{replicas}}Minimum/initial replica count{{max_replicas}}Maximum replicas for HPA{{port}}Container port number{{cpu_request}}CPU request, e.g., "100m"{{cpu_limit}}CPU limit, e.g., "500m"{{memory_request}}Memory request, e.g., "128Mi"{{memory_limit}}Memory limit, e.g., "512Mi"{{env_vars}}Environment variable names (not values), e.g., "DATABASE_URL, API_KEY"{{hostname}}Ingress hostname, e.g., "api.example.com"{{namespace}}Kubernetes namespaceExample
Input
app_name: user-api image: registry.example.com/user-api:2.1.0 replicas: 2 max_replicas: 10 port: 8080 cpu_request: 100m cpu_limit: 500m memory_request: 128Mi memory_limit: 512Mi env_vars: DATABASE_URL, REDIS_URL, JWT_SECRET hostname: api.example.com namespace: production
Output
apiVersion: apps/v1
kind: Deployment
metadata:
name: user-api
namespace: production
labels:
app: user-api
spec:
replicas: 2
selector:
matchLabels:
app: user-api
template:
metadata:
labels:
app: user-api
spec:
containers:
- name: user-api
image: registry.example.com/user-api:2.1.0
ports:
- containerPort: 8080
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512MiRelated Tools
FAQ
- How do I inject secrets into the pods?
- Reference Kubernetes Secrets in the env section using valueFrom.secretKeyRef instead of hardcoded values. Add "Use Kubernetes Secrets for all environment variables listed" to the prompt and the AI will generate the Secret manifest and the correct env references.
- Can this generate a Helm chart instead of plain YAML?
- Yes. Replace "Generate the following manifests" with "Generate a Helm chart with values.yaml" and the AI will produce a parameterised chart structure.
- What liveness vs. readiness probe values should I use?
- The AI uses conservative defaults (initialDelaySeconds: 30, periodSeconds: 10). Tune initialDelaySeconds to match your application startup time. The liveness probe should check a lightweight endpoint; the readiness probe should check that the app is ready to serve traffic (e.g., database connection established).