This demo will walk you through how to stand up a kind cluster and bootstrap Flux into it and deploy an application using Flux.
A basic understanding of Git and Docker/containers, A GitHub account, Docker Desktop installed, KIND installed, kubectl installed, and Flux CLI installed
-
Install Flux CLI and Kind (If not using a mac you can find installation instructions on both project's getting started guides)
$ brew install fluxcd/tap/flux $ brew install kind
-
Create local demo cluster
$ kind create cluster --name flux (took 37s)
-
Make Personal Access Token for creating repositories
- Check all permissions under repo
- Copy PAT to buffer
-
Export env vars locally
$ read -s GITHUB_TOKEN [paste PAT] $ export GITHUB_TOKEN=$GITHUB_TOKEN $ export GITHUB_OWNER=<your GitHub>
-
Simple bootstrap:
$ flux bootstrap github \ --owner $GITHUB_OWNER \ --personal \ --private \ --repository flux-demo \ --path=clusters/my-cluster ► connecting to github.com ✔ repository "https://github.com/priyanka-ravi/flux-demo" created ► cloning branch "main" from Git repository "https://github.com/priyanka-ravi/flux-demo.git" ✔ cloned repository ► generating component manifests ✔ generated component manifests ✔ committed sync manifests to "main" ("8122eb8f6cd0c520a757aafde01462946e2b07e8") ► pushing component manifests to "https://github.com/priyanka-ravi/flux-demo.git" ► installing components in "flux-system" namespace ✔ installed components ✔ reconciled components ► determining if source secret "flux-system/flux-system" exists ► generating source secret ✔ public key: ssh-rsa **** ✔ configured deploy key "flux-system-main-flux-system-./clusters" for "https://github.com/priyanka-ravi/flux-demo" ► applying source secret "flux-system/flux-system" ✔ reconciled source secret ► generating sync manifests ✔ generated sync manifests ✔ committed sync manifests to "main" ("06360186166df1ebbba33b5be07bea60b77e39f1") ► pushing sync manifests to "https://github.com/priyanka-ravi/flux-demo.git" ► applying sync manifests ✔ reconciled sync configuration ◎ waiting for Kustomization "flux-system/flux-system" to be reconciled ✔ Kustomization reconciled successfully ► confirming components are healthy ✔ source-controller: deployment ready ✔ kustomize-controller: deployment ready ✔ helm-controller: deployment ready ✔ notification-controller: deployment ready ✔ all components are healthy (took 1m12s)
-
Clone the newly created git repo to your local workspace
$ git clone git@github.com:$GITHUB_OWNER/flux-demo.git $ cd flux-demo
-
Make directory for the new tenant files and export create tenant
$ mkdir -p ./clusters/my-cluster/test $ flux create tenant test --with-namespace=test --export >> ./clusters/my-cluster/test/rbac.yaml $ cat ./clusters/my-cluster/test/rbac.yaml
-
Fork podinfo-deploy repo - how to fork a repo
-
Create source and kustomization into sync.yaml file
$ flux create source git podinfo \ --namespace=test \ --url=https://github.com/$GITHUB_OWNER/podinfo-deploy \ --branch=main \ --export > ./clusters/my-cluster/test/sync.yaml $ flux create kustomization podinfo \ --namespace=test \ --source=GitRepository/podinfo \ --path="./" \ --export >> ./clusters/my-cluster/test/sync.yaml $ cat ./clusters/my-cluster/test/sync.yaml $ git add . $ git commit -m "Add test namespace podinfo sync.yaml" $ git push $ flux reconcile ks flux-system --with-source $ flux get source git -A $ flux get ks -A
-
Port forward the podinfo application to access it
$ kubectl port-forward service/frontend 9898:9898 --namespace test
-
Change in frontend/deployment.yaml the UI color to 888888
env: - name: PODINFO_UI_COLOR value: "#888888"
$ flux reconcile -n test ks podinfo --with-source
NOTE: You may have to kill and restart the previous port-forward command.
$ kubectl delete deployment/frontend -n test
$ kubectl get pods -n test -w