Skip to content

Deployment YAML Patterns

TL;DR — Services in ops-scripts use one of two mutually exclusive YAML patterns: flat (same config for all envs) or custom/{env}/ (per-environment YAMLs). deploy_service_jenkins.sh on the kops server auto-detects which pattern is in use — no flag required.

K8s only

This applies only to services deployed to Kubernetes (backend microservices, cron jobs). Frontend deploys use a different path — see frontend-architecture.md.

Overview

Every service in ops-scripts lives under k8s/{service-name}/ and its K8s YAMLs follow one of two patterns. The Jenkins deploy script handles both transparently — see jenkins-k8s-jobs.md for the full CD flow.

Pattern A — flat yamls (same config for all environments)

k8s/{service}/
  .env             # configmap env vars
  yamls/
    deployment.yaml
    service.yaml
    (cronjob.yaml, etc.)

Use this when the service has identical configuration across all environments.

Pattern B — per-environment yamls

k8s/{service}/
  .env
  yamls/
    custom/
      dev/
        deployment.yaml
        service.yaml
      rc/
        deployment.yaml
        service.yaml
      sandbox/
        deployment.yaml
        service.yaml
      prod/
        deployment.yaml
        service.yaml

Use this when environments need different deployment specs (e.g., replicas, resources, env-specific env vars beyond the configmap).

How deploy_service_jenkins.sh detects the pattern

The script logic on the kops server is:

  1. First tries yamls/*.yaml (flat). If the folder doesn't exist or has no yamls, produces a grep: No such file or directory warning and continues.
  2. Then applies yamls/custom/{env}/*.yaml — logs "Applying k8s custom yamls" and runs kubectl apply on those files for the current environment.

This is universal for all services — no special flag or Jenkins configuration needed. Any service that adds yamls/custom/{env}/ will automatically get per-environment yamls applied on the next deploy.

Script lives on the kops server, not in git

The actual logic is in /var/local/buildscripts/deploy_service_jenkins.sh on each kops server (one per environment). Not in any git repo — changes must be replicated manually across dev, rc, sandbox, prod kops servers.

Don't mix both in the same service

The script tries flat first then custom — if both exist, both get applied, which can cause unexpected overrides. Pick one pattern per service.

See also

Tags

deploy #kubernetes #yamls #ops-scripts #kops