Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Support defining image paths for HelmReleases #2249

Merged
merged 5 commits into from
Aug 15, 2019

Conversation

hiddeco
Copy link
Member

@hiddeco hiddeco commented Jul 11, 2019

This commit adds support for supplying image paths for HelmRelease
resources through annotations, and introduces a new alias for image
tag filters.

For an image mapping to be valid, the image path must be defined
and may be supplemented by a tag and/or registry path. In case
the combination of resolved values does not result in a valid image
ref, the mapping will be ignored.

Supported annotations:

registry.fluxcd.io/<alias>: <registry path>
repository.fluxcd.io/<alias>: <image path>
tag.fluxcd.io/<alias>: <tag path>
filter.fluxcd.io/<alias>: <tag filter>

Image mappings are composed by <alias>.

A valid annotation mapping is for example:

annotations:
  registry.fluxcd.io/container: some.custom.registry
  repository.fluxcd.io/container: some.custom.image
  tag.fluxcd.io/container: some.custom.tag
  filter.fluxcd.io/container: glob: master-*

  repository.fluxcd.io/anotherone: depth.knows.no.limits.image

which would map the image for the following values structure:

values:
  some:
    custom:
      registry: docker.io
      image: fluxcd/flux-prerelease
      tag: master-abcdefg
  depth:
    knows:
      no:
        limits:
          image: fluxcd/helm-operator:0.10.0

This PR is in need of squaremo/kubeyaml#11 squaremo/kubeyaml#14 to persist the actual changes to git.

Fixes: #1262

@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch from f47bacc to a214627 Compare July 11, 2019 12:54
@hiddeco hiddeco added this to the 1.14.0 milestone Jul 11, 2019
@2opremio
Copy link
Contributor

Where, container a parameter, right? (i.e. does the scheme support multiple containers?)

The use of subdomains (as opposed to e.g. a path) to denote what you are specifying seems a bit funky, but we probably can't do better due to the restrictions of the annotation syntax imposed by k8s.

Maybe we could add another subdomain to make it more clear? e.g.
tag.pathspec.flux.weave.works?

@hiddeco
Copy link
Member Author

hiddeco commented Jul 11, 2019

Where, container a parameter, right? (i.e. does the scheme support multiple containers?)

container in this case is just an alias for your collection of mappings (it represents one image definition), it can be any string and multiple mappings can be defined.

The use of subdomains (as opposed to e.g. a path) to denote what you are specifying seems a bit funky, but we probably can't do better due to the restrictions of the annotation syntax imposed by k8s.

Correct, this is the most Kubernetes native approach to defining the mapping and is conform their specifications for annotations.

Maybe we could add another subdomain to make it more clear? e.g.
tag.pathspec.flux.weave.works?

Can not decide if the clarity improvement would weight up to the annoyance of a really long annotation key.

@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch 6 times, most recently from 2df534b to 11ee161 Compare July 23, 2019 09:02
@hiddeco hiddeco requested a review from squaremo July 23, 2019 09:03
@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch from 11ee161 to a6d7501 Compare July 23, 2019 09:17
@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch from a6d7501 to 4e22bc8 Compare August 1, 2019 13:30
@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch 3 times, most recently from 05e55af to 27648fa Compare August 7, 2019 15:46
Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just suggestions. One item that does need a revision, or a rebuttal: shouldn't SetWorkloadContainerImage fail if it finds annotations but can't make sense of them?

bin/kubeyaml Outdated Show resolved Hide resolved
cluster/kubernetes/manifests.go Outdated Show resolved Hide resolved
cluster/kubernetes/manifests.go Outdated Show resolved Hide resolved
cluster/kubernetes/resource/fluxhelmrelease.go Outdated Show resolved Hide resolved
cluster/kubernetes/resource/fluxhelmrelease.go Outdated Show resolved Hide resolved
cluster/kubernetes/resource/fluxhelmrelease.go Outdated Show resolved Hide resolved
cluster/kubernetes/resource/fluxhelmrelease.go Outdated Show resolved Hide resolved
cluster/kubernetes/resource/fluxhelmrelease.go Outdated Show resolved Hide resolved
cluster/kubernetes/resource/fluxhelmrelease.go Outdated Show resolved Hide resolved
// By using github.com/ghodss/yaml to unmarshal HelmReleases.
// This effectively results in all keys of `Value`s being strings
// and not interface{}.
if err := jsonyaml.Unmarshal(bytes, &fhr); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the mapper stuff above can be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above where? Quite a lot of 'mapper' things on this page...

@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch from 27648fa to c6739bd Compare August 15, 2019 17:20
This commit adds support for supplying image paths for `HelmRelease`
resources through annotations, and introduces a new alias for image
tag filters.

For an image mapping to be valid, the image path _must_ be defined
and _may_ be supplemented by a tag and/or registry path.
@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch from c6739bd to 38d69c5 Compare August 15, 2019 17:29
The `kubeyaml set` command used to update values by YAML dot
notation path was introduced in this version.
@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch from 38d69c5 to e272223 Compare August 15, 2019 17:30
@hiddeco hiddeco force-pushed the feature/helmrelease-image-pattern branch from e272223 to 32cb1c3 Compare August 15, 2019 19:02
@hiddeco hiddeco merged commit 04c4138 into master Aug 15, 2019
@hiddeco hiddeco deleted the feature/helmrelease-image-pattern branch August 15, 2019 19:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support even more patterns of specifying images in FluxHelmRelease
3 participants