π DevOps & CI/CD β Dari Developer ke Production
DevOps adalah budaya + praktik + tools yang mempersingkat jarak antara "code committed" dan "code running in production". Catatan ini memetakan 6 tahap pipeline modern dari commit hingga observability, perbandingan GitOps vs Push-based, deployment strategy (blue-green, canary, rolling), dan framework SRE. Folder DevOps/ di vault sudah punya 7 files tapi tidak ada hierarchy master.
Daftar Isi
1. Premise β DevOps = Developer + Operations
2. Six-Stage CI/CD Pipeline
3. Stage 1 β Version Control & Branching
4. Stage 2 β Continuous Integration (CI)
5. Stage 3 β Artifact & Image Registry
6. Stage 4 β Continuous Delivery/Deployment (CD)
7. Stage 5 β Deployment Strategy
8. Stage 6 β Observability & Incident Response
9. GitOps vs Push-based
1. Premise β DevOps = Developer + Operations
DevOps is NOT a tool. DevOps is NOT a job title. DevOps is a culture.
Before DevOps:
[Dev] Write code β Throw over wall β [Ops] Deploy (panic)
After DevOps:
[Dev + Ops] Code β Automated test β Automated deploy β Monitor β Feedback
Three Ways of DevOps (Gene Kim):
Flow β mempercepat aliran dari dev ke production
Feedback β mempercepat umpan balik dari production ke dev
Continuous Learning β budaya eksperimen dan perbaikan
Key metrics (DORA, 2024):
Metric Elite High Medium Low Deploy frequency Multiple/day Daily-weekly Weekly-monthly Monthly Lead time for change < 1 hour < 1 day < 1 week > 1 week Change failure rate < 5% < 10% < 15% > 15% Time to restore < 1 hour < 1 day < 1 week > 1 week
2. Six-Stage CI/CD Pipeline
Stage Nama Output Durasi S1 Version Control Branch + commit detik S2 CI (Build + Test) Tested artifact 1-30 menit S3 Registry Docker image / package detik S4 CD (Deploy) Running application 1-10 menit S5 Release Strategy Zero-downtime deploy < 1 menit S6 Observability Metrics + logs + traces Real-time
3. Stage 1 β Version Control & Branching
3.1 Branching Strategy
Strategy Complexity PR Quality Hotfix Cocok untuk GitHub Flow Rendah π‘ Mudah Tim kecil, CI kuat Git Flow Tinggi β
Kompleks Rilis terjadwal Trunk-based Sangat rendah β (pair review) Mudah Elite DORA, deploy banyak/hari GitLab Flow Sedang β
Mudah Environment-based
GitHub Flow:
main ββ * ββ * ββ * ββ * ββ>
β β
feat/ fix/hotfix
Trunk-based + short-lived branches (< 1 hari):
main βββββ * βββββ * βββββ * ββ>
β β
user- bugfix-
login header
3.2 Commit Conventions
Convention Format Tools Conventional Commits type(scope): descriptioncommitlint, semantic-release Angular feat(module): add user logincz-cli Gitmoji π fix login bug gitmoji-cli
4. Stage 2 β Continuous Integration (CI)
4.1 CI Pipeline Structure
[Trigger] β [Checkout] β [Deps] β [Lint] β [Build] β [Test] β [Test Coverage] β [Security Scan]
Langkah Tools Durasi Trigger push, PR, schedule instant Checkout git clone 10-60s Deps install npm ci, pip, cargo fetch 30s-5m Lint ESLint, ruff, clippy 10s-2m Build tsc, cargo build, go build 1-20m Unit test jest, pytest, cargo test 1-10m Integration test Docker compose, testcontainers 5-30m Coverage c8, coverage.py, tarpaulin 1-5m Security scan trivy, snyk, semgrep 1-10m
Platform Hosted Self-hosted Pricing Cache Matrix GitHub Actions β
β
Runner 2000 mnt/bulan gratis β
β
GitLab CI β
β
Runner 400 mnt/bulan β
β
CircleCI β
β 6000 mnt/bulan β
β
Jenkins β β
Self-managed Free β β
Woodpecker β β
Self-managed Free β β
5. Stage 3 β Artifact & Image Registry
5.1 Jenis Artifact
Type Format Registry Tool Container image OCI (Docker) Docker Hub, GHCR, ECR, GCR, Harbor JAR/WAR Java archive Artifactory, Nexus, GitHub Packages npm package .tgz npm registry, Verdaccio Python wheel .whl PyPI, devpi Debian/RPM .deb/.rpm Artifactory, Pulp
5.2 Container Image Best Practices
Praktik Alasan Multi-stage build Pisahkan build env dari runtime β image kecil Distroless base Hapus shell + package manager β attack surface minim Pin base image tag Jangan :latest β gunakan :sha256-xxx Scan image Trivy, Grype β sebelum push Sign image cosign (Sigstore) β verifikasi authenticity
6. Stage 4 β Continuous Delivery/Deployment (CD)
6.1 Continuous Delivery vs Continuous Deployment
Aspek Continuous Delivery Continuous Deployment Manual gate β
Yes (click deploy) β No gate Risk Lebih terkontrol Otomatis penuh Speed Menit-jam Detik-menit Use case Enterprise, compliance SaaS, internal tools
6.2 CD Pipeline Structure
[Pull image] β [DB migration] β [Config injection] β [Health check] β [Traffic switch]
Langkah Tool Check Pull image Kubernetes, Nomad, Docker Image digest match DB migration Flyway, Prisma, Alembic Idempotent Config injection Vault, Kubernetes secrets, SOPS Encrypted Health check Readiness probe, curl HTTP 200 Traffic switch Load balancer, service mesh Gradual
7. Stage 5 β Deployment Strategy
7.1 Strategi Deployment
Strategi Downtime Rollback Waktu Traffic Recreate β
Full (detik-menit) Mudah Tercepat 0β100% Rolling update β Lambat (bertahap) Bertahap Per pod Blue-green β (β€ 1 detik) Instant (switch DNS) 2Γ infra 0β100% Canary β Instant (stop %) Bertahap 1%β5%β100% A/B testing β Instant Routing-based Per user segment
7.2 Blue-Green Deployment
[Old (Blue)] β LB β Users
[New (Green)] β LB (after DNS switch)
Flow:
Deploy Green (parallel) β users still hit Blue
Smoke test Green via internal URL
Switch LB from Blue β Green
Keep Blue as rollback target
Destroy Blue after N hours/days
7.3 Canary Release
Kubernetes-style canary:
9 pods (old) + 1 pod (new) β 10% traffic to canary
β
Monitor error rate + latency
β
If OK: increment canary to 50% β 100%
If not OK: drain canary pod β back to stable
8. Stage 6 β Observability & Incident Response
8.1 Observability Foundation
Pillar Data Type Tools Signal Metrics Numeric time-series Prometheus, VictoriaMetrics, Datadog CPU, latency, error rate Logs Text events Loki, ELK, CloudWatch Detailed events Traces Request path Jaeger, Tempo, Zipkin Distributed tracing Profiling CPU/memory stack pprof, Pyroscope Performance hotspots
8.2 SRE (Site Reliability Engineering)
Key SRE concepts:
Konsep Definisi SLO (Service Level Objective) Target: 99.9% uptime SLI (Service Level Indicator) Ukuran: latency p99 < 200ms SLA (Service Level Agreement) Kontrak dengan customer Error Budget 100% - SLO = Waktu boleh error Toil Manual, repetitive, automatable work Blameless postmortem Root cause β prevent recurrence
8.3 Incident Response
Detect β Triage β Mitigate β Resolve β Postmortem
β β β β β
Alert Severity Rollback Verified Root cause
P0/P1/P2 /Canary /Fixed + Action items
9. GitOps vs Push-based
9.1 GitOps (Pull-based)
Prinsip: Git = single source of truth. Cluster pulls desired state.
[Developer pushes to Git] β [GitOps operator watches] β [Applies to cluster]
Tool Operator Auto Sync Drift Detection Argo CD β
β
β
(3m default) Flux β
β
β
Jenkins X β
Tekton β
β
Rancher Fleet β
β
β
9.2 Push-based (CI-driven)
Prinsip: CI pipeline mendorong langsung ke cluster.
[CI pipeline builds] β [Pushes image to registry] β [Sends deploy command to cluster]
Lebih sederhana, cocok untuk:
Single cluster, small team
Developer langsung akses cluster
Aplikasi stateless
9.3 GitOps vs Push-based
Aspek GitOps Push-based Source of truth Git repository CI/CD pipeline state Drift detection β
Automatic β Manual Rollback git revertRe-run pipeline Audit trail Git history Pipeline logs Complexity Higher (operator needed) Lower Multi-cluster β
Natural β Complex Secret management Sops, SealedSecrets, External Secrets CI variables
10. Cross-Reference ke Vault
References
Kim, G., Debois, P., Willis, J., Humble, J. βThe DevOps Handbook.β 2nd ed., IT Revolution, 2021.
Humble, J. & Farley, D. βContinuous Delivery.β Addison-Wesley, 2010.
Beyer, B. et al. βSite Reliability Engineering.β OβReilly, 2016.
DORA. βAccelerate State of DevOps Report.β Google Cloud, 2024.
Burns, B. et al. βKubernetes: Up and Running.β 3rd ed., OβReilly, 2024.
Beedle, M. et al. βThe Agile Manifesto.β 2001.
Farcic, V. βThe DevOps 2.5 Toolkit: Monitoring, Logging, and Auto-Scaling.β 2019.
Argo CD. βArgo CD Documentation.β CNCF, 2024.
Flux. βFlux Documentation.β CNCF, 2024.
HashiCorp. βTerraform: Infrastructure as Code.β 2024.
Newman, S. βBuilding Microservices.β 2nd ed., OβReilly, 2021.