Mercury SkillsMercury Skills

Kubernetes Patterns

Pods, deployments, services, ingress, RBAC, autoscaling, and production cluster best practices

View source34 downloads
kubernetesk8sdevopscontainersorchestration

Kubernetes Patterns#

Deploy and manage production Kubernetes clusters.

Core Objects#

Workloads#

ObjectUse CaseScaling
DeploymentStateless appsReplicas, HPA
StatefulSetStateful apps (DBs)Stable network IDs
DaemonSetPer-node agents (logging, monitoring)Node count
Job/CronJobBatch tasks, scheduled jobsCompletion

Networking#

  • Service: Stable endpoint for pods (ClusterIP, NodePort, LoadBalancer)
  • Ingress: HTTP routing, TLS termination, path-based routing
  • Network Policies: Pod-level firewall rules

Production Best Practices#

Resource Management#

resources:
  requests:
    cpu: 100m
    memory: 128Mi
  limits:
    cpu: 500m
    memory: 256Mi
  • Always set requests AND limits
  • Use LimitRange for namespace defaults
  • Use ResourceQuota for namespace caps

Pod Anti-Affinity#

Spread pods across nodes for HA.

Readiness & Liveness Probes#

  • Readiness: traffic starts flowing
  • Liveness: pod gets restarted
  • Startup: for slow-starting containers

RBAC#

  • Least-privilege service accounts per app
  • Namespace-scoped roles (not cluster-wide)
  • Regularly audit permissions
  • Use groups, not individual users

Autoscaling#

  • HPA: scale by CPU/memory or custom metrics
  • VPA: adjust resource requests automatically
  • Cluster Autoscaler: add/remove nodes
  • KEDA: event-driven scaling (SQS queue depth, etc.)

More in DevOps

View all →

CI/CD Pipeline Design: From Commit to Production

Design and implement production-grade CI/CD pipelines with GitHub Actions, layered testing strategies, secure deployment patterns, and environment management.

ci-cdgithub-actionsdevops

Docker Patterns: Production-Grade Containerization

Master Dockerfile optimization, multi-stage builds, docker-compose patterns, security hardening, and image size reduction techniques for production-grade containerization.

dockercontainerizationdevops

Terraform / Infrastructure as Code

State management, modules, workspaces, remote backends, and multi-environment strategies

terraformiacinfrastructure