components/*: Forbid write access to root filesystem

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Arthur Silva Sens 2022-01-27 09:13:18 +00:00 committed by ArthurSens
parent 48b2bb6a72
commit 57c46a2861
13 changed files with 33 additions and 5 deletions

View File

@ -169,10 +169,12 @@ function(params) {
securityContext: if bb._config.privileged then { securityContext: if bb._config.privileged then {
runAsNonRoot: false, runAsNonRoot: false,
capabilities: { drop: ['ALL'], add: ['NET_RAW'] }, capabilities: { drop: ['ALL'], add: ['NET_RAW'] },
readOnlyRootFilesystem: true,
} else { } else {
runAsNonRoot: true, runAsNonRoot: true,
runAsUser: 65534, runAsUser: 65534,
allowPrivilegeEscalation: false, allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
}, },
volumeMounts: [{ volumeMounts: [{
mountPath: '/etc/blackbox_exporter/', mountPath: '/etc/blackbox_exporter/',
@ -193,6 +195,7 @@ function(params) {
runAsNonRoot: true, runAsNonRoot: true,
runAsUser: 65534, runAsUser: 65534,
allowPrivilegeEscalation: false, allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
}, },
terminationMessagePath: '/dev/termination-log', terminationMessagePath: '/dev/termination-log',
terminationMessagePolicy: 'FallbackToLogsOnError', terminationMessagePolicy: 'FallbackToLogsOnError',

View File

@ -84,8 +84,9 @@ function(params)
}, },
}, },
// FIXME(ArthurSens): The override adding 'allowPrivilegeEscalation: false' can be deleted when // FIXME(ArthurSens): The securityContext overrides can be removed after some PRs get merged
// https://github.com/brancz/kubernetes-grafana/pull/128 gets merged. // 'allowPrivilegeEscalation: false' can be deleted when https://github.com/brancz/kubernetes-grafana/pull/128 gets merged.
// 'readOnlyRootFilesystem: true' can be deleted when https://github.com/brancz/kubernetes-grafana/pull/129 gets merged.
deployment+: { deployment+: {
spec+: { spec+: {
template+: { template+: {
@ -93,6 +94,7 @@ function(params)
containers: std.map(function(c) c { containers: std.map(function(c) c {
securityContext+: { securityContext+: {
allowPrivilegeEscalation: false, allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
}, },
}, super.containers), }, super.containers),
}, },

View File

@ -62,5 +62,6 @@ function(params) {
runAsGroup: 65532, runAsGroup: 65532,
runAsNonRoot: true, runAsNonRoot: true,
allowPrivilegeEscalation: false, allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
}, },
} }

View File

@ -118,8 +118,9 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
image: ksm._config.kubeRbacProxyImage, image: ksm._config.kubeRbacProxyImage,
}), }),
// FIXME(ArthurSens): The override adding 'allowPrivilegeEscalation: false' can be deleted when // FIXME(ArthurSens): The securityContext overrides can be removed after some PRs get merged
// https://github.com/kubernetes/kube-state-metrics/pull/1668 gets merged. // 'allowPrivilegeEscalation: false' can be deleted when https://github.com/kubernetes/kube-state-metrics/pull/1668 gets merged.
// 'readOnlyRootFilesystem: true' can be deleted when https://github.com/kubernetes/kube-state-metrics/pull/1671 gets merged.
deployment+: { deployment+: {
spec+: { spec+: {
template+: { template+: {
@ -137,6 +138,7 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
resources: ksm._config.resources, resources: ksm._config.resources,
securityContext+: { securityContext+: {
allowPrivilegeEscalation: false, allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
}, },
}, super.containers) + [kubeRbacProxyMain, kubeRbacProxySelf], }, super.containers) + [kubeRbacProxyMain, kubeRbacProxySelf],
}, },

View File

@ -183,6 +183,7 @@ function(params) {
resources: ne._config.resources, resources: ne._config.resources,
securityContext: { securityContext: {
allowPrivilegeEscalation: false, allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
}, },
}; };

View File

@ -228,6 +228,7 @@ function(params) {
], ],
securityContext: { securityContext: {
allowPrivilegeEscalation: false, allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
}, },
}; };

View File

@ -125,11 +125,17 @@ function(params)
image: po._config.kubeRbacProxyImage, image: po._config.kubeRbacProxyImage,
}), }),
// FIXME(ArthurSens): The securityContext overrides can be removed after some PRs get merged
// 'readOnlyRootFilesystem: true' can be deleted when https://github.com/prometheus-operator/prometheus-operator/pull/4531 gets merged.
deployment+: { deployment+: {
spec+: { spec+: {
template+: { template+: {
spec+: { spec+: {
containers+: [kubeRbacProxy], containers: std.map(function(c) c {
securityContext+: {
readOnlyRootFilesystem: true,
},
}, super.containers) + [kubeRbacProxy],
}, },
}, },
}, },

View File

@ -43,6 +43,7 @@ spec:
memory: 20Mi memory: 20Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true runAsNonRoot: true
runAsUser: 65534 runAsUser: 65534
volumeMounts: volumeMounts:
@ -63,6 +64,7 @@ spec:
memory: 20Mi memory: 20Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true runAsNonRoot: true
runAsUser: 65534 runAsUser: 65534
terminationMessagePath: /dev/termination-log terminationMessagePath: /dev/termination-log
@ -90,6 +92,7 @@ spec:
memory: 20Mi memory: 20Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 65532 runAsGroup: 65532
runAsNonRoot: true runAsNonRoot: true
runAsUser: 65532 runAsUser: 65532

View File

@ -47,6 +47,7 @@ spec:
memory: 100Mi memory: 100Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
volumeMounts: volumeMounts:
- mountPath: /var/lib/grafana - mountPath: /var/lib/grafana
name: grafana-storage name: grafana-storage

View File

@ -43,6 +43,7 @@ spec:
memory: 190Mi memory: 190Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 65534 runAsUser: 65534
- args: - args:
- --logtostderr - --logtostderr
@ -63,6 +64,7 @@ spec:
memory: 20Mi memory: 20Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 65532 runAsGroup: 65532
runAsNonRoot: true runAsNonRoot: true
runAsUser: 65532 runAsUser: 65532
@ -85,6 +87,7 @@ spec:
memory: 20Mi memory: 20Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 65532 runAsGroup: 65532
runAsNonRoot: true runAsNonRoot: true
runAsUser: 65532 runAsUser: 65532

View File

@ -45,6 +45,7 @@ spec:
memory: 180Mi memory: 180Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
volumeMounts: volumeMounts:
- mountPath: /host/sys - mountPath: /host/sys
mountPropagation: HostToContainer mountPropagation: HostToContainer
@ -79,6 +80,7 @@ spec:
memory: 20Mi memory: 20Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 65532 runAsGroup: 65532
runAsNonRoot: true runAsNonRoot: true
runAsUser: 65532 runAsUser: 65532

View File

@ -49,6 +49,7 @@ spec:
memory: 180Mi memory: 180Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
volumeMounts: volumeMounts:
- mountPath: /tmp - mountPath: /tmp
name: tmpfs name: tmpfs

View File

@ -44,6 +44,7 @@ spec:
memory: 100Mi memory: 100Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
- args: - args:
- --logtostderr - --logtostderr
- --secure-listen-address=:8443 - --secure-listen-address=:8443
@ -63,6 +64,7 @@ spec:
memory: 20Mi memory: 20Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 65532 runAsGroup: 65532
runAsNonRoot: true runAsNonRoot: true
runAsUser: 65532 runAsUser: 65532