Skip to content

Commit 1c4ab43

Browse files
committed
WIP: placeholder
1 parent 6c4e779 commit 1c4ab43

File tree

6 files changed

+55
-5
lines changed

6 files changed

+55
-5
lines changed

deploy/chart/templates/0000_50_olm_00-namespace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ apiVersion: v1
22
kind: Namespace
33
metadata:
44
name: {{ .Values.namespace }}
5+
labels:
6+
pod-security.kubernetes.io/enforce: restricted
57

68
---
79
apiVersion: v1
810
kind: Namespace
911
metadata:
1012
name: {{ .Values.operator_namespace }}
13+
labels:
14+
pod-security.kubernetes.io/enforce: restricted

deploy/chart/templates/0000_50_olm_07-olm-operator.deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ spec:
1717
labels:
1818
app: olm-operator
1919
spec:
20+
securityContext:
21+
runAsNonRoot: true
22+
seccompProfile:
23+
type: RuntimeDefault
24+
{{- if eq .Values.installType "upstream" }}
25+
runAsUser: {{ .Values.package.securityContext.runAsUser }}
26+
{{- end }}
2027
serviceAccountName: olm-operator-serviceaccount
2128
{{- if or .Values.olm.tlsSecret .Values.olm.clientCASecret }}
2229
volumes:
@@ -33,6 +40,10 @@ spec:
3340
{{- end }}
3441
containers:
3542
- name: olm-operator
43+
securityContext:
44+
allowPrivilegeEscalation: false
45+
capabilities:
46+
drop: [ "ALL" ]
3647
{{- if or .Values.olm.tlsSecret .Values.olm.clientCASecret }}
3748
volumeMounts:
3849
{{- end }}

deploy/chart/templates/0000_50_olm_08-catalog-operator.deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ spec:
1717
labels:
1818
app: catalog-operator
1919
spec:
20+
securityContext:
21+
runAsNonRoot: true
22+
seccompProfile:
23+
type: RuntimeDefault
24+
{{- if eq .Values.installType "upstream" }}
25+
runAsUser: {{ .Values.package.securityContext.runAsUser }}
26+
{{- end }}
2027
serviceAccountName: olm-operator-serviceaccount
2128
{{- if or .Values.catalog.tlsSecret .Values.catalog.clientCASecret }}
2229
volumes:
@@ -33,6 +40,10 @@ spec:
3340
{{- end }}
3441
containers:
3542
- name: catalog-operator
43+
securityContext:
44+
allowPrivilegeEscalation: false
45+
capabilities:
46+
drop: [ "ALL" ]
3647
{{- if or .Values.catalog.tlsSecret .Values.catalog.clientCASecret }}
3748
volumeMounts:
3849
{{- end }}

deploy/chart/templates/_packageserver.deployment-spec.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ spec:
1414
labels:
1515
app: packageserver
1616
spec:
17+
securityContext:
18+
runAsNonRoot: true
19+
seccompProfile:
20+
type: RuntimeDefault
21+
{{- if eq .Values.installType "upstream" }}
22+
runAsUser: {{ .Values.package.securityContext.runAsUser }}
23+
{{- end }}
1724
serviceAccountName: olm-operator-serviceaccount
1825
{{- if .Values.package.nodeSelector }}
1926
nodeSelector:
@@ -25,6 +32,10 @@ spec:
2532
{{- end }}
2633
containers:
2734
- name: packageserver
35+
securityContext:
36+
allowPrivilegeEscalation: false
37+
capabilities:
38+
drop: [ "ALL" ]
2839
command:
2940
- /bin/package-server
3041
- -v=4
@@ -61,10 +72,6 @@ spec:
6172
resources:
6273
{{ toYaml .Values.package.resources | indent 10 }}
6374
{{- end }}
64-
{{- if .Values.package.securityContext }}
65-
securityContext:
66-
runAsUser: {{ .Values.package.securityContext.runAsUser }}
67-
{{- end }}
6875
volumeMounts:
6976
- name: tmpfs
7077
mountPath: /tmp

deploy/chart/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ package:
5353
internalPort: 5443
5454
nodeSelector:
5555
kubernetes.io/os: linux
56+
securityContext:
57+
runAsUser: 1001
5658
resources:
5759
requests:
5860
cpu: 10m

pkg/controller/registry/reconciler/reconciler.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
126126
}
127127

128128
readOnlyRootFilesystem := false
129+
allowPrivilegeEscalation := false
130+
runAsNonRoot := true
131+
runAsUser := int64(1001)
129132

130133
pod := &corev1.Pod{
131134
ObjectMeta: metav1.ObjectMeta{
@@ -179,7 +182,11 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
179182
},
180183
},
181184
SecurityContext: &corev1.SecurityContext{
182-
ReadOnlyRootFilesystem: &readOnlyRootFilesystem,
185+
ReadOnlyRootFilesystem: &readOnlyRootFilesystem,
186+
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
187+
Capabilities: &corev1.Capabilities{
188+
Drop: []corev1.Capability{"ALL"},
189+
},
183190
},
184191
ImagePullPolicy: pullPolicy,
185192
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
@@ -188,6 +195,14 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
188195
NodeSelector: map[string]string{
189196
"kubernetes.io/os": "linux",
190197
},
198+
SecurityContext: &corev1.PodSecurityContext{
199+
RunAsNonRoot: &runAsNonRoot,
200+
// WIP note: this needs to be delete in downstream code (SCC will assign a userID)
201+
RunAsUser: &runAsUser,
202+
SeccompProfile: &corev1.SeccompProfile{
203+
Type: corev1.SeccompProfileTypeRuntimeDefault,
204+
},
205+
},
191206
ServiceAccountName: saName,
192207
},
193208
}

0 commit comments

Comments
 (0)