Module 8 · Project 08 · Deploy with GitOps and Argo CD · Lesson 29 of 48

Environments, promotion and secrets

Lay out dev, staging and production in the config repo with Kustomize or Helm values, promote releases with pull requests, and keep secrets out of Git.

In this lesson · about 30 minutes

  • Structure a config repo with Kustomize overlays or Helm values per environment
  • Promote a release from staging to production with a pull request
  • Handle secrets and notifications in a GitOps setup

One base, many environments

Each environment needs nearly the same YAML with a few differences: replica count, image tag, host name, resource sizes. Two common ways to avoid copy-and-paste:

Kustomize (built into kubectl): a base plus small overlays that patch it.

notes-config/
├── base/
│   ├── deployment.yaml  service.yaml  ingress.yaml  hpa.yaml
│   └── kustomization.yaml
└── environments/
    ├── dev/         kustomization.yaml   # replicas 1, tag 1.5.0-rc1
    ├── staging/     kustomization.yaml   # replicas 2, tag 1.5.0
    └── production/  kustomization.yaml   # replicas 4, tag 1.4.0

# environments/production/kustomization.yaml
resources:
  - ../../base
namespace: notes
images:
  - name: ghcr.io/you/notes-api
    newTag: 1.4.0
patches:
  - target: { kind: Deployment, name: notes-api }
    patch: |
      - op: replace
        path: /spec/replicas
        value: 4

Helm (Project 07): one chart, plus values-dev.yaml, values-staging.yaml and values-production.yaml. Argo CD can render either.

Promotion is a pull request

  1. CI builds 1.5.0 and opens a PR changing the dev tag. It's merged automatically; Argo CD deploys it.
  2. Tests pass in dev, so a PR changes staging to 1.5.0. A teammate reviews it.
  3. After staging soaks for a day, a PR changes production. Branch protection requires an approver from the release team.

The image is identical in every step (build once, deploy many). The only thing that moves is one line in Git, and the config repo's history shows exactly when each version reached each environment. Tools like Argo CD Image Updater or Renovate can open those PRs for you.

Rollback

Production is broken after the 1.5.0 PR merged: git revert the merge commit and push. Argo CD syncs back to 1.4.0 within a minute or so. Avoid clicking "rollback" in the Argo CD UI as your main habit: with auto-sync on, Git still says 1.5.0, and it would be re-applied. Git must say what you want.

Secrets in a GitOps world

Everything is in Git, but secrets must never be in Git in plain text. Choose one:

  • Sealed Secrets: encrypt the secret with the cluster's public key; only the controller in the cluster can decrypt it. The encrypted file is safe to commit.
  • External Secrets Operator: commit a reference ("fetch notes/db-password from AWS Secrets Manager"), not the value.
  • SOPS: encrypt values in the file with a cloud KMS key, decrypted during sync.

Knowing what happened

Argo CD Notifications can post to Slack or email on sync success, sync failure and degraded health, so the team sees every deploy without watching a dashboard. Combine that with the monitoring in Project 09.

Sorting drill

GitOps habit or anti-pattern?

Sort each practice.

  • Promote to production with a reviewed PR that changes the image tag
  • Hot-fix production with kubectl edit and leave it
  • Commit a SealedSecret instead of a plain Secret
  • Give CI cluster-admin credentials to run helm upgrade
  • Roll back with git revert
  • Use the image tag latest in production
  • Separate config repo with branch protection on main

0 of 7 sorted

Hands-on lab (simulated terminal)

Lab: promote and roll back

A clone of the config repo with Argo CD watching it, and the argocd CLI logged in.

Step 1 of 5. Type each command and press Enter. Nothing runs on your computer.

Lab: promote and roll back

1. Check the production Application's status.

you@laptop:~/notes-config$

Check your understanding0 of 3 correct

Question 1

1.With auto-sync on, you roll back using the Argo CD UI only. What's the risk?

Question 2

2.How do you keep a database password out of plain text in the config repo?

Question 3

3.What usually changes when a release is promoted from staging to production?

Key terms

Say the meaning to yourself, then tap a card to check.

Quiz score: 0 of 3

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. The labs are simulations: no real servers are touched. When you build the projects yourself, use a practice virtual machine or a free-tier cloud account you control, watch your cloud spending, and never run cleanup or delete commands on a machine you care about. Tool names belong to their owners; versions and output are shown for learning and may differ slightly from yours. Read-aloud and the whiteboard voice use your device's built-in voices.