Skip to content

Commit

Permalink
Allow permission fixup to scratch space (#101)
Browse files Browse the repository at this point in the history
NFS Mounted Scratchspaces do not get properly permissioned according to
the k8s Volume 'fsGroup' property. The most common solution for fixing
this is to use an initContainer to fix the permissions before the target
deployed POD runs. This solution implements just such an initContainer.
By default, this change has no impact on existing deployments and is "on
by request only" feature.

This PR addresses #100

Signed-off-by: Adam Wallis <[email protected]>
  • Loading branch information
adawalli authored Jan 7, 2021
1 parent b06a85a commit e60ac75
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stable/anchore-engine/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: anchore-engine
version: 1.10.7
version: 1.10.8
appVersion: 0.8.2
description: Anchore container analysis and policy evaluation engine service
keywords:
Expand Down
14 changes: 14 additions & 0 deletions stable/anchore-engine/templates/analyzer_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ spec:
- name: {{ . }}
{{- end }}
{{- end }}
{{- if and .Values.anchoreGlobal.scratchVolume.fixGroupPermissions .Values.anchoreGlobal.securityContext.fsGroup }}
initContainers:
- name: mode-fixer
image: alpine
securityContext:
runAsUser: 0
volumeMounts:
- name: {{ $component }}-scratch
mountPath: {{ .Values.anchoreGlobal.scratchVolume.mountPath }}
command:
- sh
- -c
- (chmod 0775 {{ .Values.anchoreGlobal.scratchVolume.mountPath }}; chgrp {{ .Values.anchoreGlobal.securityContext.fsGroup }} {{ .Values.anchoreGlobal.scratchVolume.mountPath }} )
{{- end }}
containers:
{{- if .Values.cloudsql.enabled }}
- name: cloudsql-proxy
Expand Down
14 changes: 14 additions & 0 deletions stable/anchore-engine/templates/enterprise_feeds_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ spec:
{{- end }}
imagePullSecrets:
- name: {{ .Values.anchoreEnterpriseGlobal.imagePullSecretName }}
{{- if and .Values.anchoreGlobal.scratchVolume.fixGroupPermissions .Values.anchoreGlobal.securityContext.fsGroup }}
initContainers:
- name: mode-fixer
image: alpine
securityContext:
runAsUser: 0
volumeMounts:
- name: {{ $component }}-scratch
mountPath: {{ .Values.anchoreGlobal.scratchVolume.mountPath }}
command:
- sh
- -c
- (chmod 0775 {{ .Values.anchoreGlobal.scratchVolume.mountPath }}; chgrp {{ .Values.anchoreGlobal.securityContext.fsGroup }} {{ .Values.anchoreGlobal.scratchVolume.mountPath }} )
{{- end }}
containers:
{{- if .Values.cloudsql.enabled }}
- name: cloudsql-proxy
Expand Down
14 changes: 14 additions & 0 deletions stable/anchore-engine/templates/policy_engine_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ spec:
- name: {{ . }}
{{- end }}
{{- end }}
{{- if and .Values.anchoreGlobal.scratchVolume.fixGroupPermissions .Values.anchoreGlobal.securityContext.fsGroup }}
initContainers:
- name: mode-fixer
image: alpine
securityContext:
runAsUser: 0
volumeMounts:
- name: {{ $component }}-scratch
mountPath: {{ .Values.anchoreGlobal.scratchVolume.mountPath }}
command:
- sh
- -c
- (chmod 0775 {{ .Values.anchoreGlobal.scratchVolume.mountPath }}; chgrp {{ .Values.anchoreGlobal.securityContext.fsGroup }} {{ .Values.anchoreGlobal.scratchVolume.mountPath }} )
{{- end }}
containers:
{{- if .Values.cloudsql.enabled }}
- name: cloudsql-proxy
Expand Down
5 changes: 5 additions & 0 deletions stable/anchore-engine/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ anchoreGlobal:
# The scratchVolume controls the mounting of an external volume for scratch space for image analysis. Generally speaking
# you need to provision 3x the size of the largest image (uncompressed) that you want to analyze for this space.
scratchVolume:
# Some k8s Volumes do not properly respect the fsGroup permissions. These volumes will get mounted as root:root
# regardless of the security permissions requested. The fixGroupPermissions will create an initContainer that will
# fixup the permissions.
fixGroupPermissions: false
mountPath: /analysis_scratch
details:
# Specify volume configuration here
Expand All @@ -143,6 +147,7 @@ anchoreGlobal:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000

###
# Start of General Anchore Engine Configurations (populates /config/config.yaml)
Expand Down

0 comments on commit e60ac75

Please sign in to comment.