-
Install Flux CLI and Kind:
$ brew reinstall flux kind $ kind --version kind version 0.10.0 $ flux --version flux version 0.9.1
-
Create local demo cluster
$ kind create cluster (took 32s)
-
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
-
Simple bootstrap:
$ flux bootstrap github --owner scottrigby --personal \ --repository ggg-demo \ --path=flux/boot ► connecting to github.com ✔ repository created ✔ repository cloned ✚ generating manifests ✔ components manifests pushed ► installing components in flux-system namespace … ◎ verifying installation ✔ install completed ► configuring deploy key ✔ deploy key configured ► generating sync manifests ✔ sync manifests pushed ► applying sync manifests ◎ waiting for cluster sync ✔ bootstrap finished (took 39s)
-
Clone the newly created git repo to your local workspace
$ cd ~/code/github.com/scottrigby $ git clone git@github.com:scottrigby/ggg-demo.git $ tree . ├── README.md └── flux └── boot └── flux-system ├── gotk-components.yaml ├── gotk-sync.yaml └── kustomization.yaml
-
Create a namespace if you wish for Traefik (files can be organized however you like)
$ mkdir flux/boot/traefik $ echo 'apiVersion: v1 kind: Namespace metadata: name: traefik' > flux/boot/traefik/ns.yaml
-
Create a Helm Source Custom Resource locally
$ flux create source helm traefik \ --url https://helm.traefik.io/traefik \ --namespace traefik \ --export > flux/boot/traefik/HelmRepo.yaml
-
Create a Helm Release Custom Resource locally
$ flux create hr traefik \ --interval=1m \ --source HelmRepository/traefik \ --chart traefik \ --chart-version 9.18.2 \ --namespace traefik \ --export > flux/boot/traefik/HelmRelease.yaml
-
File structure
$ tree . ├── README.md └── flux └── boot ├── flux-system │ ├── gotk-components.yaml │ ├── gotk-sync.yaml │ └── kustomization.yaml └── traefik ├── HelmRelease.yaml ├── HelmRepo.yaml └── ns.yaml
-
From this point on, you are doing GitOps by interacting with your Desired State source:
$ git add flux/boot/traefik $ git commit -m "Add traefik ingress controller" $ git push
-
Copy
traefik
namespace dir we already made:$ cp -r flux/boot/traefik flux/boot/cert-manager
-
File structure
$ tree . ├── README.md └── flux └── boot ├── cert-manager │ ├── HelmRelease.yaml │ ├── HelmRepo.yaml │ └── ns.yaml ├── flux-system │ ├── gotk-components.yaml │ ├── gotk-sync.yaml │ └── kustomization.yaml └── traefik ├── HelmRelease.yaml ├── HelmRepo.yaml └── ns.yaml
-
Manually edit files
-
Git add, push, and show it automatically work
-
Podinfo
-
- File structure
$ tree . ├── README.md └── flux └── boot ├── cert-manager │ ├── HelmRelease.yaml │ ├── HelmRepo.yaml │ └── ns.yaml ├── flux-system │ ├── gotk-components.yaml │ ├── gotk-sync.yaml │ └── kustomization.yaml ├── podinfo │ ├── HelmRelease.yaml │ ├── HelmRepo.yaml │ └── ns.yaml └── traefik ├── HelmRelease.yaml ├── HelmRepo.yaml └── ns.yaml
-
Delete local cluster
$ kind delete cluster
-
Delete demo repo & PAT from GitHub