Debugging with FluxCD
FluxCD is a powerful GitOps tool that automates deployments in Kubernetes. If things don’t go as planned, having an understanding of how to debug the issues can save valuable time. This guide offers insights into debugging common FluxCD resources such as Sources, Kustomizations, and Helm Releases using Makefile targets.
Debugging Sources
GitRepository
-
Check the Source Status: Use the Makefile target
make sources-status
to get a list of all sources and their statuses. -
Check for Failing Sources: Use the Makefile target
make sources-check-failing
to get a list of all failing sources. -
Logs: Inspect the logs of the Source Controller using the Makefile target
make debug
. -
Validate Source Configuration: Ensure that the
.spec
field in your GitRepository or HelmRepository manifests is correctly configured, pointing to the right URL and branch.
Debugging Kustomizations
-
Check the Kustomization Status: Use the Makefile target
make kustomization-status
to get the status of all kustomizations. -
Check For Failing Kustomizations: If you want to check if any Kustomizations are failing, use the
make kustomization-check-failing
target. -
Logs: View the logs of the kustomize-controller using the Makefile target
make debug
. -
Check Dependencies: Ensure that the Kustomization’s dependencies like Sources are in the right state and correctly set up.
-
Validate Kustomization Files: If a Kustomization points to a specific path in a git repository, validate it using
make kustomization-build DIR=<path-to-dir>
.
Debugging Helm Releases
-
Check the Flux Helm Releases Status: To get a list of all Flux Helm Releases and their status, use the
make helm-status
target. -
Check For Failing Flux Helm Releases: If you want to check if any Flux Helm Releases are failing, use the
make helm-check-failing
target. -
Logs: Check the logs of the helm-controller using the Makefile target
make debug
. -
Validate Helm Values: Ensure that the
.spec.values
in your HelmRelease manifest is correctly configured. Look for any missing or incorrectly set values that the Helm chart might require. -
Dependencies: Confirm that the HelmRelease’s dependencies like chart sources are available and in a healthy state.
Remember, understanding the relationship between these resources and their dependencies is key. Debugging typically involves ensuring that the pipeline, from source through kustomization to helm release, is set up and functioning properly.