Commit Graph

344 Commits

Author SHA1 Message Date
Valeriano Manassero 0d04ac9b6b Fix kustomize build references
Signed-off-by: Valeriano Manassero <14011549+valeriano-manassero@users.noreply.github.com>
2020-11-30 13:57:45 +01:00
Michael Bridgen 4d9df3fd04
Merge pull request #56 from fluxcd/share-fluxv2-maintainers
Note maintainers shared from fluxcd/flux2
2020-11-27 16:08:52 +00:00
Michael Bridgen e2a30deb37 Note maintainers shared from fluxcd/flux2
The GitOps toolkit controllers usually adopt the maintainers of the
"central" Flux v2 git repo, fluxcd/flux2. For convenience of keeping
track, it is easier to refer to the MAINTAINERS file there.

NB this expands the maintainers of this repo, but only to those who
were effectively considered maintainers anyway (i.e., it reflects the
established practice.)

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-27 10:46:57 +00:00
Michael Bridgen 24d539d4ab
Merge pull request #53 from fluxcd/conditions-status
Make controller update ready condition
2020-11-27 10:16:53 +00:00
Michael Bridgen 6a0d528757 Ensure LastAutomationRun only records successes
The `LastAutomationRun` field records the last time the automation
completed, whether it made changes or not. The purpose is to inform
users, so they can check against their expectations.

It should only be set once the automation run has completed without
error, otherwise it will provide false reassurance that things are
happening when they are not.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-26 12:20:40 +00:00
Michael Bridgen 38b7d2e8aa Document extra ready condition reasons
Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-26 12:17:09 +00:00
Michael Bridgen a09ac3f9d4 Make controller update ready condition
This gives ImageUpdateAutomation objects .status.conditions and
.status.observedGeneration fields, which are maintained by the
controller in the GOTK-standard way.

The only condition used is a Ready condition, compatible with kstatus
(and in common with other GOTK controllers). An object is marked Ready
if the reconciliation exits without an error, whether or not changes
were actually made. If the automation run cannot proceed, e.g.,
because the git repository referred to does not exist, or is not
cloneable, it will be marked as not ready.

This means the condition is a reliable guide to whether the particular
automation is operating or not; new objects will be marked ready as
soon as they have been run through successfully, and will stay ready
until there's a problem. Generally, if there _is_ a problem, the
object will be requeued with a backoff, or left to wait until
circumstances change (e.g., the object itself is edited); one way or
another, there will be a retry, and thereby an opportunity to
transition to ready.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-25 14:59:14 +00:00
Michael Bridgen 24bbf91dbe
Merge pull request #50 from fluxcd/manifests-by-gotk
Change config/ to be in line with GOTK
2020-11-24 10:20:07 +00:00
Michael Bridgen 3666b91366 Change config/ to be in line with GOTK
Broadly,

 - remove prometheus, webhooks and certificate handling
 - use standard names and filenames
 - don't authenticate the metrics endpoint

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 17:15:05 +00:00
Michael Bridgen d228da0513
Merge pull request #47 from fluxcd/namespaces-events-logging
GOTK conformance for watching namespaces, events, logging
2020-11-23 16:45:47 +00:00
Michael Bridgen 311ca212c5 Give controller liveness and readiness endpoints
- make the healthz endpoint a flag and give the value to the
   controller runtime
 - set up probe endpoints; copy the func from elsewhere for now
 - add the probe defs to the deployment

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 13:44:12 +00:00
Michael Bridgen 5bd0bc8cba Set logger up with log level and JSON flags
This is the GitOps Toolkit convention.  This commit also puts the
flags in the base deployment config, in the same order as for other
GOTK controllers.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 12:54:15 +00:00
Michael Bridgen c762ce8d6f Send event on success/failure to commit change
The useful events to know about for the update automation are when it
either errors out while trying to update the git repo, or succeeds.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 12:45:08 +00:00
Michael Bridgen 59975f6ad0 Make room for event recorder
This gives the controller an event recorder, without using it yet, and
makes sure it is registered when setting everything up in main.go.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 11:23:30 +00:00
Michael Bridgen 385277bef3 Add --watch-all-namespaces flag to controller
This is a convention among the GitOps toolkit controllers; if false,
the controller will watch only resources in the namespace in which
it's running.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 11:08:05 +00:00
Michael Bridgen 779d0a1a5a
Merge pull request #43 from fluxcd/copy-api-before-gomod
Fix order of copy api/ and go mod in Dockerfile
2020-11-20 13:00:04 +00:00
Michael Bridgen bacddc86ce Fix order of copy api/ and go mod in Dockerfile
Once the api/ directory has its own module, to which the top go.mod
refers, it needs to be copied over before running `go mod download`.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-19 14:52:48 +00:00
Michael Bridgen b58bd2deb7
Merge pull request #20 from fluxcd/api-pkg
Make the api package a dedicated module
2020-11-19 11:29:40 +00:00
Hidde Beydals bf8c2deeb7 Make the API package a dedicated module
This includes changes to:

* Bump the Kubernetes dependencies to v1.19.3 to align
  with the other toolkit controllers.
* Update controller-runtime dependency to v0.6.3 to align
  with the other toolkit controllers.
* Update the source-controller dependency to the most recent
  v0.2.2 version to include the v1beta1 API.
* Add the `pkg/gittestserver` dependency for the Git tests,
  as this package was removed in a newer source-controller version.
* Bump the Go version to v1.15.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-19 12:16:17 +01:00
Michael Bridgen 226ee9bd0e
Merge pull request #42 from fluxcd/release-workflow
Adapt release workflow from image-reflector
2020-11-19 11:10:26 +00:00
Michael Bridgen 0b796e4e67 Use kubebuilder action from main
As it is (v0.0.4), it runs into the hard deprecation in GitHub Actions
of add_path.

Signed-off-by: Michael Bridgen <mikeb@squaremobius.net>
2020-11-18 18:46:25 +00:00
Michael Bridgen 231e085d5d Adapt release workflow from image-reflector
I have factored out the controller name into an env entry. In a `run:`
field, it is possible (necessary?) to use shell syntax for referring
to the env entry.

If this works here, I'll backport it to image-reflector-controller.

Signed-off-by: Michael Bridgen <mikeb@squaremobius.net>
2020-11-18 18:29:04 +00:00
Michael Bridgen cd254148a5
Merge pull request #35 from fluxcd/change-copyright-header
Change copyright to Flux authors
2020-10-28 16:08:30 +00:00
Hidde Beydals 29c60ecc6e Change copyright to Flux authors
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-27 17:57:31 +01:00
Michael Bridgen 35a3035944
Merge pull request #28 from fluxcd/toolkit-compatibility
Towards Toolkit compatibility
2020-10-26 11:49:24 +00:00
Stefan Prodan 38b4eb2fe9
Enable multi-arch build
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-10-22 17:30:58 +03:00
Stefan Prodan e7ec904fef
Generate CRDs using the stable apiextensions
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-10-22 17:17:48 +03:00
Michael Bridgen fb26178744
Merge pull request #27 from fluxcd/remove-poc-mode
Remove proof-of-concept update mode
2020-10-22 15:05:14 +01:00
Michael Bridgen da2f23caf1 Remove proof-of-concept update mode
The initial implementation of image updates required a single image
policy, and updated every image field that used the image, in the git
repo. This mode has limited practical value, and rather than
elaborating on it, it would be better to concentrate on making the
more carefully thought-through "setters" mode.
2020-10-22 14:53:41 +01:00
Michael Bridgen 7318ecb184
Merge pull request #23 from fluxcd/use-kyaml-setters2
Implement automation via kyaml setters2
2020-10-21 11:07:39 +01:00
Michael Bridgen 76da2079e6 Supply :tag and :name setters for each image
It will be useful, for kustomizations e.g., to be able to set just the
tag or just the name (repository). This commit adds setters for those
to the schema -- they have the name of the image setter plus a suffix
of `:tag` or `:name`. For example:

    newName: ubuntu # {"$imagepolicy": "ns:policy:name"}
    newTag: 18.10   # {"$imagepolicy": "ns:policy:tag"}
2020-10-13 21:00:13 +01:00
Michael Bridgen b6603ab393 Rewrite directory comparison test helper
It's difficult to test the files comparison if it contains all its own
assertions, since you can only test successes. This commit rewrites
the helper to use a func without assertions, that can be more roundly
tested.
2020-10-13 21:00:13 +01:00
Michael Bridgen 9e486739e9 Adapt instructions in README to use setters 2020-10-13 21:00:13 +01:00
Michael Bridgen 4006b6d5c4 Use UpdateWithSetters in controller
(and update the test to suit)
2020-10-13 21:00:13 +01:00
Michael Bridgen 7e58a5bf47 Implement and test func for update using setters
This adds another means of updating files to the package pkg/update/,
in setters.go (and gives the existing file a better name).

In passing, I changed the test util for comparing before/after
updates, in pkg/files/, to give a little more context when comparing
file contents; and, since the comparison between actual and expected
is not symmetrical, I corrected the order of the args in the tests.
2020-10-13 20:59:35 +01:00
Michael Bridgen ec8795dcba Get the test to a point where it could pass
In particular, insert the setter reference into the deployment file.
2020-10-08 17:20:36 +01:00
Michael Bridgen 963ee35c23 Preserve line-end comments when replacing image
Previously: replace the YNode (yaml.Node) with a new one which is just
the replacement string.
Now: change the value of the YNode, and set it back in place.
2020-09-29 12:19:12 +01:00
Michael Bridgen b9d345dbc4 Test for update via setters
(this test fails, since the implementation is still a stub)
2020-09-28 12:52:57 +01:00
Michael Bridgen e176c22fa9 Add stub method and test for update by setters
This rearranges the test file a little, so that the different
strategies can share some setup.
2020-09-28 12:35:58 +01:00
Michael Bridgen fd4b139dec Add setters strategy to ImageUpdateAutomation type
This is the means for telling the controller to use kyaml setters, per
the design in
https://github.com/fluxcd/toolkit/discussions/107#discussioncomment-82746
2020-09-28 11:06:18 +01:00
Michael Bridgen 6976581d31
Merge pull request #21 from bigkevmcd/replace-cronjobs
Apply image updates to CronJob objects
2020-09-09 10:35:59 +01:00
Kevin McDermott aad1df6af6 Apply image updates to CronJob objects
This updates the image replacement to switch on the kind of the node,
and change the way the replacements are done for CronJobs.

CronJobs have PodTemplateSpecs embedded deeper in the structure.
2020-09-09 10:30:48 +01:00
Michael Bridgen 51a31cf2e7
Merge pull request #18 from fluxcd/license
Add license, DCO and COC
2020-08-11 08:44:44 +01:00
stefanprodan 1a83985f11 Add license, DCO and COC 2020-08-11 10:26:03 +03:00
Stefan Prodan 1beb24db46
Merge pull request #17 from fluxcd/reassign-to-flux
Reassign copyright to flux, and fix up package paths etc.
2020-08-11 09:42:27 +03:00
Michael Bridgen ab4a963d50 Change package name and fixup imports and paths 2020-08-10 18:09:57 +01:00
Michael Bridgen 48aac78343 Reassign copyright to Flux project 2020-08-10 17:48:24 +01:00
Michael Bridgen 51befe6054
Merge pull request #15 from squaremo/bump-controller-runtime-and-go
Bump controller runtime and go
2020-08-06 10:24:02 +01:00
Michael Bridgen 1953c677ad Get image-reflector with matching bump
This updates the package
github.com/squaremo/image-reflector-controller to a revision that also
uses controller-runtime 0.6.2 (and client-go etc., 0.18).

The ImagePolicy CRD has also changed, so I've also uodated the tests
involving that type.
2020-08-06 09:49:47 +01:00
Michael Bridgen 08b0961100 Bump controller-runtime to 0.6.2 2020-08-06 09:15:55 +01:00