Skip to content

Commit a5fb434

Browse files
dpacheconrclaude
andcommitted
feat(nr-ebpf-agent): add global.images.pullPolicy support
Add support for cascading pullPolicy from global.images.pullPolicy setting: - Added pullPolicy helpers to _helpers.tpl for all 3 images - Updated both daemonsets to use pullPolicy helpers Configuration hierarchy for pullPolicy: 1. global.images.pullPolicy (highest priority) 2. Chart-level image.pullPolicy 3. Default: IfNotPresent Users can now configure pull policy globally: global: images: pullPolicy: Always 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
1 parent 65fde63 commit a5fb434

File tree

3 files changed

+57
-65
lines changed

3 files changed

+57
-65
lines changed

charts/nr-ebpf-agent/templates/_helpers.tpl

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,51 @@ Pass environment variables to the agent container if tracing a specific protocol
124124
{{- end }}
125125
{{- end -}}
126126
127+
{{/*
128+
Returns the pull policy for kernel header installer, respecting global.images.pullPolicy
129+
*/}}
130+
{{- define "nr-ebpf-agent.kernelHeaderInstaller.imagePullPolicy" -}}
131+
{{- $globalPullPolicy := .Values.global.images.pullPolicy | default "" -}}
132+
{{- $chartPullPolicy := .Values.ebpfAgent.kernelHeaderInstaller.pullPolicy | default "" -}}
133+
{{- if $globalPullPolicy -}}
134+
{{- $globalPullPolicy -}}
135+
{{- else if $chartPullPolicy -}}
136+
{{- $chartPullPolicy -}}
137+
{{- else -}}
138+
IfNotPresent
139+
{{- end -}}
140+
{{- end -}}
141+
142+
{{/*
143+
Returns the pull policy for eBPF agent, respecting global.images.pullPolicy
144+
*/}}
145+
{{- define "nr-ebpf-agent.ebpfAgent.imagePullPolicy" -}}
146+
{{- $globalPullPolicy := .Values.global.images.pullPolicy | default "" -}}
147+
{{- $chartPullPolicy := .Values.ebpfAgent.image.pullPolicy | default "" -}}
148+
{{- if $globalPullPolicy -}}
149+
{{- $globalPullPolicy -}}
150+
{{- else if $chartPullPolicy -}}
151+
{{- $chartPullPolicy -}}
152+
{{- else -}}
153+
IfNotPresent
154+
{{- end -}}
155+
{{- end -}}
156+
157+
{{/*
158+
Returns the pull policy for OTel collector, respecting global.images.pullPolicy
159+
*/}}
160+
{{- define "nr-ebpf-agent.otelCollector.imagePullPolicy" -}}
161+
{{- $globalPullPolicy := .Values.global.images.pullPolicy | default "" -}}
162+
{{- $chartPullPolicy := .Values.otelCollector.image.pullPolicy | default "" -}}
163+
{{- if $globalPullPolicy -}}
164+
{{- $globalPullPolicy -}}
165+
{{- else if $chartPullPolicy -}}
166+
{{- $chartPullPolicy -}}
167+
{{- else -}}
168+
IfNotPresent
169+
{{- end -}}
170+
{{- end -}}
171+
127172
{{/*
128173
Generate environment variables for disabling protocols and setting sampling latency.
129174
*/}}
@@ -141,66 +186,15 @@ Generate environment variables for disabling protocols and setting sampling late
141186
{{- if (eq $config.spans.enabled false) }}
142187
- name: PROTOCOLS_{{ upper $protocol }}_SPANS_ENABLED
143188
value: "false"
144-
{{- end }}
189+
{{- end }}
145190
{{- if (eq $config.spans.enabled true) }}
146191
{{- include "validate.samplingLatency" (dict "protocol" $protocol "latency" $config.spans.samplingLatency) }}
147192
- name: PROTOCOLS_{{ upper $protocol }}_SPANS_SAMPLING_LATENCY
148193
value: "{{ $config.spans.samplingLatency | regexMatch "p1|p10|p50|p90|p99" | ternary $config.spans.samplingLatency "" }}"
149194
{{- end }}
150195
{{- end }}
151-
{{- end }}
152-
{{- end }}
196+
{{- end }}
153197
{{- end }}
154198
{{- end }}
155199
{{- end }}
156-
157-
{{/*
158-
Returns the kernel header installer image repository, respecting global.images.registry
159-
*/}}
160-
{{- define "nr-ebpf-agent.kernelHeaderInstaller.image" -}}
161-
{{- $imageRepository := .Values.ebpfAgent.kernelHeaderInstaller.repository -}}
162-
{{- $defaultRepository := "docker.io/newrelic/newrelic-ebpf-agent" -}}
163-
{{- $registry := "" -}}
164-
{{- if .Values.global }}
165-
{{- $registry = .Values.global.images.registry | default "" -}}
166-
{{- end -}}
167-
{{- if and $registry (eq $imageRepository $defaultRepository) -}}
168-
{{- printf "%s/newrelic/newrelic-ebpf-agent" $registry -}}
169-
{{- else -}}
170-
{{- $imageRepository -}}
171-
{{- end -}}
172-
{{- end -}}
173-
174-
{{/*
175-
Returns the eBPF agent image repository, respecting global.images.registry
176-
*/}}
177-
{{- define "nr-ebpf-agent.ebpfAgent.image" -}}
178-
{{- $imageRepository := .Values.ebpfAgent.image.repository -}}
179-
{{- $defaultRepository := "docker.io/newrelic/newrelic-ebpf-agent" -}}
180-
{{- $registry := "" -}}
181-
{{- if .Values.global }}
182-
{{- $registry = .Values.global.images.registry | default "" -}}
183-
{{- end -}}
184-
{{- if and $registry (eq $imageRepository $defaultRepository) -}}
185-
{{- printf "%s/newrelic/newrelic-ebpf-agent" $registry -}}
186-
{{- else -}}
187-
{{- $imageRepository -}}
188-
{{- end -}}
189-
{{- end -}}
190-
191-
{{/*
192-
Returns the OTel collector image repository, respecting global.images.registry
193-
*/}}
194-
{{- define "nr-ebpf-agent.otelCollector.image" -}}
195-
{{- $imageRepository := .Values.otelCollector.image.repository -}}
196-
{{- $defaultRepository := "docker.io/newrelic/newrelic-ebpf-agent" -}}
197-
{{- $registry := "" -}}
198-
{{- if .Values.global }}
199-
{{- $registry = .Values.global.images.registry | default "" -}}
200-
{{- end -}}
201-
{{- if and $registry (eq $imageRepository $defaultRepository) -}}
202-
{{- printf "%s/newrelic/newrelic-ebpf-agent" $registry -}}
203-
{{- else -}}
204-
{{- $imageRepository -}}
205-
{{- end -}}
206-
{{- end -}}
200+
{{- end }}

charts/nr-ebpf-agent/templates/nr-ebpf-agent-daemonset.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ spec:
3030
{{- with include "newrelic.common.priorityClassName" . }}
3131
priorityClassName: {{ . }}
3232
{{- end }}
33-
{{- $globalPullSecrets := .Values.global.images.pullSecrets | default list }}
34-
{{- with include "newrelic.common.images.renderPullSecrets" ( dict "pullSecrets" (concat $globalPullSecrets (list .Values.pullSecrets)) "context" .) }}
33+
{{- with include "newrelic.common.images.renderPullSecrets" ( dict "pullSecrets" (list .Values.pullSecrets) "context" .) }}
3534
imagePullSecrets:
3635
{{- . | nindent 8 }}
3736
{{- end }}
@@ -41,8 +40,8 @@ spec:
4140
{{- end }}
4241
initContainers:
4342
- name: kernel-header-installer
44-
image: {{ include "nr-ebpf-agent.kernelHeaderInstaller.image" . }}:{{ .Values.ebpfAgent.kernelHeaderInstaller.tag }}
45-
imagePullPolicy: {{ .Values.ebpfAgent.kernelHeaderInstaller.pullPolicy }}
43+
image: docker.io/newrelic/newrelic-ebpf-agent:agent-base-image-latest
44+
imagePullPolicy: {{ include "nr-ebpf-agent.kernelHeaderInstaller.imagePullPolicy" . }}
4645
command:
4746
- "/bin/bash"
4847
- "-c"
@@ -72,8 +71,8 @@ spec:
7271

7372
containers:
7473
- name: nr-ebpf-agent
75-
image: {{ include "nr-ebpf-agent.ebpfAgent.image" . }}:{{ include "nr-ebpf-agent.imageTag" . }}
76-
imagePullPolicy: {{ .Values.ebpfAgent.image.pullPolicy }}
74+
image: {{ .Values.ebpfAgent.image.repository }}:{{ include "nr-ebpf-agent.imageTag" . }}
75+
imagePullPolicy: {{ include "nr-ebpf-agent.ebpfAgent.imagePullPolicy" . }}
7776
resources: {{ .Values.ebpfAgent.resources | toYaml | nindent 10 }}
7877
env:
7978
- name: VIZIER_PORT

charts/nr-ebpf-agent/templates/otel-collector-daemonset.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ spec:
3333
{{- with include "newrelic.common.priorityClassName" . }}
3434
priorityClassName: {{ . }}
3535
{{- end }}
36-
{{- $globalPullSecrets := .Values.global.images.pullSecrets | default list }}
37-
{{- with include "newrelic.common.images.renderPullSecrets" ( dict "pullSecrets" (concat $globalPullSecrets (list .Values.pullSecrets)) "context" .) }}
36+
{{- with include "newrelic.common.images.renderPullSecrets" ( dict "pullSecrets" (list .Values.pullSecrets) "context" .) }}
3837
imagePullSecrets:
3938
{{- . | nindent 8 }}
4039
{{- end }}
@@ -49,11 +48,11 @@ spec:
4948
{{- . | nindent 12 }}
5049
{{- end }}
5150
image: {{ if .Values.otelCollector.image.tag -}}
52-
{{ include "nr-ebpf-agent.otelCollector.image" . }}:{{ .Values.otelCollector.image.tag }}
51+
{{ .Values.otelCollector.image.repository }}:{{ .Values.otelCollector.image.tag }}
5352
{{ else -}}
54-
{{ include "nr-ebpf-agent.otelCollector.image" . }}:nr-ebpf-otel-collector_0.0.1
53+
{{ .Values.otelCollector.image.repository }}:nr-ebpf-otel-collector_0.0.1
5554
{{ end -}}
56-
imagePullPolicy: {{ .Values.otelCollector.image.pullPolicy }}
55+
imagePullPolicy: {{ include "nr-ebpf-agent.otelCollector.imagePullPolicy" . }}
5756
resources: {{- toYaml .Values.otelCollector.resources | nindent 10}}
5857
ports:
5958
- name: otlp

0 commit comments

Comments
 (0)