Skip to content

Commit

Permalink
runAsUser SecurityContext not working for windows
Browse files Browse the repository at this point in the history
Signed-off-by: Dani Louca <[email protected]>
  • Loading branch information
dloucasfx committed May 26, 2023
1 parent fdb574c commit 63d29a6
Show file tree
Hide file tree
Showing 33 changed files with 71 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ spec:
values:
- otel-k8s-cluster-receiver
topologyKey: kubernetes.io/hostname
securityContext:
runAsUser: "0"
initContainers:
- name: cluster-receiver-node-discoverer
image: public.ecr.aws/amazonlinux/amazonlinux:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: windows
securityContext:
{}
containers:
- name: otel-collector
command:
Expand Down
2 changes: 1 addition & 1 deletion examples/only-logs-otel/rendered_manifests/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ spec:
image: quay.io/signalfx/splunk-otel-collector:0.76.0
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 0
runAsUser: "0"
env:
- name: SPLUNK_MEMORY_TOTAL_MIB
value: "500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ spec:
image: quay.io/signalfx/splunk-otel-collector:0.76.0
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 0
runAsUser: "0"
env:
- name: SPLUNK_MEMORY_TOTAL_MIB
value: "500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
serviceAccountName: default-splunk-otel-collector
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsUser: "0"
containers:
- name: otel-collector
command:
Expand Down
13 changes: 13 additions & 0 deletions helm-charts/splunk-otel-collector/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,16 @@ Whether clusterReceiver should be enabled
{{- $clusterReceiver := fromYaml (include "splunk-otel-collector.clusterReceiver" .) }}
{{- and $clusterReceiver.enabled (or (eq (include "splunk-otel-collector.metricsEnabled" .) "true") (eq (include "splunk-otel-collector.objectsOrEventsEnabled" .) "true")) -}}
{{- end -}}


{{/*
Build the securityContext for Linux and Windows
*/}}
{{- define "splunk-otel-collector.securityContext" -}}
{{- if .isWindows }}
{{- $_ := unset .securityContext "runAsUser" }}
{{- else if (eq (toString .securityContext.runAsUser) "<nil>") }}
{{- $_ := set .securityContext "runAsUser" 0 }}
{{- end }}
{{- toYaml .securityContext }}
{{- end -}}
6 changes: 1 addition & 5 deletions helm-charts/splunk-otel-collector/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,7 @@ spec:
imagePullPolicy: {{ .Values.image.otelcol.pullPolicy }}
{{- if or $agent.securityContext (and (eq (include "splunk-otel-collector.logsEnabled" $) "true") (eq .Values.logsEngine "otel")) }}
securityContext:
{{- if $agent.securityContext }}
{{- toYaml $agent.securityContext | nindent 10 }}
{{- else }}
runAsUser: 0
{{- end }}
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $agent.securityContext) | nindent 10 }}
{{- end }}
env:
- name: SPLUNK_MEMORY_TOTAL_MIB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ spec:
` }}
{{- $clusterReceiver.affinity | mustMergeOverwrite (fromYaml $clusterReceiverPodAntiAffinity) | toYaml | nindent 8 }}
{{- end }}
{{- if $clusterReceiver.securityContext }}
securityContext:
{{ toYaml $clusterReceiver.securityContext | nindent 8 }}
{{- end }}
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $clusterReceiver.securityContext) | nindent 8 }}
{{- if eq (include "splunk-otel-collector.distribution" .) "eks/fargate" }}
initContainers:
- name: cluster-receiver-node-discoverer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ spec:
affinity:
{{- toYaml $gateway.affinity | nindent 8 }}
{{- end }}
{{- if $gateway.securityContext }}
securityContext:
{{ toYaml $gateway.securityContext | nindent 8 }}
{{- end }}
{{- include "splunk-otel-collector.securityContext" (dict "isWindows" .Values.isWindows "securityContext" $gateway.securityContext) | nindent 8 }}
containers:
- name: otel-collector
command:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if or (and (.Values.fluentd.securityContext.runAsUser) (.Values.fluentd.securityContext.runAsGroup)) (and (.Values.agent.securityContext.runAsUser) (.Values.agent.securityContext.runAsGroup)) }}
{{- if or (and (.Values.fluentd.securityContext.runAsUser) (.Values.fluentd.securityContext.runAsGroup) (not .Values.isWindows) ) (and (.Values.agent.securityContext.runAsUser) (.Values.agent.securityContext.runAsGroup) (not .Values.isWindows) ) }}
apiVersion: v1
kind: Pod
metadata:
Expand Down

0 comments on commit 63d29a6

Please sign in to comment.