DevOps Domain Skill
Docker
Quick Commands
docker build -t myapp:v1.0.0 . # Build image
docker build --target production -t myapp:prod . # Multi-stage build
docker run --cpus=0.5 --memory=512m myapp:v1.0.0 # Run with limits
docker history myapp:v1.0.0 # Inspect layers
docker image prune -f # Remove dangling
docker logs -f --tail=100 container_id # Tail logs
Dockerfile Best Practices
- Use specific base image tags (never
:latest)
- Multi-stage builds for minimal runtime images
- Copy dependency files first for layer caching
- Run as non-root user
- Use
.dockerignore to exclude unnecessary files
- Minimize layers (combine RUN commands with
&&)
- Use distroless or alpine for production
- Set health checks
- Label images with metadata
See: references/docker-complete.md for optimization techniques and Compose configurations.
CI/CD Pipelines
Pipeline Stages
- Lint - Code quality checks (parallel with tests)
- Test - Unit/integration tests with coverage
- Build - Container image build and push
- Deploy - Environment-specific deployments
- Verify - Smoke tests and health checks
Best Practices
- Cache dependencies between runs
- Matrix builds for multi-version testing
- Separate fast checks (lint) from slow (integration)
- Fail fast on quality gates
- Tag images with commit SHA and semantic versions
- Store secrets in CI secret store, never in code
- Use environments for staging/production approvals
See: references/github-actions.md for complete workflows, matrix builds, caching, and deployment automation.
Kubernetes
Essential Resources
| Resource |
Purpose |
| Deployment |
Manages replica sets and rolling updates |
| Service |
Stable networking endpoint for pods |
| Ingress |
HTTP(S) routing to services |
| ConfigMap |
Non-sensitive configuration |
| Secret |
Sensitive data (credentials, tokens) |
| HPA |
Horizontal Pod Autoscaler |
Key kubectl Commands
kubectl apply -f deployment.yaml # Apply manifests
kubectl get pods,svc,ing -n production # Resource status
kubectl logs -f deployment/myapp -n production # View logs
kubectl exec -it pod/myapp-xxx -- /bin/sh # Shell into pod
kubectl port-forward svc/myapp 8080:80 # Port forward
kubectl rollout status deployment/myapp # Rollout status
kubectl rollout undo deployment/myapp # Rollback
kubectl scale deployment/myapp --replicas=5 # Manual scale
kubectl top pods -n production # Resource usage
Deployment Checklist
See: references/kubernetes-manifests.md for manifest examples, Helm charts, and security configurations.
Observability
1. Logging (What happened?)
- Structured JSON logs with context (request_id, user_id, service_name)
- Levels: DEBUG < INFO < WARNING < ERROR < CRITICAL
- Centralize with Loki, ElasticSearch, or CloudWatch
- Never log sensitive data
2. Metrics (How much/how many?)
- Counter: Monotonically increasing (requests_total)
- Gauge: Current value (active_connections)
- Histogram: Distribution (request_duration_seconds)
- Summary: Quantiles (p95, p99 latency)
- Track: request rate, error rate (4xx/5xx), latency percentiles, saturation (CPU/memory/disk)
3. Tracing (Where did time go?)
- Distributed tracing across services with OpenTelemetry
- Track request path, identify bottlenecks and slow queries
See: references/observability-stack.md for Prometheus, Grafana, Loki, Jaeger, and OpenTelemetry configurations.
Deployment Strategies
| Strategy |
How It Works |
When to Use |
Trade-off |
| Rolling |
Gradually replace old pods |
Standard deploys, backward-compatible changes |
Slower rollout |
| Blue-Green |
Two environments, instant switch |
DB migrations, major version updates |
2x infrastructure cost |
| Canary |
Route small % to new version, increase if healthy |
High-risk changes, need real-traffic validation |
Complexity, needs metrics |
All strategies: use readiness probes, have rollback plan, monitor error rate and latency during rollout.
See: references/deployment-strategies.md for rollback procedures and automated canary configurations.
Security Hardening
Container Security
- Scan images for vulnerabilities (Trivy, Snyk)
- Minimal base images (distroless, scratch)
- Non-root user, read-only root filesystem, drop all capabilities
- Regular image updates
Kubernetes Security
- Network policies (deny-all by default)
- Pod Security Standards (restricted mode)
- RBAC for least privilege access
- External secrets management (Vault, AWS Secrets Manager)
- Encrypt secrets at rest
- Admission controllers for policy enforcement
Secrets Management
- Never commit to Git
- Use external secret stores, rotate regularly
- Audit access, mount as files (not env vars when possible)
- Scope to namespaces
See: references/security-hardening.md for network policies, image scanning automation, and compliance configurations.
Infrastructure as Code
Principles
- Version control all manifests
- Declarative over imperative
- Separate environment configs (dev/staging/prod)
- Validate before apply (
kubectl dry-run, helm lint)
- Use GitOps (ArgoCD, Flux) -- Git as single source of truth
Helm Best Practices
- Template for environment differences, override with env-specific values files
- Version charts semantically
- Include sane defaults, validate before release
Troubleshooting Checklist
| Symptom |
Commands |
Common Causes |
| Pod not starting |
kubectl describe pod <name>, kubectl logs <name>, kubectl get events --sort-by=.metadata.creationTimestamp |
Image pull errors, resource limits, health check failures |
| Service unreachable |
kubectl get svc,endpoints <name>, kubectl describe svc <name> |
Label mismatch, port misconfiguration, network policies |
| High resource usage |
kubectl top pods, kubectl describe node <name> |
No resource limits, memory leaks, inefficient code |
| Deployment stuck |
kubectl rollout status deployment/<name>, kubectl get events | grep <name> |
Failing health checks, insufficient resources, image issues |
Quick Reference Links
references/docker-complete.md - Comprehensive Docker guide
references/kubernetes-manifests.md - K8s manifests and Helm charts
references/github-actions.md - Complete CI/CD workflows
references/observability-stack.md - Monitoring and logging setup
references/deployment-strategies.md - Deployment patterns and rollbacks
references/security-hardening.md - Security best practices
Key Principles
- Automate Everything - Manual processes are error-prone
- Measure Everything - Can't improve what you don't measure
- Fail Fast - Catch issues early in pipeline
- Immutable Infrastructure - Replace, don't modify
- Infrastructure as Code - Version control all config
- Monitor Proactively - Alert before users notice
- Practice Chaos - Test failure scenarios regularly
- Document Runbooks - Incident response should be scripted
1---2name: domain-devops3description: Guides the user through containerization, CI/CD pipelines, Kubernetes deployments, observability, and infrastructure management. ALWAYS trigger on "dockerize", "CI/CD", "kubernetes", "deploy", "monitoring", "logging", "metrics", "helm", "infrastructure", "observability", "rollback", "scaling", "pipeline", "container", "k8s", "GitOps", "Dockerfile", "health check", "troubleshoot deployment". Use when containerizing applications, building pipelines, deploying services, setting up monitoring, or debugging infrastructure issues. Different from the DevOps agent (agents/devops.md) which handles orchestration and runbook execution rather than pattern guidance.4---56# DevOps Domain Skill78## Docker910### Quick Commands11```bash12docker build -t myapp:v1.0.0 . # Build image13docker build --target production -t myapp:prod . # Multi-stage build14docker run --cpus=0.5 --memory=512m myapp:v1.0.0 # Run with limits15docker history myapp:v1.0.0 # Inspect layers16docker image prune -f # Remove dangling17docker logs -f --tail=100 container_id # Tail logs18```1920### Dockerfile Best Practices21- Use specific base image tags (never `:latest`)22- Multi-stage builds for minimal runtime images23- Copy dependency files first for layer caching24- Run as non-root user25- Use `.dockerignore` to exclude unnecessary files26- Minimize layers (combine RUN commands with `&&`)27- Use distroless or alpine for production28- Set health checks29- Label images with metadata3031**See:** `references/docker-complete.md` for optimization techniques and Compose configurations.3233## CI/CD Pipelines3435### Pipeline Stages361. **Lint** - Code quality checks (parallel with tests)372. **Test** - Unit/integration tests with coverage383. **Build** - Container image build and push394. **Deploy** - Environment-specific deployments405. **Verify** - Smoke tests and health checks4142### Best Practices43- Cache dependencies between runs44- Matrix builds for multi-version testing45- Separate fast checks (lint) from slow (integration)46- Fail fast on quality gates47- Tag images with commit SHA and semantic versions48- Store secrets in CI secret store, never in code49- Use environments for staging/production approvals5051**See:** `references/github-actions.md` for complete workflows, matrix builds, caching, and deployment automation.5253## Kubernetes5455### Essential Resources5657| Resource | Purpose |58|----------|---------|59| Deployment | Manages replica sets and rolling updates |60| Service | Stable networking endpoint for pods |61| Ingress | HTTP(S) routing to services |62| ConfigMap | Non-sensitive configuration |63| Secret | Sensitive data (credentials, tokens) |64| HPA | Horizontal Pod Autoscaler |6566### Key kubectl Commands67```bash68kubectl apply -f deployment.yaml # Apply manifests69kubectl get pods,svc,ing -n production # Resource status70kubectl logs -f deployment/myapp -n production # View logs71kubectl exec -it pod/myapp-xxx -- /bin/sh # Shell into pod72kubectl port-forward svc/myapp 8080:80 # Port forward73kubectl rollout status deployment/myapp # Rollout status74kubectl rollout undo deployment/myapp # Rollback75kubectl scale deployment/myapp --replicas=5 # Manual scale76kubectl top pods -n production # Resource usage77```7879### Deployment Checklist80- [ ] Resource requests and limits defined81- [ ] Liveness and readiness probes configured82- [ ] Running as non-root user83- [ ] Secrets externalized (not in manifests)84- [ ] Labels for monitoring and service discovery85- [ ] Multiple replicas for high availability86- [ ] Rolling update strategy configured87- [ ] HPA configured for auto-scaling8889**See:** `references/kubernetes-manifests.md` for manifest examples, Helm charts, and security configurations.9091## Observability9293### 1. Logging (What happened?)94- Structured JSON logs with context (request_id, user_id, service_name)95- Levels: DEBUG < INFO < WARNING < ERROR < CRITICAL96- Centralize with Loki, ElasticSearch, or CloudWatch97- Never log sensitive data9899### 2. Metrics (How much/how many?)100- **Counter:** Monotonically increasing (requests_total)101- **Gauge:** Current value (active_connections)102- **Histogram:** Distribution (request_duration_seconds)103- **Summary:** Quantiles (p95, p99 latency)104- Track: request rate, error rate (4xx/5xx), latency percentiles, saturation (CPU/memory/disk)105106### 3. Tracing (Where did time go?)107- Distributed tracing across services with OpenTelemetry108- Track request path, identify bottlenecks and slow queries109110**See:** `references/observability-stack.md` for Prometheus, Grafana, Loki, Jaeger, and OpenTelemetry configurations.111112## Deployment Strategies113114| Strategy | How It Works | When to Use | Trade-off |115|----------|-------------|-------------|-----------|116| **Rolling** | Gradually replace old pods | Standard deploys, backward-compatible changes | Slower rollout |117| **Blue-Green** | Two environments, instant switch | DB migrations, major version updates | 2x infrastructure cost |118| **Canary** | Route small % to new version, increase if healthy | High-risk changes, need real-traffic validation | Complexity, needs metrics |119120All strategies: use readiness probes, have rollback plan, monitor error rate and latency during rollout.121122**See:** `references/deployment-strategies.md` for rollback procedures and automated canary configurations.123124## Security Hardening125126### Container Security127- Scan images for vulnerabilities (Trivy, Snyk)128- Minimal base images (distroless, scratch)129- Non-root user, read-only root filesystem, drop all capabilities130- Regular image updates131132### Kubernetes Security133- Network policies (deny-all by default)134- Pod Security Standards (restricted mode)135- RBAC for least privilege access136- External secrets management (Vault, AWS Secrets Manager)137- Encrypt secrets at rest138- Admission controllers for policy enforcement139140### Secrets Management141- Never commit to Git142- Use external secret stores, rotate regularly143- Audit access, mount as files (not env vars when possible)144- Scope to namespaces145146**See:** `references/security-hardening.md` for network policies, image scanning automation, and compliance configurations.147148## Infrastructure as Code149150### Principles151- Version control all manifests152- Declarative over imperative153- Separate environment configs (dev/staging/prod)154- Validate before apply (`kubectl dry-run`, `helm lint`)155- Use GitOps (ArgoCD, Flux) -- Git as single source of truth156157### Helm Best Practices158- Template for environment differences, override with env-specific values files159- Version charts semantically160- Include sane defaults, validate before release161162## Troubleshooting Checklist163164| Symptom | Commands | Common Causes |165|---------|----------|---------------|166| Pod not starting | `kubectl describe pod <name>`, `kubectl logs <name>`, `kubectl get events --sort-by=.metadata.creationTimestamp` | Image pull errors, resource limits, health check failures |167| Service unreachable | `kubectl get svc,endpoints <name>`, `kubectl describe svc <name>` | Label mismatch, port misconfiguration, network policies |168| High resource usage | `kubectl top pods`, `kubectl describe node <name>` | No resource limits, memory leaks, inefficient code |169| Deployment stuck | `kubectl rollout status deployment/<name>`, `kubectl get events \| grep <name>` | Failing health checks, insufficient resources, image issues |170171## Quick Reference Links172173- `references/docker-complete.md` - Comprehensive Docker guide174- `references/kubernetes-manifests.md` - K8s manifests and Helm charts175- `references/github-actions.md` - Complete CI/CD workflows176- `references/observability-stack.md` - Monitoring and logging setup177- `references/deployment-strategies.md` - Deployment patterns and rollbacks178- `references/security-hardening.md` - Security best practices179180## Key Principles1811821. **Automate Everything** - Manual processes are error-prone1832. **Measure Everything** - Can't improve what you don't measure1843. **Fail Fast** - Catch issues early in pipeline1854. **Immutable Infrastructure** - Replace, don't modify1865. **Infrastructure as Code** - Version control all config1876. **Monitor Proactively** - Alert before users notice1887. **Practice Chaos** - Test failure scenarios regularly1898. **Document Runbooks** - Incident response should be scripted190191<!-- Last reviewed: 2026-03 -->