YAML Templates & Examples Library.

Production-tested YAML configurations for cloud infrastructure, container orchestration, CI/CD pipelines, and API specifications.

General#sample-app

Modern Web App Config

Standard application configuration showing objects, arrays, booleans, and environment variables.

# Production Application Configuration
app:
  name: "yaml-converter-engine"
  version: "2.4.0"
  environment: "production"
  # Server listener settings
  server:
    host: "0.0.0.0"
    port: 8080
    ssl:
      enabled: true
      cert_path: "/etc/ssl/certs/bundle.crt"
  # Database clustering configuration
  database:
    driver: "postgresql"
    pool_size: 25
    timeout_seconds: 30
    replicas:
      - host: "db-replica-01.internal"
        role: "read"
      - host: "db-replica-02.internal"
        role: "read"
  # Feature flag booleans
  features:
    cache_enabled: true
    rate_limiting: true
    beta_access: false
  allowed_origins:
    - "https://yamlconverter.com"
    - "https://app.yamlconverter.com"
General#anchors-and-aliases

YAML Anchors & Merge Keys

Demonstrates DRY configuration using YAML anchors (&), aliases (*), and merge keys (<<).

# Reusable Base Resource Template
default_resource: &default_res
  cpu: "250m"
  memory: "256Mi"
  timeout_seconds: 30

# Service definitions inheriting from default_resource
services:
  auth_service:
    <<: *default_res
    port: 8081
    name: "auth-worker"

  billing_service:
    <<: *default_res
    port: 8082
    name: "billing-worker"
    memory: "512Mi"  # Overrides default 256Mi
Kubernetes#k8s-deployment-service

Kubernetes Deployment & Service

Multi-document Kubernetes manifest containing a scalable Deployment and a ClusterIP Service.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-api-deployment
  labels:
    app: web-api
    tier: backend
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-api
  template:
    metadata:
      labels:
        app: web-api
    spec:
      containers:
        - name: web-api
          image: "node:22-alpine"
          ports:
            - containerPort: 3000
          env:
            - name: NODE_ENV
              value: "production"
          resources:
            limits:
              cpu: "500m"
              memory: "512Mi"
            requests:
              cpu: "100m"
              memory: "128Mi"
---
apiVersion: v1
kind: Service
metadata:
  name: web-api-service
  labels:
    app: web-api
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 3000
      protocol: TCP
  selector:
    app: web-api
Docker#docker-compose-stack

Docker Compose Full-Stack

Multi-container Docker Compose file with Web app, PostgreSQL database, and Redis cache.

version: "3.8"

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: "postgres://user:secret@db:5432/appdb"
      REDIS_URL: "redis://cache:6379"
    depends_on:
      - db
      - cache
    restart: unless-stopped

  db:
    image: "postgres:16-alpine"
    environment:
      POSTGRES_USER: "user"
      POSTGRES_PASSWORD: "secretpassword"
      POSTGRES_DB: "appdb"
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  cache:
    image: "redis:7-alpine"
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - redisdata:/data

volumes:
  pgdata:
  redisdata:
CI/CD#github-actions-ci

GitHub Actions CI/CD Pipeline

Automated CI workflow with Node.js matrix testing, linting, and build steps.

name: "Continuous Integration"

"on":
  push:
    branches: ["main", "staging"]
  pull_request:
    branches: ["main"]

jobs:
  test-and-build:
    name: "Test & Build"
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18.x, 20.x, 22.x]

    steps:
      - name: "Checkout code"
        uses: actions/checkout@v4

      - name: "Setup Node.js ${{ matrix.node-version }}"
        uses: actions/setup-node@v4
        with:
          node-version: "${{ matrix.node-version }}"
          cache: "npm"

      - name: "Install dependencies"
        run: npm ci

      - name: "Run linter"
        run: npm run lint

      - name: "Execute unit tests"
        run: npm test -- --coverage

      - name: "Build production bundle"
        run: npm run build
API Spec#openapi-spec

OpenAPI 3.1 REST API Spec

OpenAPI specification defining endpoints, query parameters, and response schemas.

openapi: "3.1.0"
info:
  title: "YAML Converter Microservice API"
  version: "1.0.0"
  description: "RESTful API definition for format transformations"

paths:
  /api/v1/convert:
    post:
      summary: "Convert YAML to JSON"
      operationId: "convertYaml"
      requestBody:
        required: true
        content:
          text/yaml:
            schema:
              type: "string"
      responses:
        "200":
          description: "Successful conversion"
          content:
            application/json:
              schema:
                type: "object"
        "400":
          description: "Invalid YAML syntax"
          content:
            application/json:
              schema:
                type: "object"
                properties:
                  error:
                    type: "string"
                  line:
                    type: "integer"
                  column:
                    type: "integer"
Ansible#ansible-playbook

Ansible Server Provisioning

Ansible playbook to provision and configure an Nginx reverse proxy with SSL.

---
- name: "Configure Web Server"
  hosts: webservers
  become: true
  vars:
    http_port: 80
    domain_name: "yamlconverter.com"

  tasks:
    - name: "Ensure Nginx is installed"
      apt:
        name: nginx
        state: present
        update_cache: true

    - name: "Deploy Nginx virtual host configuration"
      template:
        src: "nginx.conf.j2"
        dest: "/etc/nginx/sites-available/{{ domain_name }}"
      notify:
        - "Reload Nginx"

    - name: "Enable site configuration"
      file:
        src: "/etc/nginx/sites-available/{{ domain_name }}"
        dest: "/etc/nginx/sites-enabled/{{ domain_name }}"
        state: link

  handlers:
    - name: "Reload Nginx"
      service:
        name: nginx
        state: reloaded
Copied to clipboard!