I used this to teach myself how FluxCD can work with helm in an isolated environment without using GitHub, Gitlab, etc...
Typically, FluxCD will monitor a git repository on one of the big hosted sites. You can use GitHub, for example. Really it doesn't care what you use so long as its accessible via web request. FluxCD watches a repository for changes in Declarative YAML files making up the state of a Kubernetes Cluster; pods, deployments, etc.. Whenever there is a change it'll pull the change and make the state of the cluster match the state of what's declared in the git repository. In addition to declarative YAML files, it can also do the same thing for helm releases.
Without Using GitHub, one can directly create and modify the HelmRelease Custom Resource Definition (CRD) to get flux to update a Helm release. That's what this exercise seeks to accomplish.
- Docker Desktop for Windows installed & Kubernetes turned on.
- WSL2 + Ubuntu installed
- Helm installed in WSL (v3.12.0)
- Helm Push plugin installed
- Nginx Ingress controller installed to Kubernetes cluster
- Windows ETC hosts file must have "mypc.local" as an alias with "host.docker.internal" (NOT 127.0.0.1 or localhost)
- mkdir charts
- chmod 777 charts
- docker compose up -d
- cd simple_app
- ./build_image_versions.sh
NOTE: This also pushes to the local docker registry.
- cd helm-app
- helm repo index .
- helm package .
- helm repo add chartmusuem http://localhost:8080
- helm cm-push ./helm-app-0.1.0.tgz chartmusuem
- helm repo update
- helm search repo chartmuseum
- helm install helm-app chartmuseum/helm-app
- Open up a browser and go to "mypc.local"
NOTE. Uninstall before proceeding with "helm uninstall helm-app"
- cd fluxcd
- ./install.sh
- open up setup_fluxcd.sh. Update the CHARTMUSEUM IP address to be the same IP as an alias with "host.docker.internal" in windows host file. Massively important!
- ./ setup_fluxcd.sh
- Open up a browser and go to "mypc.local" again.
- cd helm-app
- Open Chart.yaml and change "version: 0.1.0" to "version: 0.2.0"
- Open templates/deployment.yaml and change "image: localhost:9001/simple_app:v1" to "image: localhost:9001/simple_app:v2"
- helm cm-push ./helm-app-0.2.0.tgz chartmuseum
- Update the HelmRelease Object: kubectl edit HelmRelease -n flux-system helm-app-hr
- In the editor, find "verison: 0.1.0" and change it to "version: 0.2.0"
- save and exit.
- Now, in the web browser, observe that fluxcd automatically updated the helm chart and the "Version #" in the text has changed from 1 to 2.
- Would like to use gitea as a way to host an air-gapped git repo and have FluxCD watch it instead of having to directly modify HelmRepository CRD.