Skip to content

Commit 0a36fa7

Browse files
authored
fix: allow pre-upgrade job pods to honor global security context (#670)
* fix: allow pre-upgrade job pods to honor global security context The pre-upgrade hook jobs (job-createSecret and job-patchWebhook) had hardcoded pod-level security context values that did not use global settings, while the main deployment already supports global pod/container security context. This fix updates the job templates to use the same security context helper as the deployment, enabling them to: 1. Honor global.podSecurityContext when provided (e.g., from nri-bundle) 2. Maintain backward compatibility with fallback values (runAsUser: 2000, runAsGroup: 2000) Changes: - Updated job-createSecret.yaml to use nri-metadata-injection.securityContext.pod helper - Updated job-patchWebhook.yaml to use nri-metadata-injection.securityContext.pod helper - Updated _helpers.tpl fallback values to maintain original behavior (runAsUser: 2000, runAsGroup: 2000) This enables consistent security posture across all nri-metadata-injection components and allows proper integration with nri-bundle's global security configuration. * docs: add changelog entry for global security context support
1 parent 31053d7 commit 0a36fa7

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### 🔒 Security
11+
- Allow pre-upgrade job pods to honor global security context settings @dpacheconr [#670](https://github.com/newrelic/k8s-metadata-injection/pull/670)
12+
1013
## v1.38.1 - 2025-10-20
1114

1215
### ⛓️ Dependencies

charts/nri-metadata-injection/templates/_helpers.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
{{- include "newrelic.common.securityContext.pod" . -}}
77
{{- else -}}
88
fsGroup: 1001
9-
runAsUser: 1001
10-
runAsGroup: 1001
9+
runAsUser: 2000
10+
runAsGroup: 2000
11+
runAsNonRoot: true
1112
{{- end -}}
1213
{{- end -}}
1314

charts/nri-metadata-injection/templates/admission-webhooks/job-patch/job-createSecret.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ spec:
5151
{{- end }}
5252
restartPolicy: OnFailure
5353
serviceAccountName: {{ include "nri-metadata-injection.fullname.admission.serviceAccount" . }}
54+
{{- with include "nri-metadata-injection.securityContext.pod" . }}
5455
securityContext:
55-
runAsGroup: 2000
56-
runAsNonRoot: true
57-
runAsUser: 2000
56+
{{- . | nindent 8 }}
57+
{{- end }}
5858
nodeSelector:
5959
kubernetes.io/os: linux
6060
{{ include "newrelic.common.nodeSelector" . | nindent 8 }}

charts/nri-metadata-injection/templates/admission-webhooks/job-patch/job-patchWebhook.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ spec:
5151
{{- end }}
5252
restartPolicy: OnFailure
5353
serviceAccountName: {{ include "nri-metadata-injection.fullname.admission.serviceAccount" . }}
54+
{{- with include "nri-metadata-injection.securityContext.pod" . }}
5455
securityContext:
55-
runAsGroup: 2000
56-
runAsNonRoot: true
57-
runAsUser: 2000
56+
{{- . | nindent 8 }}
57+
{{- end }}
5858
nodeSelector:
5959
kubernetes.io/os: linux
6060
{{ include "newrelic.common.nodeSelector" . | nindent 8 }}

0 commit comments

Comments
 (0)