Skip to content

Commit

Permalink
add scc flag for registry service when custom name is defined (#1967)
Browse files Browse the repository at this point in the history
* add scc flag for registry service when custom name is defined

* add scc template

* add scc test cases

* fix pre-commit
  • Loading branch information
pgvishnuram committed Aug 24, 2023
1 parent b6e796e commit 529567a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
42 changes: 42 additions & 0 deletions charts/astronomer/templates/registry/registry-scc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#################################
### Astronomer Registry Scc ###
#################################
{{- if and .Values.registry.serviceAccount.create .Values.registry.serviceAccount.sccEnabled }}
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
annotations:
release.openshift.io/create-only: "true"
"helm.sh/hook": "pre-install,pre-upgrade"
name: {{ template "registry.ServiceAccount" . }}-anyuid
priority: 10
readOnlyRootFilesystem: false
requiredDropCapabilities:
- MKNOD
runAsUser:
type: RunAsAny
seLinuxContext:
type: MustRunAs
supplementalGroups:
type: RunAsAny
users:
- system:serviceaccount:{{ .Release.Namespace }}:{{ template "registry.ServiceAccount" . }}
volumes:
- configMap
- downwardAPI
- emptyDir
- persistentVolumeClaim
- projected
- secret
defaultAddCapabilities: null
fsGroup:
type: RunAsAny
allowHostDirVolumePlugin: false
allowHostIPC: false
allowHostNetwork: false
allowHostPID: false
allowHostPorts: false
allowPrivilegeEscalation: false
allowPrivilegedContainer: false
allowedCapabilities: null
{{- end }}
2 changes: 2 additions & 0 deletions charts/astronomer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ registry:
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
# Specifies whether a scc privilege should be created for custom sa
sccEnabled: false

persistence:
# Enable persistent storage
Expand Down
12 changes: 12 additions & 0 deletions tests/chart_tests/test_astronomer_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,15 @@ def test_astronomer_registry_statefulset_with_serviceaccount_disabled(
)
assert len(docs) == 1
assert "serviceAccountName" not in docs[0]["spec"]["template"]["spec"]

def test_astronomer_registry_statefulset_with_scc_disabled(self, kube_version):
"""Test that helm renders statefulset template for astronomer
registry with SA disabled."""
docs = render_chart(
kube_version=kube_version,
values={},
show_only=[
"charts/astronomer/templates/registry/registry-scc.yaml",
],
)
assert len(docs) == 0

0 comments on commit 529567a

Please sign in to comment.