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).
Latest version of Flux.
Fluxs own documentation.
├── apps
│ ├── base
│ ├── production
│ └── development
├── infrastructure
│ ├── base
│ ├── production
│ └── development
└── clusters
├── production
└── development
-
Change directory to
clusters/development
-
Create
infrastructure.yaml
flux create kustomization infrastructure \
--source=GitRepository/flux-system \
--path="./flux/infrastructure/development" \
--prune=true \
--interval=1m \
--export > infrastructure.yaml
- Create
apps.yaml
which depends on infrastructure
flux create kustomization apps \
--source=GitRepository/flux-system \
--path="./flux/apps/development" \
--prune=true \
--interval=1m \
--depends-on=infrastructure \
--export > apps.yaml
-
Change directory to
apps/development
-
Create
kustomization.yaml
kustomize create
- Repeat step 5 in
infrastructure/development
-
Change directory to
apps/base/my-app
-
Create 'namespace.yaml' if it does not exist
kubectl create namespace my-app
- Create 'gitrepository.yaml'
flux create source git my-app \
--url=ssh://git@gitlab.com:devops9483002/devops-k8s-toolkit.git \
--branch=develop \
--secret-ref=flux-system \
--export > gitrepository.yaml
- Create 'flux-kustomization.yaml'
flux create kustomization my-app \
--source=GitRepository/my-app.flux-system \
--path="./k8s" \
--prune=true \
--interval=1m \
--namespace=my-app-namespace \
--export > flux-kustomization.yaml
Add flux-system
in --source=GitRepository/my-app.flux-system
if the GitRepository is in another namespace flux-system
for this example.
- Create 'kustomization.yaml'
kustomize create --autodetect
- Commit and push changes to Git