diff --git a/README.md b/README.md index f92a246..d47b468 100644 --- a/README.md +++ b/README.md @@ -1,276 +1,15 @@ # Image automation controller -This is part of the image update automation, as outlined in +This controller automates updates to YAML when new container images +are available. - - [this post](https://squaremo.dev/posts/gitops-controllers/); and refined in - - [this design](https://github.com/fluxcd/image-reflector-controller/pull/5) - -Its sibling repository -[image-reflector-controller](https://github.com/fluxcd/image-reflector-controller) -implements the image metadata reflection controller (scans container -image repositories and reflects the metadata in Kubernetes resources); -this repository implements the image update automation controller. +Its sibling, +[image-reflector-controller](https://github.com/fluxcd/image-reflector-controller), +scans container image repositories and reflects the metadata in +Kubernetes resources. This controller reacts to that image metadata by +updating YAML files in a git repository, and committing the changes. ## How to install it -### Prerequisites - -At present this works with GitRepository custom resources as defined -in the [`source-controller`][source-controller] types; and, the -[`image-reflector-controller`][image-reflector]. GitRepository -resources are used to describe how to access the git repository to -update. The image reflector scans container image metadata, and -reflects it into the cluster as resources which this controller uses -as input to make updates; for example, by changing deployments so they -use the most recent version of an image. - -**To install the GitRepository CRD** - -This controller only needs the custom resource definition (CRD) for -the GitRepository kind, and doesn't need the source-controller itself. - -If you're not already using the [GitOps toolkit][gotk], you can just -install the custom resource definition for GitRepository: - - kubectl apply -f https://raw.githubusercontent.com/fluxcd/source-controller/v0.2.2/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml - -**To install the image reflector controller** - -This controller relies on the image reflector controller. A working -configuration for the latter can be applied straight from the GitHub -repository: - - kustomize build https://github.com/fluxcd/image-reflector-controller/config/default/?ref=main | kubectl apply -f- - -### Installing the automation controller - -You can apply a working configuration directly from GitHub: - - kustomize build https://github.com/fluxcd/image-automation-controller/config/default?ref=main | kubectl apply -f- - -or, in a clone of this repository, - - make docker-build deploy - -You will need to do the latter if you're trying the controller on a -branch other than `main`. - -## How to use it - -Here is a quick example of configuring an automation. I'm going to use -[cuttlefacts-app][cuttlefacts-app-repo] because it's minimal and easy -to follow. - -### Image policy - -[The deployment][cuttlefacts-app-deployment] in cuttlefacts-app uses -the image `cuttlefacts/cuttlefacts-app`. We'll automate that so it -gets updated when there's a semver-tagged image, e.g., -`cuttlefacts/cuttlefacts-app:v1.0.0`. - -Keeping track of the most recent image takes two resources: an -`ImageRepository`, to scan DockerHub for the image's tags, and an -`ImagePolicy`, to give the particular policy for selecting an image -(here, a semver range). - -The `ImageRepository`: - -```bash -$ cat > image.yaml < policy.yaml < known_hosts - ssh-keygen -l -f known_hosts - -Check that the fingerprint matches one [published by -GitHub][github-fingerprints]. - -Now you can make a secret with the deploy key and known_hosts file: - - kubectl create secret generic cuttlefacts-deploy --from-file=identity --from-file=known_hosts - -Those two filenames -- `identity` and `known_hosts` -- are what the -source controller library code expects, which makes it easier for the -automation controller to use the `GitRepository` type. - -You also need to install the deploy key in GitHub. Copy it from -`identity.pub` (that's the _public_ part of the key): - -```bash -$ cat identity.pub -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKM2wTSz5VyL2UCLh3ke9XUO1WUmAf -[...]w2FFnV24AGhWdP5lPOS/Jv64+OfMSF5E/e4dwVs= mikeb@laptop.lan -``` - -... and add under `Settings / Deploy keys` for your fork on GitHub, -giving it write access. - -Now you can create a `GitRepository` which will provide access to the -git repository within the cluster. Remember to change the URL; it's -probably easiest, if you're copying & pasting, to run the following -then edit `repo.yaml` afterwards. - -```bash -$ cat > repo.yaml < update.yaml <