12 Prompts for Kubernetes: From Manifests to Helm Charts

If you've ever spent an hour trying to remember the exact syntax for a Kubernetes Service or Helm template, you're not alone. AI assistants can generate those manifests in seconds — if you know how to prompt them. This collection of 12 prompts covers Pods, Services, Ingress, Helm charts, and more. Each prompt is a practical, copy-pasteable solution you can adapt to real projects.

1. Generate a Pod with Resource Limits

Task: Create a single-pod manifest with CPU and memory requests/limits.
Prompt:

Generate a Kubernetes Pod manifest named 'my-app' with container image nginx:1.25, CPU request 250m, limit 500m, memory request 128Mi, limit 256Mi.

Example result:

apiVersion: v1
kind: Pod
metadata:
  name: my-app
spec:
  containers:
  - name: nginx
    image: nginx:1.25
    resources:
      requests:
        cpu: 250m
        memory: 128Mi
      limits:
        cpu: 500m
        memory: 256Mi

Reference: Pod API specification

2. Create a Multi-Container Pod with a Sidecar

Task: Define a main container and a sidecar that logs to a shared volume.
Prompt:

Write a Pod manifest with two containers: 'web' (nginx) and 'sidecar' (busybox). Both mount an emptyDir volume at /var/log. The sidecar runs a loop that copies access.log to stdout every 5 seconds.

Example result:

apiVersion: v1
kind: Pod
metadata:
  name: web-with-sidecar
spec:
  volumes:
  - name: logs
    emptyDir: {}
  containers:
  - name: web
    image: nginx
    volumeMounts:
    - name: logs
      mountPath: /var/log
  - name: sidecar
    image: busybox
    command: ["sh", "-c", "while true; do cat /var/log/access.log; sleep 5; done"]
    volumeMounts:
    - name: logs
      mountPath: /var/log

3. Create a Service for a Deployment

Task: Given a deployment named 'api', create a ClusterIP Service on port 80 targeting port 8080.
Prompt:

Create a Kubernetes Service manifest named 'api-service' for deployment 'api'. The service should use ClusterIP on port 80 and target port 8080.

Example result:

apiVersion: v1
kind: Service
metadata:
  name: api-service
spec:
  selector:
    app: api
  ports:
  - port: 80
    targetPort: 8080

Reference: Services

4. Generate an Ingress Rule with TLS

Task: Configure an Ingress for 'api.example.com' with TLS using a secret 'my-tls'.
Prompt:

Generate an Ingress manifest for host api.example.com. Route '/' to service 'api-service' port 80. Configure TLS with secret name 'my-tls'.

Example result:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: api-ingress
spec:
  tls:
  - hosts:
    - api.example.com
    secretName: my-tls
  rules:
  - host: api.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: api-service
            port:
              number: 80

Reference: Ingress

5. Debug a CrashLoopBackOff Error

Task: Get diagnostic steps for a pod stuck in CrashLoopBackOff.
Prompt:

I have a pod 'payment-service' in CrashLoopBackOff. Describe step-by-step how to diagnose it using kubectl, including checking logs, events, and resource limits.

Example result:
1. Run kubectl logs payment-service --previous to see the last logs before crash.
2. Run kubectl describe pod payment-service to inspect events and last state.
3. Check if the container exceeds memory limits with kubectl top pod.
4. Verify image pull and config references.

For a detailed guide, see Debug Pods.

6. Generate a Helm Chart Skeleton

Task: Create a basic Helm chart structure with values.yaml and deployment template.
Prompt:

Create a Helm chart named 'my-app' with files: Chart.yaml, values.yaml, templates/deployment.yaml, templates/service.yaml. Include placeholders for image, replicas, and port.

Example result (structure):

my-app/
├── Chart.yaml
├── values.yaml
└── templates/
    ├── deployment.yaml
    └── service.yaml

values.yaml:

replicaCount: 2
image:
  repository: my-app
  tag: latest
service:
  port: 80

Reference: Helm Charts

7. Add Environment-Specific Values to Helm

Task: Extend a Helm chart with values for dev/prod environments.
Prompt:

Add a values-dev.yaml and values-prod.yaml to the my-app chart. Dev should use 1 replica and latest tag; prod should use 5 replicas and a versioned tag.

Example result (values-prod.yaml):

replicaCount: 5
image:
  tag: v1.2.3

Then apply with helm install -f values-prod.yaml my-app ./my-app.

8. Write a Kubernetes NetworkPolicy

Task: Create a policy that allows only ingress from a specific pod label.
Prompt:

Generate a NetworkPolicy that allows ingress to pods with label 'app: api' only from pods with label 'app: ingress'.

Example result:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: api-allow-ingress
spec:
  podSelector:
    matchLabels:
      app: api
  policyTypes:
  - Ingress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: ingress

9. Convert Docker Compose to Kubernetes

Task: Get a K8s manifest from a docker-compose.yml.
Prompt:

Convert the following docker-compose.yml to Kubernetes manifests (Deployment + Service): 
web: image: nginx, ports: 80:80

Example result: A Deployment for nginx and a NodePort Service, plus hints to use tools like Kompose.

10. Create a Horizontal Pod Autoscaler

Task: Define an autoscaler for a deployment based on CPU.
Prompt:

Generate a HorizontalPodAutoscaler manifest for deployment 'api' with min=2, max=10, targetCPUUtilizationPercentage=70.

Example result:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api-autoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70

Reference: Horizontal Pod Autoscaler

11. Generate ConfigMap and Secret

Task: Create a ConfigMap for non-sensitive config and a Secret for DB credentials.
Prompt:

Write a ConfigMap with key APP_ENV=production and a Secret named 'db-secret' with username=admin and password=<base64>.

Example result (Secret):

apiVersion: v1
kind: Secret
metadata:
  name: db-secret
type: Opaque
data:
  username: YWRtaW4=
  password: cGFzcw==

12. Write a Helm Template with Conditional Logic

Task: Create a Deployment template that includes an env variable only in production.
Prompt:

Create a Helm template for a deployment. If .Values.environment is 'production', add an env var DEBUG=false; otherwise add DEBUG=true.

Template snippet:

env:
- name: DEBUG
  value: {{- if eq .Values.environment "production" }} "false" {{- else }} "true" {{- end }}

These prompts will save you hours of YAML hunting. For deeper knowledge, always consult the official Kubernetes docs and Helm docs. Try them in your next deployment — and tune them to your own patterns.

← All posts

Comments