Skip to content
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

Show error when autoupdate is enabled with pinned image #860

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 82 additions & 6 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pod_association:
common.image - Helper template to determine the image path based on various conditions.

Usage:
{{ include "common.image" (tuple $root $path $nameObj $defaultFullImage $defaultTag) }}
{{ include "common.image" (tuple $root $path $nameObj $defaultFullImage $defaultTag $defaultKey) }}

Where:
- $root: The root context of the chart (usually passed as '.' from the calling template).
Expand All @@ -184,6 +184,7 @@ Where:
- If a slice, it expects two elements:
- The first element is the key name for the otel image configuration.
- The second element is the key name for the Azure image configuration.
- $defaultKey: A unique key that is used for retrieving default values of the image if autoupdate is enabled.
- $defaultFullImage: (Optional) A default image (including tag) to use if the specified image is not found.
- Expected format: "repository/image:tag".
- $defaultTag: (Optional) A default tag to use if no tag is specified in the image configuration.
Expand Down Expand Up @@ -212,15 +213,19 @@ Example:
{{- $azureName = $nameObj -}}
{{- end -}}

{{- $defaultFullImage := "" -}}
{{- $defaultImage := "" -}}
{{- $defaultTag := "" -}}
{{- $defaultKey := "" -}}
{{- if gt (len .) 3 -}}
{{- $defaultFullImage = index . 3 -}}
{{- $defaultKey = index . 3 -}}
{{- end -}}

{{- $defaultFullImage := "" -}}
{{- $defaultImage := "" -}}
{{- $defaultTag := "" -}}
{{- if gt (len .) 4 -}}
{{- $defaultTag = index . 4 -}}
{{- $defaultFullImage = index . 4 -}}
{{- end -}}
{{- if gt (len .) 5 -}}
{{- $defaultTag = index . 5 -}}
{{- end -}}

{{- if $defaultFullImage -}}
Expand Down Expand Up @@ -253,6 +258,23 @@ Example:
{{- $valuesPath := index $path $name -}}
{{- $valuesRepository := index $valuesPath "repository" -}}
{{- $valuesTag := index $valuesPath "tag" -}}
{{- $valuesPullPolicy := index $valuesPath "pullPolicy" -}}

{{- if $root.Values.autoupdate.enabled }}
{{- $defaultImagesJson := include "common.defaultImages" $root -}}
{{- $defaultImages := fromJson $defaultImagesJson -}}
{{- $defaultImage := index $defaultImages $defaultKey -}}
{{- $validRepository := index $defaultImage "repository" -}}
{{- $validTag := index $defaultImage "tag" -}}
{{- $validPullPolicy := index $defaultImage "pullPolicy" | default "IfNotPresent" -}}

{{- if and (ne $defaultKey "") $defaultImage }}
{{- if or (ne $valuesRepository $validRepository) (ne $valuesTag $validTag) (ne $valuesPullPolicy $validPullPolicy) }}
{{- fail (printf "Autoupdate is enabled, but the default image was changed for key '%s' (repo|tag|pullPolicy differ)." $defaultKey) -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- $repo := $valuesRepository | default $defaultImage -}}
{{- $tag := $valuesTag | default $defaultTag -}}
{{- if $tag -}}
Expand Down Expand Up @@ -345,3 +367,57 @@ Usage:
{{- define "isSwiEndpointCheckEnabled" -}}
{{- ternary "true" "" (and .Values.otel.swi_endpoint_check.enabled (ternary true .Values.otel.metrics.swi_endpoint_check (eq .Values.otel.metrics.swi_endpoint_check nil))) -}}
{{- end -}}


{{/*
Backup validation set of default images from values.yaml for checking if user has changed something.
*/}}
{{- define "common.defaultImages" -}}
{
"autoupdate.image": {
"repository": "alpine/k8s",
"tag": "1.27.16",
"pullPolicy": "IfNotPresent"
},
"otel.image": {
"repository": "solarwinds/swi-opentelemetry-collector",
"tag": "",
"pullPolicy": "IfNotPresent"
},
"otel.init_images.busy_box": {
"repository": "busybox",
"tag": "1.36.1",
"pullPolicy": "IfNotPresent"
},
"otel.windows.image": {
"repository": "solarwinds/swi-opentelemetry-collector",
"tag": "",
"pullPolicy": "IfNotPresent"
},
"swoagent.image": {
"repository": "solarwinds/swo-agent",
"tag": "v2.10.68",
"pullPolicy": "IfNotPresent"
},
"ebpfNetworkMonitoring.k8sCollector.watcher.image": {
"repository": "solarwinds/opentelemetry-ebpf-k8s-watcher",
"tag": "v0.10.3",
"pullPolicy": "IfNotPresent"
},
"ebpfNetworkMonitoring.k8sCollector.relay.image": {
"repository": "solarwinds/opentelemetry-ebpf-k8s-relay",
"tag": "v0.10.3",
"pullPolicy": "IfNotPresent"
},
"ebpfNetworkMonitoring.reducer.image": {
"repository": "solarwinds/opentelemetry-ebpf-reducer",
"tag": "v0.10.3",
"pullPolicy": "IfNotPresent"
},
"ebpfNetworkMonitoring.kernelCollector.image": {
"repository": "solarwinds/opentelemetry-ebpf-kernel-collector",
"tag": "v0.10.3",
"pullPolicy": "IfNotPresent"
}
}
{{- end -}}
2 changes: 1 addition & 1 deletion deploy/helm/templates/autoupdate/autoupdate-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
- linux
containers:
- name: helm-upgrade
image: "{{ include "common.image" (tuple . .Values.autoupdate (tuple "image" "autoupdate")) }}"
image: "{{ include "common.image" (tuple . .Values.autoupdate (tuple "image" "autoupdate") "autoupdate.image") }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- /bin/bash
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/templates/events-collector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
{{- if include "isSwiEndpointCheckEnabled" . }}
initContainers:
- name: otel-endpoint-check
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- /swi-otelcol
Expand Down Expand Up @@ -99,7 +99,7 @@ spec:
capabilities:
drop:
- ALL
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
env:
- name: MY_POD_IP
Expand Down
6 changes: 3 additions & 3 deletions deploy/helm/templates/metrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
initContainers:
{{- if and .Values.otel.metrics.prometheus_check .Values.otel.metrics.prometheus.url }}
- name: prometheus-check
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box") }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "otel.init_images.busy_box") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until $(wget --spider -nv $PROMETHEUS_URL/federate?); do echo waiting on prometheus; sleep 1; done && echo "Prometheus is available"']
envFrom:
Expand All @@ -77,7 +77,7 @@ spec:
{{- end }}
{{- if include "isSwiEndpointCheckEnabled" . }}
- name: otel-endpoint-check
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- /swi-otelcol
Expand Down Expand Up @@ -113,7 +113,7 @@ spec:
drop:
- ALL

image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
env:
- name: MY_POD_IP
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/templates/metrics-discovery-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ spec:
{{- if include "isSwiEndpointCheckEnabled" . }}
initContainers:
- name: otel-endpoint-check
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- /swi-otelcol
Expand Down Expand Up @@ -101,7 +101,7 @@ spec:
drop:
- ALL

image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
env:
- name: SOLARWINDS_API_TOKEN
Expand Down
6 changes: 3 additions & 3 deletions deploy/helm/templates/network/k8s-collector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
{{- end }}
initContainers:
- name: wait-for-reducer
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box") }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "otel.init_images.busy_box") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until nc -zv $EBPF_NET_INTAKE_HOST $EBPF_NET_INTAKE_PORT; do echo "Waiting for reducer endpoint..."; sleep 5; done;']
env:
Expand All @@ -41,13 +41,13 @@ spec:
- name: "EBPF_NET_INTAKE_PORT"
value: "{{ .Values.ebpfNetworkMonitoring.reducer.telemetryPort }}"
containers:
- image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.k8sCollector.watcher (tuple "image" "ebpf_k8s_watcher")) }}"
- image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.k8sCollector.watcher (tuple "image" "ebpf_k8s_watcher") "ebpfNetworkMonitoring.k8sCollector.watcher.image") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.k8sCollector.watcher.image.pullPolicy }}
name: k8s-watcher
args:
- --log-console
- --log-level={{ .Values.ebpfNetworkMonitoring.k8sCollector.telemetry.logs.level }}
- image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.k8sCollector.relay (tuple "image" "ebpf_k8s_relay")) }}"
- image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.k8sCollector.relay (tuple "image" "ebpf_k8s_relay") "ebpfNetworkMonitoring.k8sCollector.relay.image") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.k8sCollector.relay.image.pullPolicy }}
name: k8s-relay
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
{{- end }}
initContainers:
- name: wait-for-reducer
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box") }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "otel.init_images.busy_box") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until nc -zv $EBPF_NET_INTAKE_HOST $EBPF_NET_INTAKE_PORT; do echo "Waiting for reducer endpoint..."; sleep 5; done;']
env:
Expand All @@ -64,7 +64,7 @@ spec:
value: "{{ .Values.ebpfNetworkMonitoring.reducer.telemetryPort }}"
containers:
- name: swi-kernel-collector
image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.kernelCollector (tuple "image" "ebpf_kernel_collector")) }}"
image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.kernelCollector (tuple "image" "ebpf_kernel_collector") "ebpfNetworkMonitoring.kernelCollector.image") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.kernelCollector.image.pullPolicy }}
args:
- --config-file=/etc/network-explorer/config.yaml
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/templates/network/reducer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
{{- end }}
initContainers:
- name: wait-for-metrics-collector
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box") }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "otel.init_images.busy_box") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until nc -zv $METRICS_COLLECTOR_HOST $METRICS_COLLECTOR_PORT; do echo "Waiting for metrics collector endpoint..."; sleep 5; done;']
env:
Expand All @@ -39,7 +39,7 @@ spec:
value: "{{ .Values.otel.metrics.otlp_endpoint.port }}"
containers:
- name: reducer
image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.reducer (tuple "image" "ebpf_reducer")) }}"
image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.reducer (tuple "image" "ebpf_reducer") "ebpfNetworkMonitoring.reducer.image") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.reducer.image.pullPolicy }}
args:
- --port={{ .Values.ebpfNetworkMonitoring.reducer.telemetryPort }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ spec:
{{- if include "isSwiEndpointCheckEnabled" . }}
initContainers:
- name: otel-endpoint-check
image: "{{ include "common.image" (tuple . .Values.otel.windows (tuple "image" "image_windows") nil .Chart.AppVersion ) }}"
image: "{{ include "common.image" (tuple . .Values.otel.windows (tuple "image" "image_windows") "otel.windows.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- c:\swi-otelcol.exe
Expand All @@ -86,7 +86,7 @@ spec:
{{- end }}
containers:
- name: swi-opentelemetry-collector
image: "{{ include "common.image" (tuple . .Values.otel.windows (tuple "image" "image_windows") nil .Chart.AppVersion ) }}"
image: "{{ include "common.image" (tuple . .Values.otel.windows (tuple "image" "image_windows") "otel.windows.image" nil .Chart.AppVersion ) }}"
imagePullPolicy: {{ .Values.otel.windows.image.pullPolicy }}
securityContext:
windowsOptions:
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/templates/node-collector-daemon-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ spec:
{{- if include "isSwiEndpointCheckEnabled" . }}
initContainers:
- name: otel-endpoint-check
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- /swi-otelcol
Expand All @@ -108,7 +108,7 @@ spec:
{{- end }}
containers:
- name: swi-opentelemetry-collector
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" "otel.image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
securityContext:
readOnlyRootFilesystem: true
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/templates/swo-agent-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
{{- end }}
containers:
- name: swo-agent
image: "{{ include "common.image" (tuple . .Values.swoagent (tuple "image" "swoagent")) }}"
image: "{{ include "common.image" (tuple . .Values.swoagent (tuple "image" "swoagent") "swoagent.image") }}"
imagePullPolicy: {{ .Values.swoagent.image.pullPolicy }}
env:
- name: UAMS_CLIENT_ID_OVERRIDE_SOURCE_NAME
Expand Down
Loading