Generate a Kubernetes Deployment Manifest with Best Practices

Create production-ready Kubernetes deployment manifests with security, autoscaling, networking, and reliability best practices built in.

๐Ÿ“ The Prompt

You are a Kubernetes platform engineer with deep expertise in production-grade deployments. Generate a complete set of Kubernetes manifests to deploy a [APPLICATION_TYPE] application to a [CLUSTER_ENVIRONMENT] cluster. Application Details: - Application name: [APP_NAME] - Container image: [CONTAINER_IMAGE]:[TAG] - Exposed port(s): [PORTS] - Expected resource usage: [RESOURCE_PROFILE] (e.g., lightweight, moderate, high-compute) - Number of replicas for production: [REPLICA_COUNT] - Namespace: [NAMESPACE] Generate the following Kubernetes manifests with production best practices: 1. **Namespace**: Create the namespace with appropriate labels and annotations. 2. **Deployment**: Include: - Resource requests and limits appropriate for the [RESOURCE_PROFILE] - Liveness, readiness, and startup probes with sensible defaults for a [APPLICATION_TYPE] - Anti-affinity rules to spread pods across nodes - Security context (non-root user, read-only root filesystem, drop all capabilities) - Graceful shutdown with terminationGracePeriodSeconds - Rolling update strategy with maxSurge and maxUnavailable 3. **Service**: Create a ClusterIP service exposing the application internally. 4. **Ingress / Gateway API**: Configure ingress with TLS termination for the domain [DOMAIN_NAME], using [INGRESS_CONTROLLER] (e.g., nginx, traefik, AWS ALB). 5. **ConfigMap & Secret**: Provide a ConfigMap for non-sensitive configuration values [CONFIG_VARS] and a Secret (with placeholder values) for sensitive data [SECRET_VARS]. 6. **Horizontal Pod Autoscaler**: Configure HPA based on CPU and memory utilization with min/max replica bounds. 7. **PodDisruptionBudget**: Ensure minimum availability during node maintenance. 8. **NetworkPolicy**: Restrict ingress and egress traffic to only what is necessary. Output each manifest as a separate YAML document (separated by ---) with inline comments explaining key decisions. Also provide a summary table listing each resource, its kind, and its purpose.

๐Ÿ’ก Tips for Better Results

Replace the resource profile placeholder with actual observed CPU/memory metrics from your application to get accurate resource requests and limits. Specify your exact ingress controller so the annotations and API versions match your cluster's setup. Review generated NetworkPolicy rules carefully โ€” overly restrictive policies can break service-to-service communication in your cluster.

๐ŸŽฏ Use Cases

Platform engineers and backend developers deploying containerized applications to Kubernetes who want a comprehensive, security-hardened starting point instead of writing manifests from scratch.

๐Ÿ”— Related Prompts

๐Ÿ’ป Coding beginner

Explain Code Like Im a Beginner

Get any code explained in plain English with line-by-line breakdowns, analogies, and learning suggestions.

๐Ÿ’ป Coding beginner

Debug My Code and Explain the Fix

Get your code debugged with clear explanations of what went wrong and why, plus the corrected version.

๐Ÿ’ป Coding intermediate

Write Unit Tests for My Code

Generate thorough unit tests covering edge cases, error handling, and both positive and negative scenarios.

๐Ÿ’ป Coding intermediate

Convert Code Between Languages

Convert code between any programming languages while maintaining idiomatic patterns and best practices.

๐Ÿ’ป Coding intermediate

Write a REST API Endpoint

Generate production-ready REST API endpoints with validation, error handling, and documentation.

๐Ÿ’ป Coding advanced

Create a GitHub Actions CI/CD Workflow for Automated Testing and Deployment

Generate a complete GitHub Actions CI/CD workflow with build, test, deploy, and notification jobs for your project.