Ravindra BagaleCourses & study guides मराठी

Chapter 86: Argo CD (GitOps)

DevOps

86.5 Multi-env — apps of apps or ApplicationSet

Story. A Razorpay-style platform team in Bengaluru had shop-api on dev, stage and prod. They did not want three hand-written Application copies forever. First they used an "app of apps": one root Application pointed at a folder of Application YAMLs. Later they switched busy products to ApplicationSet so one generator created Applications per environment from a list.

Root app or ApplicationSet creates child Applications for dev, stage and prod.
Root app or ApplicationSet creates child Applications for dev, stage and prod.

Why

Copy-pasting Application YAML for every env drifts. Generators keep the pattern in one place.

What

  • App of apps — One Application whose path contains other Application manifests.
  • ApplicationSet — A controller that generates Applications from a generator (list, git, cluster, matrix…).
  • Per-env values — Different path, targetRevision or Helm value files per environment.

How

  1. Put each env folder under something like envs/dev, envs/stage, envs/prod.
  2. Start with three Applications or one app-of-apps folder.
  3. Move to ApplicationSet when the list of apps grows.

Example 1: Three destinations (idea)

apps/shop-api/          # base manifests or chart
envs/dev/values.yaml
envs/stage/values.yaml
envs/prod/values.yaml

What it shows: Same chart, different values per env — same idea as Helm value files from chapter 85.

Example 2: ApplicationSet list generator (awareness)

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: shop-api
  namespace: argocd
spec:
  generators:
    - list:
        elements:
          - env: dev
            ns: shop-dev
          - env: stage
            ns: shop-stage
          - env: prod
            ns: shop-prod
  template:
    metadata:
      name: 'shop-api-{{env}}'
    spec:
      project: default
      source:
        repoURL: https://git.example.com/shop/deploy.git
        targetRevision: HEAD
        path: apps/shop-api
        helm:
          valueFiles:
            - ../../envs/{{env}}/values.yaml
      destination:
        server: https://kubernetes.default.svc
        namespace: '{{ns}}'

What it shows: One template expands to three Applications. Learn list generator before matrix generators.

Ravindra Bagale's Tip

Master one Application end to end before ApplicationSet. Generators hide mistakes until sync fails in three envs at once.

Quick quiz

Q1. What is an app of apps?

A root Application that deploys other Application manifests from Git.

Q2. What does ApplicationSet do?

It generates many Applications from a template and generators.

Q3. How do envs usually differ?

Different namespaces, value files or target revisions.

Did you understand? Let us try it once more.