Lesson 19 GitOps with Helm
Theme:
Lesson 19 · Slide 1

GitOps with Helm

Using Git as the single source of truth for Helm-based deployments.

Lesson 19 · Slide 2

GitOps Principles

Notes: GitOps inverts the deployment model: instead of CI pushing to the cluster, an in-cluster agent pulls from Git and converges the live state.

Why Helm + GitOps?

Lesson 19 · Slide 3

ArgoCD — Application CRD

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: oci://registry.example.com/charts
    chart: my-app
    targetRevision: 1.4.0
    helm:
      releaseName: my-app
      valueFiles:
        - values-production.yaml
      parameters:
        - name: image.tag
          value: "v2.3.1"
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
Notes: selfHeal: true reverts manual kubectl changes automatically. prune: true deletes resources removed from Git.
Lesson 19 · Slide 4

ArgoCD — ApplicationSet

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: cluster-apps
  namespace: argocd
spec:
  generators:
    - git:
        repoURL: https://github.com/org/gitops-repo.git
        revision: main
        directories:
          - path: "apps/*"
    - clusters:
        selector:
          matchLabels:
            env: production
  template:
    metadata:
      name: "{{path.basename}}-{{name}}"
    spec:
      project: default
      source:
        repoURL: https://github.com/org/gitops-repo.git
        targetRevision: main
        path: "{{path}}"
      destination:
        server: "{{server}}"
        namespace: "{{path.basename}}"

The Git directory generator creates one Application per subdirectory. The cluster generator fans out across multiple clusters.

Lesson 19 · Slide 5

FluxCD — HelmRelease & HelmRepository

HelmRepository Source

apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
  name: bitnami
  namespace: flux-system
spec:
  type: oci
  url: oci://registry-1.docker.io/bitnamicharts
  interval: 10m

HelmRelease

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: redis
  namespace: caching
spec:
  interval: 30m
  chart:
    spec:
      chart: redis
      version: "18.x"
      sourceRef:
        kind: HelmRepository
        name: bitnami
        namespace: flux-system
  valuesFrom:
    - kind: ConfigMap
      name: redis-values
  values:
    architecture: replication
    replica:
      replicaCount: 3
Notes: valuesFrom lets you pull values from ConfigMaps or Secrets, keeping sensitive data separate from the HelmRelease manifest.
Lesson 19 · Slide 6

Automated Image Updates & Drift Detection

Flux Image Automation

apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageUpdateAutomation
metadata:
  name: flux-system
  namespace: flux-system
spec:
  interval: 30m
  sourceRef:
    kind: GitRepository
    name: flux-system
  git:
    checkout:
      ref:
        branch: main
    commit:
      author:
        name: fluxcdbot
        email: flux@example.com
      messageTemplate: "chore: update images"
    push:
      branch: main
  update:
    path: ./clusters/production
    strategy: Setters
Lesson 19 · Slide 7

Secrets, Rollbacks & Helm in CI

Secrets in GitOps

Rollback Strategies

Helm Template in CI vs Native Helm

Notes: Rendered manifests give cleaner PR diffs but lose Helm release metadata. Native Helm support preserves release history and hooks.
Lesson 19 · Slide 8

Summary

Next: Lesson 20 →

1 / ?