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:
- 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
- An ArgoCD
Applicationmanifest that:- Deploys the
bitnami/nginxchart (or any public Helm chart) - References environment-specific values from the
envs/staging/directory - Enables automated sync with
selfHeal: trueandprune: true - Sets a sync retry policy with backoff (5 retries, 5s initial delay, 2x factor, 3m cap)
- Deploys the
- Demonstrate drift detection by manually modifying the live deployment (e.g.,
kubectl scaleorkubectl edit) and capturing ArgoCD restoring the declared state. - 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
- ArgoCD Application manifest includes
selfHeal: true,prune: true, and retry policy - Manual drift (e.g., replica count change via kubectl) is automatically corrected within one sync cycle
- Rollback to a previous revision succeeds via
argocd app rollbackor the UI history panel - Environment-specific values are cleanly separated in
envs/staging/andenvs/production/
Task 2 — FluxCD HelmRelease with Encrypted Secrets
Configure a FluxCD-managed deployment that uses a HelmRelease resource with SOPS-encrypted secrets. Your deliverables:
- A
HelmRepositorysource pointing to a public chart repository (e.g., Bitnami). - A
HelmReleasemanifest that:- References the
HelmRepositorysource and pins to a specific chart version - Uses
valuesFromto pull values from a Kubernetes Secret - Configures remediation: on install failure, retry 3 times; on upgrade failure, rollback automatically
- Sets a
spec.intervalof5mfor reconciliation
- References the
- 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. - A
Kustomizationresource 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
HelmReleasereferences a pinned chart version and includes remediation with rollback on upgrade failurevaluesFromcorrectly references a Secret for sensitive configurationsecrets.enc.yamlis encrypted with SOPS (age or GPG) and does not contain plaintext secrets- FluxCD
Kustomizationincludesdecryptionconfiguration pointing to the SOPS key - All manifests pass
kubectl apply --dry-run=clientvalidation
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:
- Write an
ApplicationSetmanifest 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
- 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
- Use
- Add a sync wave annotation strategy: dev deploys first (wave 0), staging second (wave 1), production last (wave 2).
- Document what happens when you:
- Add a fourth cluster to the list generator
- Remove a cluster from the list generator (explain the
preserveResourcesOnDeletionpolicy) - Change the chart version — how does the rollout propagate?
Self-check
ApplicationSetuses a list generator with 3+ targets and parameterized template- Each generated Application deploys to the correct namespace with the correct replica count
- Sync wave annotations are present to enforce deployment ordering
- Written explanation covers adding/removing targets and the
preserveResourcesOnDeletionpolicy
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 |