Skip to content

Commit 0c69772

Browse files
Merge pull request #1215 from ShazaAldawamneh/OCPSTRAT-1076
OCPSTRAT-1076: Add readonlyRootFilesystem
2 parents 07dbf23 + 723cdc4 commit 0c69772

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

bindata/nodecadaemon.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ spec:
2929
containers:
3030
- name: node-ca
3131
securityContext:
32+
readOnlyRootFilesystem: true
3233
privileged: true
3334
runAsUser: 1001
3435
runAsGroup: 0

manifests/07-operator-ibm-cloud-managed.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ spec:
6262
requests:
6363
cpu: 10m
6464
memory: 50Mi
65+
securityContext:
66+
readOnlyRootFilesystem: true
6567
terminationMessagePolicy: FallbackToLogsOnError
6668
volumeMounts:
6769
- mountPath: /var/run/configmaps/trusted-ca/
@@ -71,6 +73,8 @@ spec:
7173
- mountPath: /var/run/secrets/openshift/serviceaccount
7274
name: bound-sa-token
7375
readOnly: true
76+
- mountPath: /tmp
77+
name: tmp
7478
priorityClassName: system-cluster-critical
7579
serviceAccountName: cluster-image-registry-operator
7680
shareProcessNamespace: false
@@ -87,6 +91,8 @@ spec:
8791
operator: Exists
8892
tolerationSeconds: 120
8993
volumes:
94+
- emptyDir: {}
95+
name: tmp
9096
- name: image-registry-operator-tls
9197
secret:
9298
secretName: image-registry-operator-tls

manifests/07-operator.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ spec:
7979
value: /tmp/azurestackcloud.json
8080
- name: OPERATOR_IMAGE_VERSION
8181
value: 0.0.1-snapshot
82+
securityContext:
83+
readOnlyRootFilesystem: true
8284
terminationMessagePolicy: FallbackToLogsOnError
8385
volumeMounts:
8486
- name: trusted-ca
@@ -88,7 +90,11 @@ spec:
8890
- name: bound-sa-token
8991
mountPath: /var/run/secrets/openshift/serviceaccount
9092
readOnly: true
93+
- name: tmp
94+
mountPath: /tmp
9195
volumes:
96+
- name: tmp
97+
emptyDir: {}
9298
- name: image-registry-operator-tls
9399
secret:
94100
secretName: image-registry-operator-tls

pkg/resource/podtemplatespec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1414
"k8s.io/apimachinery/pkg/util/intstr"
1515
coreset "k8s.io/client-go/kubernetes/typed/core/v1"
16+
"k8s.io/utils/ptr"
1617

1718
configapiv1 "github.com/openshift/api/config/v1"
1819
v1 "github.com/openshift/api/imageregistry/v1"
@@ -511,6 +512,9 @@ func makePodTemplateSpec(coreClient coreset.CoreV1Interface, proxyLister configl
511512
},
512513
},
513514
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
515+
SecurityContext: &corev1.SecurityContext{
516+
ReadOnlyRootFilesystem: ptr.To(true),
517+
},
514518
},
515519
},
516520
Volumes: volumes,

pkg/resource/prunercronjob.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"k8s.io/apimachinery/pkg/runtime"
1414
batchset "k8s.io/client-go/kubernetes/typed/batch/v1"
1515
batchlisters "k8s.io/client-go/listers/batch/v1"
16+
"k8s.io/utils/ptr"
1617

1718
imageregistryapiv1 "github.com/openshift/api/imageregistry/v1"
1819
securityv1 "github.com/openshift/api/security/v1"
@@ -166,6 +167,9 @@ done
166167
ReadOnly: true,
167168
},
168169
},
170+
SecurityContext: &kcorev1.SecurityContext{
171+
ReadOnlyRootFilesystem: ptr.To(true),
172+
},
169173
},
170174
},
171175
},

0 commit comments

Comments
 (0)