Flux¶
TODO: source private repos
Flux is a tool that automatically ensures that the state of a cluster matches the config in git. It uses an operator in the cluster to trigger deployments inside Kubernetes, which means you don't need a separate CD tool. It monitors all relevant image repositories, detects new images, triggers deployments and updates the desired running configuration based on that (and a configurable policy).
The benefits are: you don't need to grant your CI access to the cluster, every change is atomic and transactional, git has your audit log. Each transaction either fails or succeeds cleanly. You're entirely code centric and don't need new infrastructure.
Install fluxctl¶
Install Flux¶
Deploy Flux - Github¶
Flux Stack¶
- Create github repo
- Generate PAT token in this link
- repo permission
- copy and secure token
- export
- install flux (change owner / repo / path) flux create source git manifests \ --url=ssh://git@github.com/$GITHUB_USER/flux-manifests \ --private-key-file=~.ssh/id_rsa \ --branch main \ --interval 30s \ --export \ | tee apps/flux-source.yaml
flux create kustomization manifests \ --source manifests \ --path "./" \ --prune true \ --interval 5m \ --export \ | tee -a apps/flux-kustomization.yaml
Create files from secrets¶
ssh-keygen -q -N "" -f ./identity ssh-keyscan github.com > ./known_hosts
kubectl create secret generic ssh-credentials \ --from-file=./identity \ --from-file=./identity.pub \ --from-file=./known_hosts
flux create secret git manifests \ --url=https://github.com/renantmagalhaes/flux-manifests \ --private-key-file=./identity ```