JSONYAMify

Home / Blog / YAML untuk DevOps

YAML untuk DevOps: Docker Compose, Kubernetes, dan CI/CD

Oleh Andi Putra Ogie · Update: Juni 2026 · 6 menit baca

Di dunia DevOps, YAML praktis menjadi bahasa universal untuk mendeskripsikan infrastruktur dan automasi. Berikut tiga konteks paling umum.

1. Docker Compose

version: "3.9"
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
  api:
    build: ./api
    environment:
      - NODE_ENV=production
    depends_on:
      - db
  db:
    image: postgres:16

Setiap service didefinisikan sebagai key di bawah services, dengan konfigurasi image, port, environment variable, dan dependensi antar service.

2. Kubernetes Manifest

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: myregistry/api:1.4.0
          ports:
            - containerPort: 8080

Kubernetes sangat bergantung pada YAML untuk mendefinisikan Deployment, Service, ConfigMap, Secret, dan resource lain. Kesalahan indentasi sekecil apa pun bisa membuat kubectl apply gagal total.

3. CI/CD Pipeline (GitHub Actions)

name: CI
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm install
      - run: npm test

Tips Menghindari Error YAML di Production

🔧 Validasi YAML Config Kamu

YAML for DevOps: Docker Compose, Kubernetes, and CI/CD

By Andi Putra Ogie · Updated: June 2026 · 6 min read

In the DevOps world, YAML has practically become the universal language for describing infrastructure and automation. Here are the three most common contexts.

1. Docker Compose

version: "3.9"
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
  api:
    build: ./api
    environment:
      - NODE_ENV=production
    depends_on:
      - db
  db:
    image: postgres:16

Each service is defined as a key under services, with config for image, ports, environment variables, and dependencies between services.

2. Kubernetes Manifests

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: myregistry/api:1.4.0
          ports:
            - containerPort: 8080

Kubernetes relies heavily on YAML to define Deployments, Services, ConfigMaps, Secrets, and more. Even a tiny indentation mistake can make kubectl apply fail entirely.

3. CI/CD Pipeline (GitHub Actions)

name: CI
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm install
      - run: npm test

Tips to Avoid YAML Errors in Production

🔧 Validate Your YAML Config