-
Notifications
You must be signed in to change notification settings - Fork 73
Added imageSpec for registry/repo:tag overrides #447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Helm Template output:
|
@blang9238 what is the reason for this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to be backwards compatible.
@zhill P1 asked if we could support separating out the registry / repo / tag (similar to other charts) but mentioned that BB will only pull it down if it's in our upstream. I'm reworking this currently to use the common.tpl. I'll send you the internal discussion. |
@@ -39,7 +39,11 @@ spec: | |||
{{- include "enterprise.common.cloudsqlContainer" . | nindent 8 }} | |||
{{- end }} | |||
- name: "{{ .Chart.Name }}-{{ $component | lower }}" | |||
image: {{ .Values.image }} | |||
image: {{- if and .Values.imageSpec.registry .Values.imageSpec.repository .Values.imageSpec.tag -}} | |||
{{ printf "%s/%s:%s" .Values.imageSpec.registry .Values.imageSpec.repository .Values.imageSpec.tag | trim | indent 1}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't handle digests instead of a tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but similar bitnami format does support digest as well in the object via the "Digest" field, so not sure if that needs to also be supported here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, can certainly add it.
image: {{- if and .Values.ui.imageSpec.registry .Values.ui.imageSpec.repository .Values.ui.imageSpec.tag -}} | ||
{{ printf "%s/%s:%s" .Values.ui.imageSpec.registry .Values.ui.imageSpec.repository .Values.ui.imageSpec.tag | trim | indent 1}} | ||
{{- else -}} | ||
{{ .Values.image | trim | indent 1}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what's breaking testing. I'll push a fix shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Create an image specification template that can override the default image | ||
based on global settings | ||
*/}} | ||
{{- define "enterprise.common.imageOverride" -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Override" is confusing here, it should just be "enterprise.common.image".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, so should it be:
image: docker.io/anchore/enterprise:v5.16.0
# registry: docker.io
# repository: anchore/enterprise
# tag: v5.16.0
# digest: sha256:12345abcde
Then if registry / repo / tag / digest are defined, use that, otherwise default to just the pullstring?
or should I split it out into something like:
image:
pullstring: docker.io/anchore/enterprise:v5.16.0
# registry: docker.io
# repository: anchore/enterprise
# tag: v5.16.0
# digest: sha256:12345abcde
And then do the same checks but modify .Values.image to .Values.image.pullstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard, saw your later comment about checking the 'image' value either being a map or a string
Create an image specification template for the UI that can override the default image | ||
based on component-specific or global settings | ||
*/}} | ||
{{- define "enterprise.ui.imageOverride" -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as above, just use "enterprise.ui.image".
Create an image specification template for the UI that can override the default image | ||
based on component-specific or global settings | ||
*/}} | ||
{{- define "enterprise.kubectl.imageOverride" -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
stable/enterprise/Chart.yaml
Outdated
@@ -1,6 +1,6 @@ | |||
apiVersion: v2 | |||
name: enterprise | |||
version: "3.5.2" | |||
version: "3.5.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a new feature, though backwards compatible, I think this is "3.6.0" not a patch update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhill since v5.16.0 took the chart to 3.6.0, should I then bump this to 3.7.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blang9238 I also checked on how we can make this a bit easier for the user and something like this snippet would allow the 'image' value to be either a map or a string so we wouldn't need different keys:
{{- define "enterprise.common.image" -}}
# Check if the 'image' is a string or not, if not, use it as a map.
{{- if eq (printf "%T" .Values.image) "string" }}
{{- .Values.image | trim -}}
{{- else -}}
# Assume a map (but verify non-nil..) and construct string from the parts.
{{- printf "%s/%s:%s" .Values.image.Registry .Values.image.Repository Values.image.Tag | trim -}}
{{- end -}}
{{- end }}
I'd like others' opinions on if allowing different types there would be more confusing, but at least it is a single place in the Values to set the images rather than 2 that interact. @HN23 or @Btodhunter, thoughts?
@@ -39,7 +39,7 @@ spec: | |||
{{- include "enterprise.common.cloudsqlContainer" . | nindent 8 }} | |||
{{- end }} | |||
- name: "{{ .Chart.Name }}-{{ $component | lower }}" | |||
image: {{ .Values.image }} | |||
image: {{ include "enterprise.common.imageOverride" . | trim }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the trim needed here? Shouldn't that be applied once in the setting of the value?
@zhill pushed some updates for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is a breaking change, so we need to fix that (the new way for kubectl works but is breaking if a user had set it previously). Otherwise just a few questions and minor value checks to ensure the image refs are constructed well. Overall looking good. Getting close!
{{- define "enterprise.common.image" -}} | ||
{{- if eq (printf "%T" .Values.image) "string" }} | ||
{{- .Values.image | trim -}} | ||
{{- else if and .Values.image.digest -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the "and" necessary here? I may be wrong but I don't think the "and" is helpful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, removed.
{{- define "enterprise.ui.image" -}} | ||
{{- if eq (printf "%T" .Values.ui.image) "string" }} | ||
{{- .Values.ui.image | trim -}} | ||
{{- else if and .Values.ui.image.digest -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same "and" question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
{{- if eq (printf "%T" .Values.image) "string" }} | ||
{{- .Values.image | trim -}} | ||
{{- else if and .Values.image.digest -}} | ||
{{- printf "%s/%s@%s" .Values.image.registry .Values.image.repository .Values.image.digest | trim -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in both these cases, tag or digest, if the user only fills out part of the dict, it will output a bad reference that will fail to run the pods. I'd like to see some checks that the registry and repository properties exist and are non-nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack thanks @zhill, I'll revisit and get checks in place for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok latest commit should handle it better.
@zhill Is this aligned with what you were thinking? I left the trims in, renders correctly when I tested locally and with helm templating. |
@blang9238 |
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
…erride' Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
Signed-off-by: Ben Lang <blang@anchore.com>
ab96e9a
to
ce04dc4
Compare
stable/enterprise/values.yaml
Outdated
@@ -17,9 +17,16 @@ global: | |||
## Common params used by all Anchore k8s resources | |||
################################################### | |||
|
|||
## @param image Image used for all Anchore Enterprise deployments, excluding Anchore UI | |||
## @param imageOverride imageOverride used for all Anchore Enterprise deployments by separating out registry/repo:tag, excluding Anchore UI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is imageOverride an old/deleted value? If so, we should remove mentions of it.
stable/enterprise/Chart.yaml
Outdated
@@ -1,6 +1,6 @@ | |||
apiVersion: v2 | |||
name: enterprise | |||
version: "3.8.0" | |||
version: "3.8.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably bump this to the next minor version instead of a patch since its changing/adding a new way the chart works. Also we should probably update the README to include the changes (both the kubectlImage change and the image/ui.image change)
Signed-off-by: Ben Lang <blang@anchore.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Thanks for the PR @blang9238 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Signed-off-by: Ben Lang blang@anchore.com