This repo provides a demonstration of using a Compose file to define an application running in Kubernetes and deployed using Flux. It is making use of my compose-deployer Helm chart, but it can easily be swapped out with any other tooling.
The general idea is to have a pipeline that converts the manifests and commits those back to the repo where Flux can pick them up. In this example, we are using GitHub Actions, which can easily be swapped out with whatever CI system you might be using.
If you want to exercise the full demo, you will want to do the following:
Fork this repo (which will let you make changes to the files)
flux/manifests.yamlfile, adjust the
urlfor the GitRepository to point to your forked repo
Clone the project
If you need Traefik/Flux to be installed, you can do so using the manifests in the
kubectl apply -k ./pre-reqs
Now, we are going to define the
Kustomizationobjects that provide config to Flux to watch and apply the manifests in our repo. Apply the manifests in the
kubectl apply -f ./flux
After a moment, you should see the voting app up and running. It might take a minute to pull all of the images.
> kubectl get pods db-677f6fd579-8vcmq 1/1 Running 0 2m redis-6c7f9657c-vmq75 1/1 Running 0 2m result-66b4856489-7swvq 1/1 Running 0 2m vote-65d4d9594f-c7d27 1/1 Running 0 2m vote-65d4d9594f-ldd26 1/1 Running 0 2m worker-7497c578cb-4g6xf 1/1 Running 0 2m worker-7497c578cb-9ztgj 1/1 Running 1 2m
You should be able to open http://vote.localhost and see the voting app. Opening http://results.localhost should give you the results page (Chrome auto-resolves *.localhost to localhost, so hopefully it works by default for you).
Make a change to the
docker-compose.ymlfile. A good idea might be is to define the
OPTION_Benvironment variables on the voting app to change what you're voting for. If you push the file, you should see a pipeline get triggered and the app be deployed on your local machine within a moment or two.
When you're ready to tear everything down, simply remove the flux config, which will then remove all of the apps:
kubectl delete -f ./flux
And if you want to remove the Traefik ingress and Flux components, you can do so using this command:
kubectl delete -k ./pre-reqs