fluxcd - getting started
Ensure you have installed the followings
- kubernetes
- flux cli
- github account
Fluxcd will integrate with your github and apply any changes in the repository to deploy application to your k8s cluster.
In order to do that, we have to bootstrap your application first. This will install flux core component such as source-controller, helm controller, kustomization controller and notification-controller.
To deploy an app from git you need a repository. Flux can create that for you
Then you need to enter your PAT tokens for github. Once you have done that, please enter the following commands to start working with your repository.
Creating your GitRepository source - this will be your source code or codebase where your application will be deploying and in this instance it is using "https://github.com/stefanprodan/podinfo"
which is similiar to this yaml below:-
Committing your code change.
Next, create a deployment/implementation yaml by running the following command. It is saying use kustomize to do the deployment and as you will see below, there's a few options that you can configure for example to bump up the replicas.
This will create the equivalent yaml.
Then to test your code changes:-
Flux will auto-sync and deploy your app.
You can also check the flux sync status by running the following command (really confusing tho) - when i looked at it, i was under the impression that my deployment didn't work - mainly because of the displaced text outputs.
flux get kustomizations --watch
Your podinfo will be deployed to the default namespace. You can run the following command to get those details
kubectl get pods -n default
Let's say you wanted to change this to a helm release instead. You can instead change the yaml to the followings.
Convert git repository to helm repository
Then change kustomization to helm release. Commenting out the code changes that we had earlier.
Commit this and wait for it to sync. You should have 2 podinfo replica now.
Some tips on debugging.
Sometimes it can be confusing when the deployment doesn't work. By committing and waiting is not an ideal way of dealing with it.
What you can do is run kubectl apply to test out those HelmRepository or even HelmRelease before even committing it and always checks to logs from HelmRelease controller. If it is kustomization, you need to check Kustomization controller.
Comments