-
Notifications
You must be signed in to change notification settings - Fork 510
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
[Operator] Optional tag for collector #1196
[Operator] Optional tag for collector #1196
Conversation
{{- else if .Values.manager.collectorImage.repository }} | ||
- --collector-image={{ .Values.manager.collectorImage.repository }} |
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.
Let's move this and the above logic into a helper template so we don't have to do the same condition twice.
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.
Do you mean, something like this?
{{- define "opentelemetry-operator.collectorImage" -}}
{{- if and .Values.manager.collectorImage.repository .Values.manager.collectorImage.tag }}
- --collector-image={{ .Values.manager.collectorImage.repository }}:{{ .Values.manager.collectorImage.tag }}
{{- else if .Values.manager.collectorImage.repository }}
- --collector-image={{ .Values.manager.collectorImage.repository }}
{{- end -}}
{{- end }}
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.
I believe we can do something like:
{{ - $tag = "" }}
{{ if .Values.manager.collectorImage.tag }}
{{ - $tag = ":" + .Values.manager.collectorImage.tag }}
{{- end }}
- --collector-image={{ .Values.manager.collectorImage.repository }}{{ $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.
BTW, despite you are forcing the users to add a collector repository. I would add an if condition here so in case you remove the requirement in the future, it can avoid a bug if you forget to add the if condition here later.
Check it out:
{{- if .Values.manager.collectorImage.repository -}}
{{- $tag := "" -}}
{{- if .Values.manager.collectorImage.tag -}}
{{- $tag = print ":" .Values.manager.collectorImage.tag -}}
{{- end }}
- --collector-image={{ .Values.manager.collectorImage.repository }}{{ $tag }}
{{- end }}
@@ -49,6 +49,8 @@ spec: | |||
{{- end }} | |||
{{- if and .Values.manager.collectorImage.repository .Values.manager.collectorImage.tag }} | |||
- --collector-image={{ .Values.manager.collectorImage.repository }}:{{ .Values.manager.collectorImage.tag }} | |||
{{- else if .Values.manager.collectorImage.repository }} | |||
- --collector-image={{ .Values.manager.collectorImage.repository }} |
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.
@jdiegosierra in the situation that we don't pass in a tag, are you sure the tag that ends up being uses is the default collector version from the operator and not the latest version of the set image repository?
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.
I tried with the latest version, so let me check it with a different one
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.
@TylerHelmuth It works as expected:
appVersion: 0.100.1
manager:
image:
repository: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
tag: "0.99.0"
collectorImage:
repository: ""
tag: ""
k describe pod opentelemetry-operator-79cbd68444-wdpl9 | grep Image:
Image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.99.0
k describe pod simplest-collector-54bb659675-99d7g | grep Image:
Image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:0.99.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.
What about when you set and image repository and not 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.
In that scenario, the operator assumes the collector image is the latest one. If we want to have both components with the same version in that specific scenario, I guess we can pick the tag from the operator.
# Source: opentelemetry-operator/templates/deployment.yaml
- --collector-image=otel/opentelemetry-collector
image: "ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.99.0"
Image ID: docker.io/otel/opentelemetry-collector@sha256:fe7714849adfd251129be75e39c5c4fa7031d87146645afa5d391ab957845c18
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.
Anyway, that situation can not happen right now because it is mandatory to have both fields set:
opentelemetry-helm-charts/charts/opentelemetry-operator/templates/deployment.yaml
Lines 50 to 51 in ef0e1ac
{{- if and .Values.manager.collectorImage.repository .Values.manager.collectorImage.tag }} | |
- --collector-image={{ .Values.manager.collectorImage.repository }}:{{ .Values.manager.collectorImage.tag }} |
BTW, what do you think about changing this alert with a "warning"?
If the user doesn't set a tag, the image will not take effect, and setting only the repository field as mandatory might create confusion: opentelemetry-helm-charts/charts/opentelemetry-operator/templates/deployment.yaml Lines 50 to 53 in ef0e1ac
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Resolves #1189