Flux CD
Other tools
- flux-local tools and libraries for managing a local flux gitops repository focused on validation steps to help improve quality of commits, PRs, and general local testing.
Install
Flux cli tool:
Terraform
Issues:
Manual
Upgrade/install flux on cluster:
flux install --network-policy=false --watch-all-namespaces=true --namespace=flux-system
Usage
Get all flux resources:
flux get all
Reconcile all helm releases
flux get -A helmrelease --no-header | \
awk -F' ' '{system("flux reconcile -n " $1 " helmrelease " $2)}'
or
kubectl get -A hr --template \
'{{range .items}}{{.metadata.namespace}}/{{.metadata.name}}{{"\n"}}{{end}}' | \
awk -F'/' '{system("flux reconcile -n " $1 " helmrelease " $2)}'
CRDs
Troubleshooting
Test flux resource locally
Beware: Doesn't render valuesFrom:
fields!
yq .spec.values media/transmission-helmrelease.yaml > /tmp/values.yml
helm -n test template -f /tmp/values.yml transmission truecharts/transmission
upgrade retries exhausted
If you get helm-controller reconciliation failed: upgrade retries exhausted
:
flux suspend helmrelease nextcloud -n oas-apps
flux resume helmrelease nextcloud -n oas-apps
another operation (install/upgrade/rollback) is in progress
Helm upgrade failed: another operation (install/upgrade/rollback) is in progress
See https://open.greenhost.net/stackspin/wordpress-helm/-/issues/119
Solved by helm rollback and flux reconciliation of the helmRelease.
First list all helm releases in the namespace and watch for the pending-install
status ones:
$ helm -n stackspin-apps ls --all
NAME NAMESPACE REVISION UPDATED STATUS ...
wordpress stackspin-apps 4 2022-04-19 13:57:09.108314695 +0000 UTC pending-install ...
Then do a helm rollback to the revision before (in this case 3
):
helm -n stackspin-apps rollback wordpress 3
HelmChart 'flux-system/wireguard-wireguard-server' is not ready
Note: There are two helmchart
resources:
helmcharts.helm.cattle.io
(default, when uses withhelmcharts
)
-
helmcharts.source.toolkit.fluxcd.io
(use this one!)kc get helmcharts.source.toolkit.fluxcd.io -A
"Cannot delete kustomization when it is running health checks"
from Cannot delete kustomization when it is running health checks
The only workaround is to suspend the Kustomization, then restart the controller by killing its pod. When the controller starts it will no longer try to run the health check again since it receives the new object that's suspended.
Use different branch for Stackspin
kc -n flux-system patch gitrepo stackspin -p "{\"spec:\": {\"ref\": {\"branch\": \"nextcloud_1030\" }}}"