Skip to content

Commit

Permalink
Extend options for setting security context
Browse files Browse the repository at this point in the history
Add options to set container security contexts in clusterRecever and gateway deployments.
  • Loading branch information
dmitryax committed Feb 5, 2025
1 parent 8dfbe93 commit 12dcb22
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement
# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, operator, chart, other)
component: clusterReceiver
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add an option to set the security context for the container.
# One or more tracking issues related to the change
issues: [1647]
8 changes: 8 additions & 0 deletions .chloggen/add-container-security-context-option-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement
# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, operator, chart, other)
component: gateway
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add an option to set the security context for the container.
# One or more tracking issues related to the change
issues: [1647]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation
# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, operator, chart, other)
component: clusterReceiver
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate the `securityContext` field in favor of the `podSecurityContext`.
# One or more tracking issues related to the change
issues: [1647]
8 changes: 8 additions & 0 deletions .chloggen/deprecate-security-context-option-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation
# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, operator, chart, other)
component: gateway
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate the `securityContext` field in favor of the `podSecurityContext`.
# One or more tracking issues related to the change
issues: [1647]
6 changes: 6 additions & 0 deletions helm-charts/splunk-otel-collector/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ Splunk OpenTelemetry Collector is installed and configured to send data to Splun
- Status: Instrumentation language maturity varies. See `operator.instrumentation.spec` and documentation for utilized instrumentation details.
- Splunk Support: We offer full support for Splunk distributions and best-effort support for native OpenTelemetry distributions of auto-instrumentation libraries.
{{- end }}
{{- if not (eq (toString .Values.gateway.securityContext) "<nil>") }}
[WARNING] "gateway.securityContext" parameter is deprecated. Please use "gateway.podSecurityContext" instead.
{{ end }}
{{- if not (eq (toString .Values.clusterReceiver.securityContext) "<nil>") }}
[WARNING] "clusterReceiver.securityContext" parameter is deprecated. Please use "clusterReceiver.podSecurityContext" instead.
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ spec:
` }}
{{- $clusterReceiver.affinity | mustMergeOverwrite (fromYaml $clusterReceiverPodAntiAffinity) | toYaml | nindent 8 }}
{{- end }}
{{- if $clusterReceiver.securityContext }}
{{- $podSecurityContext := $clusterReceiver.podSecurityContext | default $clusterReceiver.securityContext }}
{{- if $podSecurityContext }}
securityContext:
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $clusterReceiver.securityContext) | nindent 8 }}
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $podSecurityContext) | nindent 8 }}
{{- end }}
{{- if eq (include "splunk-otel-collector.distribution" .) "eks/fargate" }}
initContainers:
Expand Down Expand Up @@ -127,6 +128,10 @@ spec:
{{- if .Values.clusterReceiver.featureGates }}
- --feature-gates={{ .Values.clusterReceiver.featureGates }}
{{- end }}
{{- with .Values.clusterReceiver.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
image: {{ template "splunk-otel-collector.image.otelcol" . }}
imagePullPolicy: {{ .Values.image.otelcol.pullPolicy }}
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ spec:
affinity:
{{- toYaml $gateway.affinity | nindent 8 }}
{{- end }}
{{- if $gateway.securityContext }}
{{- $podSecurityContext := $gateway.podSecurityContext | default $gateway.securityContext }}
{{- if $podSecurityContext }}
securityContext:
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $gateway.securityContext) | nindent 8 }}
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $podSecurityContext) | nindent 8 }}
{{- end }}
containers:
- name: otel-collector
Expand All @@ -80,6 +81,10 @@ spec:
{{- if .Values.gateway.featureGates }}
- --feature-gates={{ .Values.gateway.featureGates }}
{{- end }}
{{- with .Values.gateway.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
image: {{ template "splunk-otel-collector.image.otelcol" . }}
imagePullPolicy: {{ .Values.image.otelcol.pullPolicy }}
env:
Expand Down
14 changes: 14 additions & 0 deletions helm-charts/splunk-otel-collector/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,13 @@
"type": "object"
},
"securityContext": {
"description": "[DEPRECATED] Use podSecurityContext instead.",
"type": "object"
},
"podSecurityContext": {
"type": "object"
},
"containerSecurityContext": {
"type": "object"
},
"terminationGracePeriodSeconds": {
Expand Down Expand Up @@ -1348,6 +1355,13 @@
"type": "object"
},
"securityContext": {
"description": "[DEPRECATED] Use podSecurityContext instead.",
"type": "object"
},
"podSecurityContext": {
"type": "object"
},
"containerSecurityContext": {
"type": "object"
},
"terminationGracePeriodSeconds": {
Expand Down
10 changes: 8 additions & 2 deletions helm-charts/splunk-otel-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,13 @@ clusterReceiver:
affinity: {}

# Pod configurations
securityContext: {}
podSecurityContext: {}
terminationGracePeriodSeconds: 600
priorityClassName: ""

# Security context applied to the otel-collector container in the cluster receiver deployment.
containerSecurityContext: {}

# k8s cluster receiver collector annotations
annotations: {}
podAnnotations: {}
Expand Down Expand Up @@ -1138,10 +1141,13 @@ gateway:
affinity: {}

# Pod configurations
securityContext: {}
podSecurityContext: {}
terminationGracePeriodSeconds: 600
priorityClassName: ""

# Security context applied to the otel-collector container in the gateway deployment.
containerSecurityContext: {}

# OTel collector annotations
annotations: {}
podAnnotations: {}
Expand Down

0 comments on commit 12dcb22

Please sign in to comment.