DevCloudLab More courses at DevCloudLab.com →
FLUX CD · SECTION 3 · LECTURE 2

DevCloudLab

Deploying applications using Flux CD with Git as the Helm chart source

Section 3, Lecture 2, from the Flux CD course by DevCloudLab.


What you’ll learn

Overview

In this lecture, you learned how to deploy Helm Chart releases to Kubernetes using Flux CD with Git as the source of truth. We covered two approaches to Helm Chart installation:

  1. Local Chart Source: Managing your own chart files and deploying directly from a directory path
  2. Package Repository: Using pre-built, tested charts from repositories like Bitnami

We demonstrated the first approach: creating a Helm Chart, storing its source in a Git repository, and letting Flux CD automatically deploy it using a HelmRelease resource.

Key Concepts

Why separate directories?

HelmRelease Custom Resource

The HelmRelease custom resource tells Flux CD how and when to deploy a Helm Chart:

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: nginx
  namespace: default
spec:
  interval: 1m
  chart:
    spec:
      chart: ./charts/nginx
      sourceRef:
        kind: GitRepository
        name: flux-system
        namespace: flux-system
      interval: 1m

What each field means:

Two Intervals

Understanding the difference is crucial:

The two intervals govern different things: one keeps the running release in line with its definition, the other watches for a new chart.

Complete Working Example

Step 1: Create the Helm Chart

mkdir charts
cd charts
helm create nginx

Step 2: Customize Chart Values

Edit charts/nginx/values.yaml to enable Ingress:

ingress:
  enabled: true
  className: "nginx"
  annotations: {}
  hosts:
    - host: ""
      paths:
        - path: /
          pathType: ImplementationSpecific

Step 3: Create the HelmRelease Manifest

Create clusters/my-cluster/nginx-helm-release.yaml:

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: nginx
  namespace: default
spec:
  interval: 1m
  chart:
    spec:
      chart: ./charts/nginx
      sourceRef:
        kind: GitRepository
        name: flux-system
        namespace: flux-system
      interval: 1m

Step 4: Commit and Merge to Main

git checkout -b nginx-helm-release
git add -A
git commit -m "Adding the Nginx Helm chart and creating the Flux CD Helm Release resource"
git push --set-upstream origin nginx-helm-release

Then create and merge the MR on GitLab.

Step 5: Trigger Reconciliation

flux reconcile kustomization flux-system --with-source

Step 6: Verify Deployment

The Helm install takes a few seconds after the reconcile, so wait for the release to become Ready before reading its status:

kubectl wait --for=condition=Ready helmrelease/nginx -n default --timeout=2m
kubectl get helmrelease
kubectl get pods

kubectl get helmrelease then shows READY as True and a status of Helm install succeeded for release default/nginx.v1 with chart nginx@0.1.0. If you run it the instant the reconcile returns, READY is Unknown and the status reads Running 'install' action. That is the install still in progress, not a failure.

You should also see the Nginx pod running, along with a Service and Ingress in the default namespace.

Common Commands

Command Purpose
helm create <chart-name> Scaffold a new Helm chart with default templates
kubectl get helmrelease List all HelmRelease resources
kubectl describe helmrelease <name> Inspect a HelmRelease and its status
flux reconcile kustomization flux-system --with-source Manually trigger Flux to check for changes
flux logs --all-namespaces --follow View real-time Flux controller logs

Troubleshooting

HelmRelease not creating?

Chart files not found?

Helm chart update not detected?

Further Reading


DevCloudLab

Built by DevCloudLab
Hands-on cloud-native courses: Kubernetes, GitOps, CI/CD and the cloud.
Visit DevCloudLab.com →