From Dockerfile to GitOps: 12 Battle-Tested AI Prompts for Infrastructure Automation

Introduction

Infrastructure automation is no longer a luxury—it's the backbone of modern software delivery. Yet, even seasoned DevOps engineers spend hours wrestling with YAML syntax, debugging CI pipelines, or optimizing container images. What if you could delegate those repetitive tasks to an AI assistant and focus on architecture and strategy? This collection brings you 12 practical AI prompts designed to accelerate your daily DevOps workflow—from crafting efficient Dockerfiles to implementing GitOps with ArgoCD. Each prompt is copy-paste ready, includes a usage example, and explains the context where it shines. Whether you're a platform engineer or a developer dabbling in infrastructure, these prompts will save you time and reduce errors.

Why AI for DevOps?

AI won't replace your infrastructure, but it can dramatically reduce the cognitive load of writing and maintaining it. According to a 2023 survey by the Cloud Native Computing Foundation (CNCF), 96% of organizations are adopting or evaluating cloud-native technologies (source: cncf.io/reports). The complexity of managing Kubernetes clusters, CI/CD pipelines, and multi-cloud environments is a top challenge. AI prompts act as an on-demand expert, helping you generate boilerplate, debug issues, and even explain unfamiliar concepts.

Getting Started

All prompts below are designed for use with general-purpose LLMs (e.g., ChatGPT, Claude, or ASI Biont). Replace placeholders like [your-image] with your actual values. For best results, provide context: paste relevant logs, files, or describe your environment.

The Prompts

1. Dockerfile Optimization

Purpose: Generate a multi-stage Dockerfile for a specific application stack, with size and security best practices.

Prompt:

You are a Docker expert. Create a multi-stage Dockerfile for a [Python/Node.js/Go] application that uses [package manager, e.g., pip/npm]. Include:
- A builder stage with all build dependencies
- A runtime stage based on [distroless or alpine]
- Non-root user creation
- Healthcheck instructions
- Copy only necessary artifacts
Optimize for minimal image size and security. Explain each step.

Usage Example:

You are a Docker expert. Create a multi-stage Dockerfile for a Python application that uses pip. Include a builder stage with gcc, a runtime stage based on python:3.12-alpine, non-root user, healthcheck, and copy only the virtual environment. Optimize for minimal size. Explain each step.

Why it works: The prompt provides clear constraints (language, base image, security) and demands explanations, turning the AI into a mentor.

2. Kubernetes Manifest Generation

Purpose: Generate a complete Kubernetes deployment manifest (Deployment, Service, ConfigMap) for a microservice.

Prompt:

Generate Kubernetes manifests for a [service-name] microservice. Requirements:
- Deployment with [number] replicas, resource requests/limits, liveness and readiness probes
- Service of type ClusterIP exposing port [port]
- ConfigMap for environment variables
- Use image [image:tag]
- Include labels and selectors
- Follow best practices for high availability (pod anti-affinity, PDB)

Usage Example:

Generate Kubernetes manifests for a user-service microservice. Requirements: 3 replicas, resource requests/limits, liveness and readiness probes (HTTP on /health), Service ClusterIP on port 8080, ConfigMap for DATABASE_URL, image myapp/user-service:v1.2. Include pod anti-affinity and a PodDisruptionBudget.

Why it works: The prompt specifies both functional and non-functional requirements, ensuring a production-ready output.

3. Docker Compose for Local Development

Purpose: Create a docker-compose.yml for a microservice with dependent services (DB, cache, etc.).

Prompt:

Write a docker-compose.yml for local development of a [Node.js/Python] app. Include:
- The app service with volume mount for hot reload
- PostgreSQL [version] with a named volume
- Redis [version]
- Environment variables and healthchecks
- Use version '3.8'

Usage Example:

Write a docker-compose.yml for local development of a Node.js app. Include the app service with volume mount for hot reload, PostgreSQL 15 with a named volume, Redis 7, environment variables, and healthchecks. Use version '3.8'.

Why it works: The prompt covers database, cache, and app services, which is a common local stack.

4. Kubernetes Troubleshooting

Purpose: Diagnose a Kubernetes issue based on error logs.

Prompt:

You are a Kubernetes expert. Given the following error, identify the root cause and provide a step-by-step debugging plan:
[Paste error logs or describe the issue]
Include commands to verify your hypothesis and possible fixes.

Usage Example:

You are a Kubernetes expert. Given the following error, identify the root cause and provide a step-by-step debugging plan: Pod 'my-app-7d9f5d9f6c-abcde' is CrashLoopBackOff. Logs show 'Error: listen EADDRINUSE: address already in use :::8080'. Include commands to verify and possible fixes.

Why it works: The prompt leverages the AI's ability to reason about logs and suggests concrete command-line steps.

5. GitHub Actions CI Pipeline

Purpose: Generate a CI workflow for a project hosted on GitHub.

Prompt:

Create a GitHub Actions workflow for a [language] project. The workflow should:
- Trigger on push and pull requests to [branch]
- Set up [language] environment
- Run [build command]
- Run [test command]
- Upload test artifacts on failure
- Use official actions

Usage Example:

Create a GitHub Actions workflow for a Java Maven project. The workflow should: trigger on push and PR to main, set up JDK 17, run 'mvn clean verify', upload test reports on failure, use actions/checkout and actions/setup-java.

Why it works: The prompt defines triggers, steps, and even artifact handling, producing a ready-to-use workflow.

6. GitLab CI/CD Pipeline

Purpose: Create a multi-stage GitLab CI/CD pipeline with build, test, and deploy stages.

Prompt:

Design a GitLab CI/CD pipeline for a [language] app. Include stages: build, test, deploy. Use [container registry] for the image. Deploy to [Kubernetes or VM] using [specific method]. Include caching and only/except rules.

Usage Example:

Design a GitLab CI/CD pipeline for a Python app. Include stages: build, test, deploy. Use GitLab registry for the image. Deploy to Kubernetes using kubectl. Include caching for pip and only/except rules for main branch.

Why it works: The prompt covers the entire pipeline lifecycle with deployment specifics.

7. ArgoCD Application Manifest

Purpose: Generate an ArgoCD Application manifest for GitOps-based deployment.

Prompt:

Generate an ArgoCD Application manifest for deploying [app-name] from [repo-url] to [namespace] on cluster [cluster-name]. Use syncPolicy with automated sync and self-heal. Include a project reference and destination.

Usage Example:

Generate an ArgoCD Application manifest for deploying 'my-app' from https://github.com/example/my-app.git to 'production' namespace on cluster 'in-cluster'. Use syncPolicy with automated sync and self-heal. Include a project reference and destination.

Why it works: The prompt specifies GitOps best practices (auto-sync, self-heal) and yields a declarative configuration.

8. Terraform Module for Cloud Resources

Purpose: Create a Terraform module for provisioning a cloud resource (e.g., AWS S3 bucket, VPC).

Prompt:

Write a Terraform module for [resource type] on [cloud provider]. The module should:
- Accept variables for [name, region, tags]
- Output relevant attributes
- Include lifecycle rules (e.g., prevent_destroy)
- Use provider version [version]

Usage Example:

Write a Terraform module for an AWS S3 bucket. The module should: accept variables for bucket_name, region (default us-east-1), tags; output bucket_arn; include lifecycle rule with prevent_destroy; use hashicorp/aws provider version 5.0.

Why it works: The prompt defines interface (variables/outputs) and resource specifics.

9. Prometheus Alerting Rules

Purpose: Generate Prometheus alerting rules for common infrastructure scenarios.

Prompt:

Write Prometheus alerting rules for [scenario: e.g., high CPU, disk space, pod down]. Include:
- Alert name, expr, for, labels, annotations
- Use thresholds appropriate for [production/development]
- Add a description with instructions for the on-call engineer

Usage Example:

Write Prometheus alerting rules for high CPU usage (over 80% for 5 minutes), disk space (less than 10% free), and Kubernetes pod down (absent for 1 minute). Include alert names, expressions, for, labels, and annotations with runbook link.

Why it works: The prompt yields alerting rules ready to drop into Prometheus config.

10. Grafana Dashboard JSON

Purpose: Generate a Grafana dashboard JSON for monitoring a specific service.

Prompt:

Create a Grafana dashboard JSON for [service]. Include panels for:
- Request rate (QPS)
- Error rate (5xx)
- Latency (p50, p95, p99)
- CPU/memory usage
Use Prometheus data source with UID [uid]. Provide the full JSON.

Usage Example:

Create a Grafana dashboard JSON for a web service. Include panels for request rate (QPS), error rate (5xx), latency (p50, p95, p99), and CPU/memory usage. Use Prometheus data source with UID 'prometheus'. Provide the full JSON.

Why it works: The prompt specifies metrics and data source, producing a functional dashboard.

11. Helm Chart Generation

Purpose: Generate a Helm chart structure and necessary files for a simple microservice.

Prompt:

Create a Helm chart for [app-name]. Include:
- Chart.yaml with version and appVersion
- values.yaml with sensible defaults (image, replicaCount, service)
- templates/deployment.yaml, service.yaml, ingress.yaml with templating
- Use _helpers.tpl for labels

Usage Example:

Create a Helm chart for 'my-api'. Include Chart.yaml with version 0.1.0, values.yaml with image 'myacr.azurecr.io/my-api:v1' (replicaCount 2), templates/deployment.yaml, service.yaml, ingress.yaml with templating, and _helpers.tpl for common labels.

Why it works: The prompt defines the full chart layout, saving time on boilerplate.

12. Shell Script for Log Management

Purpose: Generate a Bash script to collect and rotate logs from multiple services.

Prompt:

Write a Bash script that:
- Compresses logs older than [days] days in /var/log/myapp*
- Moves them to an archive directory
- Deletes archives older than [months] months
- Sends a summary email or logs to syslog
- Uses logrotate syntax or custom script? Provide both options.

Usage Example:

Write a Bash script that compresses logs older than 7 days in /var/log/myapp*, moves them to /var/log/archive, deletes archives older than 6 months, and logs to syslog. Provide both logrotate config and a custom script.

Why it works: The prompt addresses a real operational need and offers two approaches.

Comparison Table

Prompt Tool Use Case Complexity
Dockerfile Optimization Docker Build efficient images Medium
K8s Manifest Generation Kubernetes Deploy microservices Medium
Compose for Dev Docker Compose Local env Low
K8s Troubleshooting Kubernetes Debugging High
GitHub Actions CI GitHub Actions CI pipeline Medium
GitLab CI/CD GitLab CI Full pipeline High
ArgoCD Application ArgoCD GitOps deployment Medium
Terraform Module Terraform IaC for cloud High
Prometheus Rules Prometheus Alerting Medium
Grafana Dashboard Grafana Monitoring Medium
Helm Chart Helm Package K8s apps Medium
Log Management Bash/logrotate Ops tasks Low

Best Practices for Using AI Prompts in DevOps

  • Always review generated code: AI can hallucinate or produce outdated syntax. Test in a staging environment.
  • Provide context: The more specific you are, the better the output. Include versions, paths, and constraints.
  • Iterate: Treat the first output as a draft. Ask for refinements like 'make it more secure' or 'use best practices'.
  • Combine prompts: Use multiple prompts in sequence (e.g., generate a Dockerfile, then a K8s manifest, then a CI pipeline).
  • Stay up-to-date: Tools evolve. Cross-check with official docs (e.g., Docker, Kubernetes, ArgoCD).

Conclusion

AI prompts are not a magic bullet, but they are a powerful accelerator for DevOps tasks. By using these 12 prompts, you can cut down on boilerplate, avoid common pitfalls, and focus on the challenging parts of infrastructure automation. Start with the ones that match your current bottleneck—maybe it's Dockerfile optimization or writing a CI pipeline. Experiment, customize, and make them your own. As you integrate AI into your workflow, remember: the goal is not to replace your expertise but to amplify it. Happy automating!

← All posts

Comments