A small repo with the simplest .yaml manifests to test FluxV2 right away on your cluster
Whether you are migrating from deprecated FluxV1 or decided to go GitOps by testing FluxV2, the existing documentation can be intimidating. You may want to quickly test FluxV2 without using the CLI and its default behaviour of bootstraping a new repo containing your Flux setup.
That was my case so I created this repo to help you quickly get hands on by providing the simplest manifests template.
I hope it will help you discover the GitOps philosophy and start great things following it!
- If you are already using a GitOps agent on your Kubernetes cluster, deactivate the reconciliation for the namespace you want to test
- All the entities related to the namespace you are testing are already defining it in their manifest (
metadata: / namespace:
) - All the entities related to the namespace you are testing are inside a folder
- All the entities have been created through manifests (no usage of Helm charts)
- Make sure that the namespace
flux-system
does not exist in your cluster
- kubectl apply the file install.yaml
- it's a copy of the official manifest for Flux v2.1.1
- that will create the namespace
flux-system
and setup the 5 basic components of FluxV2 : https://fluxcd.io/flux/components/
- for your basic test, you only need to use Source and Kustomize controllers
- first configure the Secret secrets/your-git-user.yaml accordingly
- kubectl apply this file
- then configure the sources/your-repo.yaml manifest with the information about the repo describing your cluster state
- you can explore easily all available options by installing Flux CLI and run
flux create source git --help
- the
--explore
option is particularly useful to generate the manifest you want to use - kubectl apply this file
- you can explore easily all available options by installing Flux CLI and run
- tail the logs of the pod
source-controller
in theflux-system
namespace and make sure that the pull is working - now configure the reconcilers/your-namespace.yaml manifest with the information about the folder of the namespace you want to watch with FluxV2 now
- you can explore easily all available options by installing Flux CLI and run
flux create kustomization --help
- the
--explore
option is particularly useful to generate the manifest you want to use - kubectl apply this file
- you can explore easily all available options by installing Flux CLI and run
- tail the logs of the pod
kustomize-controller
in theflux-system
namespace and make sure that the reconciliation is working - make a test by commit / pushing a modification in the repo describing your cluster state
- check the reconciliation happening in the logs of the
kustomize-controller
pod in theflux-system
namespace - congratulations you are running FLuxV2!
When a issue in happening during the repo pull or the reconciliation of a namespace folder, you can be easily notified on Slack like this (using the Notification controller):
- create a new Slack app on your workspace and configure the Secret secrets/your-slack-app-token.yaml accordingly
- kubectl apply this file
- put the Slack channel name you want to use in notifications/your-slack-channel.yaml
- kubectl apply this file
- customize the file notifications/alerts.yaml with YOUR_CLUSTER_NAME
- you can explore easily all available options by installing Flux CLI and run
flux create alert --help
- the
--explore
option is particularly useful to generate the manifest you want to use - kubectl apply this file
- you can explore easily all available options by installing Flux CLI and run
- tail the logs of the pod
notification-controller
in theflux-system
namespace - make a test by commit / pushing a modification with a typo in the repo describing your cluster state
- make sure the alert is detected in the logs and that your Slack channel is updated with this error message
- commit / push the typo fix
- you are all set now!
- Documentation about the GitOps Toolkit components Flux V2 is using : https://fluxcd.io/flux/components/
- Migrating from Flux v1 to v2 with Leigh Capili : https://www.youtube.com/watch?v=vwvTwLQhXVI
- excellent walkthrough
- Using Flux V2 to sync Helm charts : https://fluxcd.io/flux/components/helm/