Kubernetes Manifests

Kubernetes Manifests

Sets rules for writing production-ready Kubernetes YAML manifests: labels, security contexts, resource limits, probes and validation steps.


applyTo: 'k8s//*.yaml,k8s//.yml,manifests/**/.yaml,manifests//*.yml,deploy//.yaml,deploy/**/.yml,charts//templates//.yaml,charts//templates//.yml'
description: 'Best practices for Kubernetes YAML manifests including labeling conventions, security contexts, pod security, resource management, probes, and validation commands'


Kubernetes Manifests Instructions

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 name
  • app.kubernetes.io/instance: Instance identifier
  • app.kubernetes.io/version: Version
  • app.kubernetes.io/component: Component role
  • app.kubernetes.io/part-of: Application group
  • app.kubernetes.io/managed-by: Management tool

Additional Labels:

  • environment: Environment name
  • team: Owning team
  • cost-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: true
  • runAsUser and runAsGroup: Specific IDs
  • fsGroup: File system group
  • seccompProfile.type: RuntimeDefault

Container-level:

  • allowPrivilegeEscalation: false
  • readOnlyRootFilesystem: 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:

  • RollingUpdate with maxSurge and maxUnavailable
  • Set maxUnavailable: 0 for 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.yaml
  • kubectl apply --dry-run=server -f manifest.yaml
  • kubeconform -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.yaml
  • kubectl rollout status deployment/NAME

Rollback:

  • kubectl rollout undo deployment/NAME
  • kubectl rollout undo deployment/NAME --to-revision=N
  • kubectl 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

  1. Use standard labels and annotations
  2. Always run as non-root with dropped capabilities
  3. Define resource requests and limits
  4. Implement all three probe types
  5. Pin image tags to specific versions
  6. Configure anti-affinity for HA
  7. Set Pod Disruption Budgets
  8. Use rolling updates with zero unavailability
  9. Validate manifests before applying
  10. Enable read-only root filesystem when possible

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…