Skip to content
Snippets Groups Projects
Verified Commit a4f255de authored by Martin Weise's avatar Martin Weise
Browse files

Added correct securityconfig for openshift

parent aa77ed94
Branches
Tags
1 merge request!299Dev
...@@ -32,11 +32,11 @@ MAINTAINER Martin Weise <martin.weise@tuwien.ac.at> ...@@ -32,11 +32,11 @@ MAINTAINER Martin Weise <martin.weise@tuwien.ac.at>
ARG APP_VERSION="latest" ARG APP_VERSION="latest"
ARG COMMIT="" ARG COMMIT=""
USER 1000 USER 65534
WORKDIR /app WORKDIR /app
COPY --from=build --chown=1000:1000 /app/.output /app/.output COPY --from=build --chown=65534 /app/.output /app/.output
ENV NUXT_PUBLIC_VERSION="${APP_VERSION:-}" ENV NUXT_PUBLIC_VERSION="${APP_VERSION:-}"
ENV NUXT_PUBLIC_COMMIT="${COMMIT:-}" ENV NUXT_PUBLIC_COMMIT="${COMMIT:-}"
......
{{/*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{/* vim: set filetype=mustache: */}}
{{/*
Return true if the detected platform is Openshift
Usage:
{{- include "common.compatibility.isOpenshift" . -}}
*/}}
{{- define "common.compatibility.isOpenshift" -}}
{{- if .Capabilities.APIVersions.Has "security.openshift.io/v1" -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{/*
Render a compatible securityContext depending on the platform. By default it is maintained as it is. In other platforms like Openshift we remove default user/group values that do not work out of the box with the restricted-v1 SCC
Usage:
{{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) -}}
*/}}
{{- define "common.compatibility.renderSecurityContext" -}}
{{- $adaptedContext := .secContext -}}
{{- if (((.context.Values.global).compatibility).openshift) -}}
{{- if or (eq .context.Values.global.compatibility.openshift.adaptSecurityContext "force") (and (eq .context.Values.global.compatibility.openshift.adaptSecurityContext "auto") (include "common.compatibility.isOpenshift" .context)) -}}
{{/* Remove incompatible user/group values that do not work in Openshift out of the box */}}
{{- $adaptedContext = omit $adaptedContext "fsGroup" "runAsUser" "runAsGroup" -}}
{{- if not .secContext.seLinuxOptions -}}
{{/* If it is an empty object, we remove it from the resulting context because it causes validation issues */}}
{{- $adaptedContext = omit $adaptedContext "seLinuxOptions" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/* Remove fields that are disregarded when running the container in privileged mode */}}
{{- if $adaptedContext.privileged -}}
{{- $adaptedContext = omit $adaptedContext "capabilities" "seLinuxOptions" -}}
{{- end -}}
{{- omit $adaptedContext "enabled" | toYaml -}}
{{- end -}}
\ No newline at end of file
...@@ -22,25 +22,16 @@ spec: ...@@ -22,25 +22,16 @@ spec:
app: analyse-service app: analyse-service
service: analyse-service service: analyse-service
spec: spec:
securityContext: {{- if .Values.analyseservice.podSecurityContext.enabled }}
runAsNonRoot: true securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.analyseservice.podSecurityContext "context" $) | nindent 8 }}
fsGroup: 1001 {{- end }}
runAsUser: 1001
runAsGroup: 1001
containers: containers:
- name: analyse-service - name: analyse-service
image: {{ .Values.analyseservice.image.name }} image: {{ .Values.analyseservice.image.name }}
imagePullPolicy: {{ .Values.analyseservice.image.pullPolicy | default "IfNotPresent" }} imagePullPolicy: {{ .Values.analyseservice.image.pullPolicy | default "IfNotPresent" }}
securityContext: {{- if .Values.analyseservice.containerSecurityContext.enabled }}
allowPrivilegeEscalation: false securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.analyseservice.containerSecurityContext "context" $) | nindent 12 }}
runAsNonRoot: true {{- end }}
runAsUser: 1001
runAsGroup: 1001
seccompProfile:
type: {{ .Values.analyseservice.profileType | default "RuntimeDefault" }}
capabilities:
drop:
- ALL
ports: ports:
- containerPort: 8080 - containerPort: 8080
protocol: TCP protocol: TCP
...@@ -63,4 +54,7 @@ spec: ...@@ -63,4 +54,7 @@ spec:
- "curl -sSL localhost:8080/health | grep 'UP' || exit 1" - "curl -sSL localhost:8080/health | grep 'UP' || exit 1"
initialDelaySeconds: 10 initialDelaySeconds: 10
periodSeconds: 30 periodSeconds: 30
{{- if .Values.analyseservice.resources }}
resources: {{- toYaml .Values.analyseservice.resources | nindent 12 }}
{{- end }}
{{- end }} {{- end }}
...@@ -22,25 +22,16 @@ spec: ...@@ -22,25 +22,16 @@ spec:
app: data-service app: data-service
service: data-service service: data-service
spec: spec:
securityContext: {{- if .Values.dataservice.podSecurityContext.enabled }}
runAsNonRoot: true securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.dataservice.podSecurityContext "context" $) | nindent 8 }}
fsGroup: 65534 {{- end }}
runAsUser: 65534
runAsGroup: 65534
containers: containers:
- name: data-service - name: data-service
image: {{ .Values.dataservice.image.name }} image: {{ .Values.dataservice.image.name }}
imagePullPolicy: {{ .Values.dataservice.image.pullPolicy | default "IfNotPresent" }} imagePullPolicy: {{ .Values.dataservice.image.pullPolicy | default "IfNotPresent" }}
securityContext: {{- if .Values.dataservice.containerSecurityContext.enabled }}
allowPrivilegeEscalation: false securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.dataservice.containerSecurityContext "context" $) | nindent 12 }}
runAsNonRoot: true {{- end }}
runAsUser: 65534
runAsGroup: 65534
seccompProfile:
type: {{ .Values.dataservice.profileType | default "RuntimeDefault" }}
capabilities:
drop:
- ALL
ports: ports:
- containerPort: 80 - containerPort: 80
protocol: TCP protocol: TCP
...@@ -63,6 +54,9 @@ spec: ...@@ -63,6 +54,9 @@ spec:
- "curl -sSL localhost:8080/actuator/health/liveness | grep 'UP' || exit 1" - "curl -sSL localhost:8080/actuator/health/liveness | grep 'UP' || exit 1"
initialDelaySeconds: 30 initialDelaySeconds: 30
periodSeconds: 30 periodSeconds: 30
{{- if .Values.dataservice.resources }}
resources: {{- toYaml .Values.dataservice.resources | nindent 12 }}
{{- end }}
volumeMounts: [] volumeMounts: []
volumes: [] volumes: []
{{- end }} {{- end }}
...@@ -22,25 +22,16 @@ spec: ...@@ -22,25 +22,16 @@ spec:
app: metadata-service app: metadata-service
service: metadata-service service: metadata-service
spec: spec:
securityContext: {{- if .Values.metadataservice.podSecurityContext.enabled }}
runAsNonRoot: true securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.metadataservice.podSecurityContext "context" $) | nindent 8 }}
fsGroup: 65534 {{- end }}
runAsUser: 65534
runAsGroup: 65534
containers: containers:
- name: metadata-service - name: metadata-service
image: {{ .Values.metadataservice.image.name }} image: {{ .Values.metadataservice.image.name }}
imagePullPolicy: {{ .Values.metadataservice.image.pullPolicy | default "IfNotPresent" }} imagePullPolicy: {{ .Values.metadataservice.image.pullPolicy | default "IfNotPresent" }}
securityContext: {{- if .Values.metadataservice.containerSecurityContext.enabled }}
allowPrivilegeEscalation: false securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.metadataservice.containerSecurityContext "context" $) | nindent 12 }}
runAsNonRoot: true {{- end }}
runAsUser: 65534
runAsGroup: 65534
seccompProfile:
type: {{ .Values.metadataservice.profileType | default "RuntimeDefault" }}
capabilities:
drop:
- ALL
ports: ports:
- containerPort: 80 - containerPort: 80
protocol: TCP protocol: TCP
...@@ -63,4 +54,7 @@ spec: ...@@ -63,4 +54,7 @@ spec:
- "curl -sSL localhost:8080/actuator/health/liveness | grep 'UP' || exit 1" - "curl -sSL localhost:8080/actuator/health/liveness | grep 'UP' || exit 1"
initialDelaySeconds: 30 initialDelaySeconds: 30
periodSeconds: 30 periodSeconds: 30
{{- if .Values.metadataservice.resources }}
resources: {{- toYaml .Values.metadataservice.resources | nindent 12 }}
{{- end }}
{{- end }} {{- end }}
...@@ -22,25 +22,16 @@ spec: ...@@ -22,25 +22,16 @@ spec:
app: search-service app: search-service
service: search-service service: search-service
spec: spec:
securityContext: {{- if .Values.searchservice.podSecurityContext.enabled }}
runAsNonRoot: true securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.searchservice.podSecurityContext "context" $) | nindent 8 }}
fsGroup: 1001 {{- end }}
runAsUser: 1001
runAsGroup: 1001
initContainers: initContainers:
- name: init - name: init
image: {{ .Values.searchservice.init.image.name }} image: {{ .Values.searchservice.init.image.name }}
imagePullPolicy: {{ .Values.searchservice.init.image.pullPolicy | default "IfNotPresent" }} imagePullPolicy: {{ .Values.searchservice.init.image.pullPolicy | default "IfNotPresent" }}
securityContext: {{- if .Values.searchservice.containerSecurityContext.enabled }}
allowPrivilegeEscalation: false securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.searchservice.containerSecurityContext "context" $) | nindent 12 }}
runAsNonRoot: true {{- end }}
runAsUser: 1001
runAsGroup: 1001
seccompProfile:
type: {{ .Values.searchservice.profileType | default "RuntimeDefault" }}
capabilities:
drop:
- ALL
envFrom: envFrom:
- secretRef: - secretRef:
name: search-service-secret name: search-service-secret
...@@ -80,6 +71,9 @@ spec: ...@@ -80,6 +71,9 @@ spec:
- "curl -sSL localhost:8080/health | grep 'UP' || exit 1" - "curl -sSL localhost:8080/health | grep 'UP' || exit 1"
initialDelaySeconds: 10 initialDelaySeconds: 10
periodSeconds: 30 periodSeconds: 30
{{- if .Values.searchservice.resources }}
resources: {{- toYaml .Values.searchservice.resources | nindent 12 }}
{{- end }}
volumeMounts: [ ] volumeMounts: [ ]
volumes: [ ] volumes: [ ]
{{- end }} {{- end }}
...@@ -22,22 +22,16 @@ spec: ...@@ -22,22 +22,16 @@ spec:
app: ui app: ui
service: ui service: ui
spec: spec:
securityContext: {{- if .Values.ui.podSecurityContext.enabled }}
runAsNonRoot: true securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.ui.podSecurityContext "context" $) | nindent 8 }}
fsGroup: 1000 {{- end }}
runAsUser: 1000
runAsGroup: 1000
containers: containers:
- name: ui - name: ui
image: {{ .Values.ui.image.name }} image: {{ .Values.ui.image.name }}
imagePullPolicy: {{ .Values.ui.image.pullPolicy | default "IfNotPresent" }} imagePullPolicy: {{ .Values.ui.image.pullPolicy | default "IfNotPresent" }}
securityContext: {{- if .Values.ui.containerSecurityContext.enabled }}
allowPrivilegeEscalation: false securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.ui.containerSecurityContext "context" $) | nindent 12 }}
seccompProfile: {{- end }}
type: {{ .Values.ui.profileType | default "RuntimeDefault" }}
capabilities:
drop:
- ALL
ports: ports:
- containerPort: 3000 - containerPort: 3000
protocol: TCP protocol: TCP
...@@ -143,6 +137,9 @@ spec: ...@@ -143,6 +137,9 @@ spec:
port: 3000 port: 3000
initialDelaySeconds: 30 initialDelaySeconds: 30
periodSeconds: 30 periodSeconds: 30
{{- if .Values.ui.resources }}
resources: {{- toYaml .Values.ui.resources | nindent 12 }}
{{- end }}
volumes: volumes:
{{- if .Values.ui.extraVolumes }} {{- if .Values.ui.extraVolumes }}
{{- .Values.ui.extraVolumes | toYaml | nindent 8 }} {{- .Values.ui.extraVolumes | toYaml | nindent 8 }}
......
...@@ -336,6 +336,32 @@ analyseservice: ...@@ -336,6 +336,32 @@ analyseservice:
pullPolicy: Always pullPolicy: Always
## @param analyseservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`. ## @param analyseservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`.
debug: false debug: false
podSecurityContext:
enabled: true
fsGroupChangePolicy: Always
sysctls: [ ]
supplementalGroups: [ ]
fsGroup: 1001
containerSecurityContext:
enabled: true
seLinuxOptions: null
runAsUser: 1001
runAsGroup: 1001
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
capabilities:
drop: [ "ALL" ]
seccompProfile:
type: "RuntimeDefault"
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 500m
memory: 2048Mi
## @param analyseservice.endpoint The url of the endpoint. ## @param analyseservice.endpoint The url of the endpoint.
endpoint: http://analyse-service endpoint: http://analyse-service
s3: s3:
...@@ -356,6 +382,31 @@ metadataservice: ...@@ -356,6 +382,31 @@ metadataservice:
pullPolicy: Always pullPolicy: Always
## @param metadataservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`. ## @param metadataservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`.
debug: false debug: false
podSecurityContext:
enabled: true
fsGroupChangePolicy: Always
sysctls: [ ]
supplementalGroups: [ ]
fsGroup: 1001
containerSecurityContext:
enabled: true
seLinuxOptions: null
runAsUser: 1001
runAsGroup: 1001
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
capabilities:
drop: [ "ALL" ]
seccompProfile:
type: "RuntimeDefault"
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 1000m
memory: 2048Mi
## @param metadataservice.endpoint The Metadata Service endpoint. ## @param metadataservice.endpoint The Metadata Service endpoint.
endpoint: http://metadata-service endpoint: http://metadata-service
admin: admin:
...@@ -410,6 +461,31 @@ dataservice: ...@@ -410,6 +461,31 @@ dataservice:
pullPolicy: Always pullPolicy: Always
## @param dataservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`. ## @param dataservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`.
debug: false debug: false
podSecurityContext:
enabled: true
fsGroupChangePolicy: Always
sysctls: [ ]
supplementalGroups: [ ]
fsGroup: 1001
containerSecurityContext:
enabled: true
seLinuxOptions: null
runAsUser: 1001
runAsGroup: 1001
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
capabilities:
drop: [ "ALL" ]
seccompProfile:
type: "RuntimeDefault"
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 1000m
memory: 2048Mi
grant: grant:
## @param dataservice.grant.read The default database permissions for users with read access. ## @param dataservice.grant.read The default database permissions for users with read access.
read: SELECT read: SELECT
...@@ -465,6 +541,31 @@ searchservice: ...@@ -465,6 +541,31 @@ searchservice:
pullPolicy: Always pullPolicy: Always
## @param searchservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`. ## @param searchservice.image.debug Set the logging level to `trace`. Otherwise, set to `info`.
debug: false debug: false
podSecurityContext:
enabled: true
fsGroupChangePolicy: Always
sysctls: [ ]
supplementalGroups: [ ]
fsGroup: 1001
containerSecurityContext:
enabled: true
seLinuxOptions: null
runAsUser: 1001
runAsGroup: 1001
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: [ "ALL" ]
seccompProfile:
type: "RuntimeDefault"
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 1000m
memory: 2048Mi
## @skip searchservice.init ## @skip searchservice.init
init: init:
image: image:
...@@ -583,6 +684,31 @@ ui: ...@@ -583,6 +684,31 @@ ui:
pullPolicy: Always pullPolicy: Always
## @param ui.image.debug Set the logging level to `trace`. Otherwise, set to `info`. ## @param ui.image.debug Set the logging level to `trace`. Otherwise, set to `info`.
debug: false debug: false
podSecurityContext:
enabled: true
fsGroupChangePolicy: Always
sysctls: [ ]
supplementalGroups: [ ]
fsGroup: 1000
containerSecurityContext:
enabled: true
seLinuxOptions: null
runAsUser: 1000
runAsGroup: 1000
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
capabilities:
drop: [ "ALL" ]
seccompProfile:
type: "RuntimeDefault"
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 1000m
memory: 2048Mi
public: public:
api: api:
## @param ui.public.api.client The endpoint for the client api. ## @param ui.public.api.client The endpoint for the client api.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment