fluxctl - Manage Kubernetes deployments via CLI
Control and automate deployments with $ fluxctl, a handy command line utility that talks to Weave Flux, our continuous delivery operator for Kubernetes.
Understanding Core Kubernetes Concepts & Components
Helm Charts in Kubernetes
How to Deploy and Access the Kubernetes Dashboard
Weave Flux is the Kubernetes GitOps operator (read more about continuous delivery with GitOps), that manages deployments for you. If you are entirely new to Weave Flux, you might want to check out our get started tutorial or our guide for Helm users.
fluxctl is a command-line tool that can talk to Weave Flux - it makes it very easy to manage, automate and even roll back deployments.
Installing fluxctl just became easier!
On Mac OS
If you use Weave Flux in your cluster and you’re on a Mac, it just became a lot easier to interact with Flux on the command line. Simply run
brew install fluxctl
and you’re good to go
On Arch Linux
Install the fluxctl-bin package from the AUR:
git clone https://aur.archlinux.org/fluxctl-bin.git cd fluxctl-bin makepkg -si
(Thanks Simon Weald for making this available for Arch!)
If none of the above work for you, simply grab the most recent fluxctl build (for Mac, Linux or Windows) from our release page.
Here’s what fluxctl lets you do
After you have installed Weave Flux agent and fluxctl, the first step is getting the public key from Weave Flux, so you can add it as a deploy key to e.g. Github.
Simply run the command:
Which displays something like this:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvzeeIcV31fcIeR4YZR6xu8Ojbdc1KrfQoVf zYZb8QbDPmY2Bse5xxXWsoHg8IJCWgK+t6IZGoMeoppWz9H3zNgBK74gF4ZPVxfbn3 985zu8935z3eBJ5G5eQW6ZBsF0so/YcsyuanwhVknXvpP3yU66UPQhr0qMCQ9QxvBO dLF/7Tk5oVdQ5n92IziREKl2OtnshUBFDVG5bHGbbZXENrgx2m2YUxVEB9QjbwBSpz rV4K6yJaGExzodFFdPnWmqZT5Aw/o1liYB5PPFeL4D5B2qivqjGzH3GoiaiuLPtHmI FMYO3LavwxgwzE0qlBWcI925nU46/GMJKqRf8eF
Add this public key to your repository as your deploy key and you’re good to go. (For this blog post I simply forked the flux-example repository.)
Now Weave Flux will start watching your image registry and deploying services to the cluster. With fluxctl you can find out what the state of your deployments are and the available releases.
Displays something like this:
CONTROLLER CONTAINER IMAGE RELEASE POLICY default:deployment/flux flux quay.io/weaveworks/flux:1.7.0 ready default:deployment/helloworld helloworld quay.io/weaveworks/helloworld:master-a000001 ready sidecar quay.io/weaveworks/sidecar:master-a000001 default:deployment/memcached memcached memcached:1.4.25 ready
Or list images with:
fluxctl list-images -c default:deployment/helloworld
CONTROLLER CONTAINER IMAGE CREATED default:deployment/helloworld helloworld quay.io/weaveworks/helloworld --> master-07a1b6b 27 Dec 17 14:06 UTC master-a000004 13 Nov 17 14:57 UTC master-a000003 13 Nov 17 14:45 UTC master-9a16ff945b9e 20 Jul 16 13:19 UTC master-b31c617a0fe3 20 Jul 16 13:19 UTC master-a000002 12 Jul 16 17:17 UTC master-a000001 12 Jul 16 17:16 UTC sidecar quay.io/weaveworks/sidecar --> master-a000002 23 Aug 16 10:05 UTC master-a000001 23 Aug 16 09:53 UTC
So it looks like our helloworld deployment is not on the latest available image version.
Automating deployments, and getting deployments automatically synced to the cluster is as easy as this:
fluxctl automate --controller=default:deployment/helloworld
Since we added the deploy key to Github at the very start, the config change is live in our config repository as well. In true GitOps fashion, you now have an audit trail and can easily re-deploy current status in case of disaster recovery or redeploy an identical environment.
If you wanted to deploy only a subset of releases to your cluster, you can do that too. You can filter images by running:
fluxctl policy --controller=default:deployment/helloworld --tag-all='glob:master-*'
You can either use glob, semver or regexp for filtering.
fluxctl is a great tool, and it offers a lot more than what we have covered in the post. Find more information about fluxctl in our docs.
If you want to know more, join to us in the #flux Slack channel. Any other help, feedback, and questions are always welcome as well!