1---2name: automate-deployments-and-cicd3description: "Automate deployments, manage infrastructure, and build reliable CI/CD pipelines."4category: "DevOps & Infra"5author: community6version: "1.0.0"7icon: server8metadata:9 source: https://skillmd.com/skills/rondoflow/automate-deployments-and-cicd10---1112# DevOps Rules1314## CI/CD Pipelines15- Fail fast: run linting and unit tests before expensive integration tests — saves time and compute16- Cache dependencies between runs — `npm install` on every build wastes minutes17- Pin action versions with SHA, not tags — `actions/checkout@v3` can change, SHA is immutable18- Secrets in environment variables, never in code or logs — mask them in CI output19- Parallel jobs for independent steps — test, lint, and build can run simultaneously2021## Deployment Strategies22- Blue-green: run new version alongside old, switch traffic atomically — instant rollback by switching back23- Canary: route percentage of traffic to new version — catch issues before full rollout24- Rolling: update instances incrementally — balance between speed and risk25- Always have rollback plan before deploying — know exactly how to revert26- Deploy the same artifact to all environments — build once, promote through stages2728## Infrastructure as Code29- Version control all infrastructure — terraform, ansible, cloudformation in git30- Never apply changes without plan/diff review — `terraform plan` before `apply`31- State files contain secrets — store remotely with encryption, never in git32- Modules for reusable components — don't copy-paste infrastructure definitions33- Separate environments with workspaces or directories — dev changes shouldn't affect prod3435## Containers36- One process per container — containers are not VMs37- Health checks are mandatory — orchestrators need them for routing and restarts38- Don't run as root — use non-root USER in Dockerfile39- Immutable images: config via environment, not baked in — same image in all environments40- Tag images with git SHA, not just `latest` — know exactly what's deployed4142## Secrets Management43- Never store secrets in environment files committed to git — use vault, sealed secrets, or CI secret storage44- Rotate secrets regularly — automation makes rotation painless45- Different secrets per environment — dev leak shouldn't compromise prod46- Audit secret access — know who accessed what and when47- Secrets in memory, not disk when possible — temp files persist longer than expected4849## Monitoring & Alerting50- Four golden signals: latency, traffic, errors, saturation — start here51- Alert on symptoms, not causes — "users seeing errors" not "CPU high"52- Every alert must be actionable — if you can't do anything, it's noise53- Dashboard per service with key metrics — one glance shows health54- Structured logs (JSON) for machine parsing — grep works, but queries are better5556## Reliability57- Define SLOs before building alerting — what does "healthy" mean for this service?58- Error budgets: some failures are acceptable — 99.9% means 8 hours downtime/year is OK59- Chaos engineering in staging — break things intentionally before prod breaks accidentally60- Runbooks for common incidents — 3am is not the time to figure out recovery steps61- Post-mortems without blame — focus on systems, not people6263## Common Mistakes64- SSH into prod to fix things — all changes through automation, or you'll forget what you did65- No staging environment — "works on my machine" doesn't mean works in prod66- Ignoring flaky tests — they erode trust in CI, either fix or delete67- Manual steps in deployment — if it's not automated, it'll be done wrong eventually68- Monitoring only happy paths — check error rates and edge cases too6970## Networking71- Internal services don't need public IPs — use private subnets, expose only load balancers72- TLS everywhere, including internal traffic — zero trust, even behind firewall73- DNS for service discovery — hardcoded IPs break when things move74- Load balancer health checks separate from app health — LB needs fast response, app health can be thorough75- Firewall default deny — explicitly allow what's needed, block everything else