To enable GitOps we will be installing the following to our EKS cluster:
In other workshops we have used eksctl enable repo
to install these. However, for this workshop we will be using Helm to install them both as we want access to additional configuration options (specifically reduce the polling period).
Both Flux and Flux Helm Operator will reside in their own namespace. Run the following command to create the namespace:
kubectl create ns flux
Both Flux and Helm Operator are via helm charts from the Flux Chart Repository. Tell Helm about this repository by running the following command:
helm repo add fluxcd https://charts.fluxcd.io
Let’s install Flux using its Helm Chart making sure you replace yourname/my-eks-config.git
with your repo details:
helm upgrade -i flux fluxcd/flux --wait --namespace flux --set git.url=git@github.com:yourname/my-eks-config.git --set git.pollInterval=1m
Let us go through the specified arguments one by one:
There are more arguments and options, please refer to the Flux documentation which details all the flags.
When Flux is installed you will see a message similar to this:
NAME: flux
LAST DEPLOYED: Wed May 20 09:50:15 2020
NAMESPACE: flux
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Get the Git deploy key by either (a) running
kubectl -n flux logs deployment/flux | grep identity.pub | cut -d '"' -f2
or by (b) installing fluxctl through
https://docs.fluxcd.io/en/latest/references/fluxctl#installing-fluxctl
and running:
fluxctl identity --k8s-fwd-ns flux
As indicated by the message we need to add the Flux deploy key to our GitHub repo. Run the following command:
kubectl -n flux logs deployment/flux | grep identity.pub | cut -d '"' -f2
Copy the output from this command (which will start with ssh-rsa
).
Go to the Settings for your git repo and then click Deploy keys.
Click the Add deploy button, enter a title of Workshop
, paste the contents of the key into Key box and make sure you tick Allow write acess:
Click Add key.
Install the CRDs that are needed for HelmRelease:
kubectl apply -f https://raw.githubusercontent.com/fluxcd/helm-operator/master/deploy/crds.yaml
And then install Helm Operator using the helm chart:
helm upgrade -i helm-operator fluxcd/helm-operator --wait --namespace flux --set git.ssh.secretName=flux-git-deploy --set helm.versions=v3