Kubernetes Manifests Instructions
Best practices for Kubernetes YAML manifests including labeling conventions, security contexts, pod security, resource management, probes, and validation commands
At a glance
- Kind
- Instruction · Ananke
prompt - Reference
awesome-copilot/kubernetes-manifests·ananke://prompt/awesome-copilot/kubernetes-manifests@1.0.0- Applies to
k8s/**/*.yaml,k8s/**/*.yml,manifests/**/*.yaml,manifests/**/*.yml,deploy/**/*.yaml,deploy/**/*.yml,charts/**/templates/**/*.yaml,charts/**/templates/**/*.yml- Files
- 1 · 4.4 KB
- How it's used
- Instructions apply automatically to files matching their applyTo glob in GitHub Copilot. For Claude Code, reference the file from CLAUDE.md.
Where it fits
- Task
- Provision infrastructureReview security
- Lifecycle phase
- Implementation
- Role
- DevOps / SRE engineerSecurity engineer
- Domain
- Infrastructure and cloudSecurity
- Framework or tool
- Kubernetes
- Platform
- Ananke PlexusGitHub Copilot
- Needs
- Nothing (text only)
Facets suggested from the item's own text and tags, not yet reviewed. Facets say where an item is relevant, not that it will run in your setup. How facets work
Checked by Dex
Verified, not self-reported: dex-trove 0.3.16 installed this item into each layout and checked that the tool can load it. Dex collects no download or usage data.
- GitHub Copilot ✓ loads
Upstream metadata
Self-reported by the item's author; Dex shows it as written.
applyTo | k8s/**/*.yaml,k8s/**/*.yml,manifests/**/*.yaml,manifests/**/*.yml,deploy/**/*.yaml,deploy/**/*.yml,charts/**/templates/**/*.yaml,charts/**/templates/**/*.yml |
|---|
Documentation
View upstream ↗Contents
Your Mission
Create production-ready Kubernetes manifests that prioritize security, reliability, and operational excellence with consistent labeling, proper resource management, and comprehensive health checks.
Labeling Conventions
Required Labels (Kubernetes recommended):
app.kubernetes.io/name: Application nameapp.kubernetes.io/instance: Instance identifierapp.kubernetes.io/version: Versionapp.kubernetes.io/component: Component roleapp.kubernetes.io/part-of: Application groupapp.kubernetes.io/managed-by: Management tool
Additional Labels:
environment: Environment nameteam: Owning teamcost-center: For billing
Useful Annotations:
- Documentation and ownership
- Monitoring:
prometheus.io/scrape,prometheus.io/port,prometheus.io/path - Change tracking: git commit, deployment date
SecurityContext Defaults
Pod-level:
runAsNonRoot: truerunAsUserandrunAsGroup: Specific IDsfsGroup: File system groupseccompProfile.type: RuntimeDefault
Container-level:
allowPrivilegeEscalation: falsereadOnlyRootFilesystem: true(with tmpfs mounts for writable dirs)capabilities.drop: [ALL](add only what’s needed)
Pod Security Standards
Use Pod Security Admission:
- Restricted (recommended for production): Enforces security hardening
- Baseline: Minimal security requirements
- Apply at namespace level
Resource Requests and Limits
Always define:
- Requests: Guaranteed minimum (scheduling)
- Limits: Maximum allowed (prevents exhaustion)
QoS Classes:
- Guaranteed: requests == limits (best for critical apps)
- Burstable: requests < limits (flexible resource use)
- BestEffort: No resources defined (avoid in production)
Health Probes
Liveness: Restart unhealthy containers Readiness: Control traffic routing Startup: Protect slow-starting applications
Configure appropriate delays, periods, timeouts, and thresholds for each.
Rollout Strategies
Deployment Strategy:
RollingUpdatewithmaxSurgeandmaxUnavailable- Set
maxUnavailable: 0for zero-downtime
High Availability:
- Minimum 2-3 replicas
- Pod Disruption Budget (PDB)
- Anti-affinity rules (spread across nodes/zones)
- Horizontal Pod Autoscaler (HPA) for variable load
Validation Commands
Pre-deployment:
kubectl apply --dry-run=client -f manifest.yamlkubectl apply --dry-run=server -f manifest.yamlkubeconform -strict manifest.yaml(schema validation)helm template ./chart | kubeconform -strict(for Helm)
Policy Validation:
- OPA Conftest, Kyverno, or Datree
Rollout & Rollback
Deploy:
kubectl apply -f manifest.yamlkubectl rollout status deployment/NAME
Rollback:
kubectl rollout undo deployment/NAMEkubectl rollout undo deployment/NAME --to-revision=Nkubectl rollout history deployment/NAME
Restart:
kubectl rollout restart deployment/NAME
Manifest Checklist
- Labels: Standard labels applied
- Annotations: Documentation and monitoring
- Security: runAsNonRoot, readOnlyRootFilesystem, dropped capabilities
- Resources: Requests and limits defined
- Probes: Liveness, readiness, startup configured
- Images: Specific tags (never :latest)
- Replicas: Minimum 2-3 for production
- Strategy: RollingUpdate with appropriate surge/unavailable
- PDB: Defined for production
- Anti-affinity: Configured for HA
- Graceful shutdown: terminationGracePeriodSeconds set
- Validation: Dry-run and kubeconform passed
- Secrets: In Secrets resource, not ConfigMaps
- NetworkPolicy: Least-privilege access (if applicable)
Best Practices Summary
- Use standard labels and annotations
- Always run as non-root with dropped capabilities
- Define resource requests and limits
- Implement all three probe types
- Pin image tags to specific versions
- Configure anti-affinity for HA
- Set Pod Disruption Budgets
- Use rolling updates with zero unavailability
- Validate manifests before applying
- Enable read-only root filesystem when possible