From YAML Spaghetti to Cluster Zen: 12 DevOps Prompts for Kubernetes, Helm, and Monitoring That Actually Work

If you've ever spent three hours debugging a Kubernetes manifest only to find a missing comma in a YAML file, you know the pain. Or maybe you've wrestled with a Helm chart that worked in staging but fell apart in production. As clusters grow and teams scale, the operational overhead can feel overwhelming. But here's the thing: AI assistants, when prompted correctly, can be surprisingly good at cutting through the noise. This isn't about replacing your expertise—it's about augmenting it. In this article, I've curated 12 practical prompts for Kubernetes, Helm, monitoring, and cluster optimization. Each one comes with a real-world example and the kind of nuance that comes from spending too many nights on-call. Let's dive in.

Why Prompts Matter in the DevOps World

Before we get to the prompts, let's address the elephant in the room: why use AI for Kubernetes at all? The answer lies in the sheer complexity of the ecosystem. According to the CNCF Annual Survey 2023, 96% of organizations are using or evaluating Kubernetes in some form. That's a lot of YAML. AI can help you generate boilerplate, analyze logs, and even suggest optimizations—but only if you ask the right questions. A vague prompt like "help me with my cluster" will get you a generic answer. A well-structured prompt with context, constraints, and examples will get you something you can actually use.

The Prompts: From Basic to Advanced

1. Generate a Kubernetes Deployment Manifest

Prompt:

Create a Kubernetes Deployment manifest for a Node.js application named 'myapp' using the image 'myapp:v1.0'. Include 3 replicas, a liveness probe hitting /healthz on port 3000, and resource requests of 256Mi memory and 500m CPU. Set the update strategy to RollingUpdate with maxSurge: 1 and maxUnavailable: 0.

Why it works: It specifies the app, image, replicas, probes, resources, and update strategy—everything needed for a production-ready manifest.

Example output:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: myapp:v1.0
        ports:
        - containerPort: 3000
        livenessProbe:
          httpGet:
            path: /healthz
            port: 3000
        resources:
          requests:
            memory: "256Mi"
            cpu: "500m"

2. Debug a CrashLoopBackOff

Prompt:

My pod 'api-6b7c9d4f8-abcde' is in CrashLoopBackOff. Here's the relevant part of the logs: [paste logs]. The pod restarts every 30 seconds. What could be the cause, and how do I fix it?

Why it works: You're providing real logs and context. The AI can analyze the logs for common issues like OOMKilled, missing env vars, or failing health checks.

Example output: The AI might point out that the logs show "connection refused" to a database, suggesting a misconfigured DATABASE_URL env var. It would then recommend checking the ConfigMap or Secret, and verifying the service DNS.

3. Optimize Resource Requests and Limits

Prompt:

Here's the output of 'kubectl top pods' for the last week: [paste data]. My team wants to reduce costs. Suggest resource requests and limits for each deployment based on this usage.

Why it works: You're giving real data. The AI can suggest requests based on the 80th percentile of usage, and limits based on the 95th percentile, following the Kubernetes best practices.

Example output: For a deployment web, the AI might suggest setting requests to 256Mi and limits to 512Mi, based on observed usage patterns, and note that CPU is consistently underutilized, so reducing CPU requests could improve scheduling.

4. Write a Helm Chart for a Microservice

Prompt:

Create a Helm chart for a microservice called 'orders' with the following requirements: a Deployment, a Service on port 8080, a ConfigMap for environment variables, and a Secret for the database password. The chart should support values for image repository, tag, replicas, and environment-specific overrides.

Why it works: It outlines the components and the customization points, so the AI can generate a proper chart structure.

Example output: The AI would produce a charts/orders/ directory with Chart.yaml, values.yaml, and templates for deployment.yaml, service.yaml, configmap.yaml, and secret.yaml. The values.yaml would have sensible defaults like replicaCount: 2 and image.repository: myregistry/orders.

5. Debug a Helm Upgrade Failure

Prompt:

I ran 'helm upgrade --install myrelease mychart --namespace prod' and got this error: [paste error]. The release is stuck in 'pending-upgrade'. What's wrong and how do I recover?

Why it works: You're providing the exact error. The AI can diagnose common issues like a failed hook, an invalid manifest, or a resource that already exists.

Example output: The AI might identify a missing namespace in a hook, or a duplicate Service. It would suggest helm rollback to the last stable release and then fixing the chart.

6. Set Up Prometheus Monitoring for a Cluster

Prompt:

I need to monitor a Kubernetes cluster with Prometheus. Generate a values.yaml for the prometheus-community/kube-prometheus-stack Helm chart with custom settings for storage (10GB PVC), retention (30d), and alerting via Slack webhook. Also include node exporter and kube-state-metrics.

Why it works: It specifies the chart, key parameters, and integrations.

Example output: The AI would produce a values.yaml with prometheus.prometheusSpec.retention: 30d, prometheus.prometheusSpec.storageSpec.volumeClaimTemplate with 10GB, and alertmanager.config with a Slack receiver.

7. Analyze PromQL Queries for Performance

Prompt:

Here's a PromQL query I'm using to check CPU usage: [paste query]. It's slow and returns inconsistent results. Can you optimize it? Also, explain what each part does.

Why it works: You're giving a specific query and asking for optimization and explanation.

Example output: The AI might suggest using rate(container_cpu_usage_seconds_total[5m]) instead of sum(rate(...)) if you don't need a sum, or adding a topk() to limit results.

8. Create Grafana Dashboards as Code

Prompt:

Generate a Grafana dashboard JSON for the 'grafana' Helm chart that displays: 1) CPU usage by pod, 2) Memory usage by pod, 3) Request latency (using the 'nginx' ingress controller metrics), 4) Error rate (5xx responses). Use the Prometheus data source.

Why it works: It defines the panels and the data source, so the AI can produce a JSON that you can import.

Example output: The AI would generate a JSON file with panels for each metric, using queries like sum(rate(container_cpu_usage_seconds_total[5m])) by (pod).

9. Optimize Cluster Autoscaling with HPA and VPA

Prompt:

I have a cluster with 5 nodes. I want to scale pods automatically based on CPU and memory. Create a HorizontalPodAutoscaler for my 'web' deployment, and a VerticalPodAutoscaler for the 'worker' deployment. Also, suggest Cluster Autoscaler settings for the node group.

Why it works: You're specifying what to scale and for which deployments.

Example output: The AI would provide YAML for HPA targeting 70% CPU utilization, and VPA with updateMode: Auto. For Cluster Autoscaler, it might suggest a minSize: 3, maxSize: 10 and scale-down-utilization-threshold: 0.5.

10. Troubleshoot Network Policies

Prompt:

My application can't connect to a database in the same namespace. I have a NetworkPolicy that should allow traffic on port 5432. Here's the policy: [paste YAML]. What's wrong?

Why it works: You're providing the policy and the symptom.

Example output: The AI might point out that the podSelector is incorrect, or that the policy is missing namespaceSelector for the database pod.

11. Secure a Cluster with RBAC

Prompt:

Create RBAC rules for a CI/CD system that needs to deploy to the 'test' namespace but only view resources in 'prod'. Include a ServiceAccount for the CI, a Role, and a RoleBinding.

Why it works: It specifies the exact permissions and scope.

Example output: The AI would generate a ServiceAccount ci-bot, a Role with verbs get, list, watch, create, update, patch, delete on deployments, services, etc., in test, and a ReadOnly Role for prod.

12. Plan a Migration to a New Ingress Controller

Prompt:

I'm planning to migrate from NGINX Ingress to Traefik. Here's my current setup: [describe ingress resources and annotations]. What are the key differences I need to account for? Provide a migration plan.

Why it works: You're giving context and asking for a plan.

Example output: The AI would list differences like annotation syntax (nginx.ingress.kubernetes.io vs traefik.ingress.kubernetes.io), support for TCP/UDP, and provide a step-by-step migration plan.

Putting It All Together: A Real-World Scenario

Let's imagine you're a platform engineer at a mid-sized startup. You've been tasked with optimizing a cluster that's running 50 microservices. You notice that many pods are over-provisioned, and some are crashing during peak hours. Using prompt #3, you analyze resource usage and adjust requests. Then, using prompt #9, you set up HPA to handle spikes. You also use prompt #7 to create a dashboard that gives you visibility into the new autoscaling behavior. Within a week, you've reduced costs by 20% and eliminated pager alerts.

Conclusion

These prompts aren't magic bullets—they're tools that, when used with your expertise, can make you more efficient. I've found that the key is to be specific and provide context. The more you treat the AI like a junior engineer who needs clear instructions, the better the results. So, next time you're stuck on a tricky Kubernetes problem, try one of these prompts. And remember, the best prompts are the ones you write yourself based on your unique situation. Happy clustering!

← All posts

Comments