Lesson 19 GitOps with Helm
Theme:

Homework

Put GitOps principles into practice by configuring ArgoCD Applications, FluxCD HelmReleases, and a multi-cluster deployment strategy.

Submission: For each task, include the YAML manifests you created, screenshots of the GitOps controller syncing the application, and a brief explanation of your design decisions. Push all manifests to a Git repository.

Task 1 — ArgoCD Application with Drift Detection and Rollback

Set up an ArgoCD Application that deploys a Helm chart and demonstrates drift detection with automatic self-healing. Your setup must include:

  1. A Git repository with the following structure:
gitops-homework/
  apps/
    webapp/
      application.yaml      # ArgoCD Application CRD
  envs/
    staging/
      values.yaml           # staging overrides
    production/
      values.yaml           # production overrides
  1. An ArgoCD Application manifest that:
    • Deploys the bitnami/nginx chart (or any public Helm chart)
    • References environment-specific values from the envs/staging/ directory
    • Enables automated sync with selfHeal: true and prune: true
    • Sets a sync retry policy with backoff (5 retries, 5s initial delay, 2x factor, 3m cap)
  2. Demonstrate drift detection by manually modifying the live deployment (e.g., kubectl scale or kubectl edit) and capturing ArgoCD restoring the declared state.
  3. Perform a rollback using the ArgoCD CLI or UI: deploy a broken change via Git, then roll back to the previous healthy revision.

Self-check

Task 2 — FluxCD HelmRelease with Encrypted Secrets

Configure a FluxCD-managed deployment that uses a HelmRelease resource with SOPS-encrypted secrets. Your deliverables:

  1. A HelmRepository source pointing to a public chart repository (e.g., Bitnami).
  2. A HelmRelease manifest that:
    • References the HelmRepository source and pins to a specific chart version
    • Uses valuesFrom to pull values from a Kubernetes Secret
    • Configures remediation: on install failure, retry 3 times; on upgrade failure, rollback automatically
    • Sets a spec.interval of 5m for reconciliation
  3. A SOPS-encrypted secret file (secrets.enc.yaml) containing at least two sensitive values (e.g., database password and API key). Use either age or GPG for encryption.
  4. A Kustomization resource that decrypts the SOPS secret and feeds it into the HelmRelease.
Tip: If you do not have a cluster with FluxCD installed, you can still complete this task by writing all the manifests and validating them with kubectl apply --dry-run=client -f. For SOPS, install sops and age locally to create the encrypted file.

Self-check

Task 3 — Multi-Cluster ApplicationSet

Design an ArgoCD ApplicationSet that deploys the same Helm chart across multiple clusters (or simulated clusters using namespaces) with per-target overrides. Requirements:

  1. Write an ApplicationSet manifest that uses a list generator with at least three targets:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: webapp-multi
  namespace: argocd
spec:
  generators:
    - list:
        elements:
          - cluster: dev
            url: https://kubernetes.default.svc
            namespace: dev
            replicas: "1"
          - cluster: staging
            url: https://kubernetes.default.svc
            namespace: staging
            replicas: "2"
          - cluster: production
            url: https://kubernetes.default.svc
            namespace: production
            replicas: "3"
  template:
    # ... complete the template
  1. The template must:
    • Use {{cluster}} and {{namespace}} parameters in the Application name and destination
    • Pass {{replicas}} as a Helm parameter override
    • Include a sync policy with automated sync and self-heal
  2. Add a sync wave annotation strategy: dev deploys first (wave 0), staging second (wave 1), production last (wave 2).
  3. Document what happens when you:
    • Add a fourth cluster to the list generator
    • Remove a cluster from the list generator (explain the preserveResourcesOnDeletion policy)
    • Change the chart version — how does the rollout propagate?

Self-check

Grading Rubric

Criterion Points Requirements
Task 1 — ArgoCD drift & rollback 30 Valid Application CRD with self-heal and prune; drift detected and corrected; rollback demonstrated; env-specific values separated
Task 2 — FluxCD + SOPS secrets 35 HelmRelease with pinned version and remediation; SOPS-encrypted secret with age/GPG; Kustomization with decryption config; manifests validate
Task 3 — Multi-cluster ApplicationSet 25 List generator with 3+ targets; parameterized template; sync wave ordering; written analysis of add/remove/update scenarios
Code quality & documentation 10 Clean YAML; meaningful comments; clear repo structure; thorough explanations