πŸš€ 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. 1. Premise β€” DevOps = Developer + Operations
  2. 2. Six-Stage CI/CD Pipeline
  3. 3. Stage 1 β€” Version Control & Branching
  4. 4. Stage 2 β€” Continuous Integration (CI)
  5. 5. Stage 3 β€” Artifact & Image Registry
  6. 6. Stage 4 β€” Continuous Delivery/Deployment (CD)
  7. 7. Stage 5 β€” Deployment Strategy
  8. 8. Stage 6 β€” Observability & Incident Response
  9. 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):

  1. Flow β€” mempercepat aliran dari dev ke production
  2. Feedback β€” mempercepat umpan balik dari production ke dev
  3. Continuous Learning β€” budaya eksperimen dan perbaikan

Key metrics (DORA, 2024):

MetricEliteHighMediumLow
Deploy frequencyMultiple/dayDaily-weeklyWeekly-monthlyMonthly
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

StageNamaOutputDurasi
S1Version ControlBranch + commitdetik
S2CI (Build + Test)Tested artifact1-30 menit
S3RegistryDocker image / packagedetik
S4CD (Deploy)Running application1-10 menit
S5Release StrategyZero-downtime deploy< 1 menit
S6ObservabilityMetrics + logs + tracesReal-time

3. Stage 1 β€” Version Control & Branching

3.1 Branching Strategy

StrategyComplexityPR QualityHotfixCocok untuk
GitHub FlowRendah🟑MudahTim kecil, CI kuat
Git FlowTinggiβœ…KompleksRilis terjadwal
Trunk-basedSangat rendah❌ (pair review)MudahElite DORA, deploy banyak/hari
GitLab FlowSedangβœ…MudahEnvironment-based

GitHub Flow:

main ── * ── * ── * ── * ──>
        ↑      ↑
        feat/  fix/hotfix

Trunk-based + short-lived branches (< 1 hari):

main ───── * ───── * ───── * ──>
             ↑       ↑
           user-    bugfix-
           login    header

3.2 Commit Conventions

ConventionFormatTools
Conventional Commitstype(scope): descriptioncommitlint, semantic-release
Angularfeat(module): add user logincz-cli
GitmojiπŸ› fix login buggitmoji-cli

4. Stage 2 β€” Continuous Integration (CI)

4.1 CI Pipeline Structure

[Trigger] β†’ [Checkout] β†’ [Deps] β†’ [Lint] β†’ [Build] β†’ [Test] β†’ [Test Coverage] β†’ [Security Scan]
LangkahToolsDurasi
Triggerpush, PR, scheduleinstant
Checkoutgit clone10-60s
Deps installnpm ci, pip, cargo fetch30s-5m
LintESLint, ruff, clippy10s-2m
Buildtsc, cargo build, go build1-20m
Unit testjest, pytest, cargo test1-10m
Integration testDocker compose, testcontainers5-30m
Coveragec8, coverage.py, tarpaulin1-5m
Security scantrivy, snyk, semgrep1-10m

4.2 CI Platform Comparison

PlatformHostedSelf-hostedPricingCacheMatrix
GitHub Actionsβœ…βœ… Runner2000 mnt/bulan gratisβœ…βœ…
GitLab CIβœ…βœ… Runner400 mnt/bulanβœ…βœ…
CircleCIβœ…βŒ6000 mnt/bulanβœ…βœ…
JenkinsβŒβœ… Self-managedFreeβŒβœ…
WoodpeckerβŒβœ… Self-managedFreeβŒβœ…

5. Stage 3 β€” Artifact & Image Registry

5.1 Jenis Artifact

TypeFormatRegistry Tool
Container imageOCI (Docker)Docker Hub, GHCR, ECR, GCR, Harbor
JAR/WARJava archiveArtifactory, Nexus, GitHub Packages
npm package.tgznpm registry, Verdaccio
Python wheel.whlPyPI, devpi
Debian/RPM.deb/.rpmArtifactory, Pulp

5.2 Container Image Best Practices

PraktikAlasan
Multi-stage buildPisahkan build env dari runtime β€” image kecil
Distroless baseHapus shell + package manager β†’ attack surface minim
Pin base image tagJangan :latest β€” gunakan :sha256-xxx
Scan imageTrivy, Grype β€” sebelum push
Sign imagecosign (Sigstore) β€” verifikasi authenticity

6. Stage 4 β€” Continuous Delivery/Deployment (CD)

6.1 Continuous Delivery vs Continuous Deployment

AspekContinuous DeliveryContinuous Deployment
Manual gateβœ… Yes (click deploy)❌ No gate
RiskLebih terkontrolOtomatis penuh
SpeedMenit-jamDetik-menit
Use caseEnterprise, complianceSaaS, internal tools

6.2 CD Pipeline Structure

[Pull image] β†’ [DB migration] β†’ [Config injection] β†’ [Health check] β†’ [Traffic switch]
LangkahToolCheck
Pull imageKubernetes, Nomad, DockerImage digest match
DB migrationFlyway, Prisma, AlembicIdempotent
Config injectionVault, Kubernetes secrets, SOPSEncrypted
Health checkReadiness probe, curlHTTP 200
Traffic switchLoad balancer, service meshGradual

7. Stage 5 β€” Deployment Strategy

7.1 Strategi Deployment

StrategiDowntimeRollbackWaktuTraffic
Recreateβœ… Full (detik-menit)MudahTercepat0β†’100%
Rolling update❌Lambat (bertahap)BertahapPer pod
Blue-green❌ (≀ 1 detik)Instant (switch DNS)2Γ— infra0β†’100%
Canary❌Instant (stop %)Bertahap1%β†’5%β†’100%
A/B testing❌InstantRouting-basedPer user segment

7.2 Blue-Green Deployment

[Old (Blue)]  β†’  LB β†’ Users
[New (Green)] β†’  LB (after DNS switch)

Flow:

  1. Deploy Green (parallel) β€” users still hit Blue
  2. Smoke test Green via internal URL
  3. Switch LB from Blue β†’ Green
  4. Keep Blue as rollback target
  5. 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

PillarData TypeToolsSignal
MetricsNumeric time-seriesPrometheus, VictoriaMetrics, DatadogCPU, latency, error rate
LogsText eventsLoki, ELK, CloudWatchDetailed events
TracesRequest pathJaeger, Tempo, ZipkinDistributed tracing
ProfilingCPU/memory stackpprof, PyroscopePerformance hotspots

8.2 SRE (Site Reliability Engineering)

Key SRE concepts:

KonsepDefinisi
SLO (Service Level Objective)Target: 99.9% uptime
SLI (Service Level Indicator)Ukuran: latency p99 < 200ms
SLA (Service Level Agreement)Kontrak dengan customer
Error Budget100% - SLO = Waktu boleh error
ToilManual, repetitive, automatable work
Blameless postmortemRoot 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]
ToolOperatorAuto SyncDrift 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

AspekGitOpsPush-based
Source of truthGit repositoryCI/CD pipeline state
Drift detectionβœ… Automatic❌ Manual
Rollbackgit revertRe-run pipeline
Audit trailGit historyPipeline logs
ComplexityHigher (operator needed)Lower
Multi-clusterβœ… Natural❌ Complex
Secret managementSops, SealedSecrets, External SecretsCI variables

10. Cross-Reference ke Vault

StageCatatan Vault
S1hierarchy-programming-language β€” Language ecosystem tooling
S2 (CI)hierarchy-package-managers β€” Dependency management
S3hierarchy-database-storage-systems β€” Container registry storage
S4 (CD)hierarchy-systems-architecture-evolution β€” Deployment patterns
S5hierarchy-failure-modes-resilience β€” Rollback strategies
S6hierarchy-cybersecurity-defense-architecture β€” Security monitoring
Allhierarchy-abstraction-layers β€” DevOps as Layer L8

References

  1. Kim, G., Debois, P., Willis, J., Humble, J. β€œThe DevOps Handbook.” 2nd ed., IT Revolution, 2021.
  2. Humble, J. & Farley, D. β€œContinuous Delivery.” Addison-Wesley, 2010.
  3. Beyer, B. et al. β€œSite Reliability Engineering.” O’Reilly, 2016.
  4. DORA. β€œAccelerate State of DevOps Report.” Google Cloud, 2024.
  5. Burns, B. et al. β€œKubernetes: Up and Running.” 3rd ed., O’Reilly, 2024.
  6. Beedle, M. et al. β€œThe Agile Manifesto.” 2001.
  7. Farcic, V. β€œThe DevOps 2.5 Toolkit: Monitoring, Logging, and Auto-Scaling.” 2019.
  8. Argo CD. β€œArgo CD Documentation.” CNCF, 2024.
  9. Flux. β€œFlux Documentation.” CNCF, 2024.
  10. HashiCorp. β€œTerraform: Infrastructure as Code.” 2024.
  11. Newman, S. β€œBuilding Microservices.” 2nd ed., O’Reilly, 2021.