Weave Cloud deploy consists of two parts: the fluxd daemon and the fluxctl service. The fluxd daemon is deployed to the cluster where it listens for changes being pushed through git and when it detects a change, it updates the cluster and any images accordingly. fluxctl is the command line utility that allows you to send requests and commands to the daemon. First deploy the fluxd daemon to the cluster and then download the fluxctl service binaries and configure it for your environment.

Also Weave Cloud deploy assumes that you have set up your deployment YAML for your Kubernetes services and that you have already deployed your application to the cluster. See Setting up Your Manifests

Note: You can also set up most of these variables in the Weave Cloud GUI and it is not necessary to configure it on the command line, unless you prefer working that way.

The following topics are discussed:

Installing the Daemon & the CLI Utility

To install and set up Weave Cloud deploy in Kubernetes:

1. Deploy the fluxd daemon to the Kubernetes cluster by running:

kubectl apply -n kube-system -f \
   "https://cloud.weave.works/k8s/flux?service-token=[cloud-token]-version=$(kubectl version | base64 | tr -d '\n')"

Where,

[cloud-token] is found on the settings page of your instance in Weave Cloud.

2. Check Explore to see that the fluxd is running as a container.

To simplify this, enter flux agent into the search field in Explore

3. Generate public and private SSH keys for your repo. These keys are used by fluxd to manage changes between Github and Kubernetes:

ssh-keygen -f id-rsa-flux

4. Install the fluxctl binary onto the master node:

curl -o /usr/local/bin/fluxctl -sSL https://github.com/weaveworks/flux/releases/
chmod +x /usr/local/bin/fluxctl

5. Using your preferred text editor, create a file on the master node called flux.conf:

git:
  URL: git@github.com:<YOUR_GITHUB_USERNAME>/microservices-demo
  path: deploy/kubernetes/manifests
  branch: master
  key: |
         -----BEGIN RSA PRIVATE KEY-----
         ZNsnTooXXGagxg5a3vqsGPgoHH1KvqE5my+v7uYhRxbHi5uaTNEWnD46ci06PyBz
         zSS6I+zgkdsQk7Pj2DNNzBS6n08gl8OJX073JgKPqlfqDSxmZ37XWdGMlkeIuS21
         nwli0jsXVMKO7LYl+b5a0N5ia9cqUDEut1eeKN+hwDbZeYdT/oGBsNFgBRTvgQhK
         ... contents of id-rsa-flux file from above ...
         -----END RSA PRIVATE KEY-----
slack:
  hookURL: ""
  username: ""
registry:
  auths: {}

Copy the following into the flux.conf:

  • Replace <YOUR_GITHUB_USERNAME> with your GitHub username (required).

  • Copy the private key you created earlier into the private key section of the file. To view the generated key, run cat id-rsa-flux (required). Ensure that the indentation is correct and that there is no whitespace.

Note: the use of | indicates a multiline string value for the key. All the lines must be indented if using the pipe character.

  • In the Registry section, copy the authorization details from your private image registry.
  • If you are using a public registry, then Deploy will detect the images automatically.

6. Next, configure access to the fluxd daemon and also associate the Weave Cloud instance with:

export FLUX_SERVICE_TOKEN=<weave-cloud-token>

Note: If you’ve logged out of your shell, you must re-run export FLUX_SERVICE_TOKEN=<weave-cloud-token> to re-establish your environment.

7. Load the config file into the Flux service:

fluxctl set-config --file=flux.conf

8. Check that all went well by running:

fluxctl list-services

Note: For images and services to appear, you must have first deployed your application to a cluster.

If you’re using a Private Docker Registry

To configure fluxd to use a private registry, use the following stanza in the .conf file:

registry:
  auths:
    "<address-of-registry>":
      auth: "<base64-encoded-user:password>"

An example of <address-of-registry> is https://index.docker.io/v1/. You can copy <base64-encoded-user:password> from your ~/.docker/config.json.

Note: If you prefer, you can also enter this information in the Weave Cloud deploy settings screen. See Configuring Deploy in Weave Cloud

Configuring The SSH Deploy Keys for GitHub

Configure the deploy keys for the microservices-demo repository that you forked in Github. This allows Weave Cloud deploy to read and write to the repo with the Kubernetes manifests in it. It is important to note that the SSH keys you created must be set on the repository that contains the Kubernetes manifests. These manifests are used by Weave Cloud deploy to manage changes between the cluster and the app.

To set your public key up for your repo:

1. Go to the <YOUR_GITHUB_USERNAME>/<your code> repo on github, and click Settings from the top of the repo.

2. Click on Deploy Keys from the left-hand menu.

3. Click Add a Key, and then paste in your public key generated from above (Run cat id-rsa-flux.pub to see it).

Enable the Allow Read/Write access box so that Weave Cloud deploy has full access to the repo.

Further Reading