Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Linux capabilities #1610

Merged
merged 1 commit into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ kubeconform: crdschemas manifests $(KUBECONFORM_BIN)

.PHONY: kubescape
kubescape: $(KUBESCAPE_BIN) ## Runs a security analysis on generated manifests - failing if risk score is above threshold percentage 't'
$(KUBESCAPE_BIN) scan -s framework -t 20 nsa manifests/*.yaml --exceptions 'kubescape-exceptions.json'
$(KUBESCAPE_BIN) scan -s framework -t 16 nsa manifests/*.yaml --exceptions 'kubescape-exceptions.json'

.PHONY: fmt
fmt: $(JSONNETFMT_BIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ function(params) {
runAsUser: 65534,
allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
capabilities: { drop: ['ALL'] },
},
volumeMounts: [{
mountPath: '/etc/blackbox_exporter/',
Expand All @@ -196,6 +197,7 @@ function(params) {
runAsUser: 65534,
allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
capabilities: { drop: ['ALL'] },
},
terminationMessagePath: '/dev/termination-log',
terminationMessagePolicy: 'FallbackToLogsOnError',
Expand Down
2 changes: 2 additions & 0 deletions jsonnet/kube-prometheus/components/grafana.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function(params)
// FIXME(ArthurSens): The securityContext overrides can be removed after some PRs get 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.
// 'capabilities: { drop: ['ALL'] }' can be deleted when https://github.com/brancz/kubernetes-grafana/pull/130 gets merged.
deployment+: {
spec+: {
template+: {
Expand All @@ -95,6 +96,7 @@ function(params)
securityContext+: {
allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
capabilities: { drop: ['ALL'] },
},
}, super.containers),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ function(params) {
runAsNonRoot: true,
allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
capabilities: { drop: ['ALL'] },
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
image: ksm._config.kubeRbacProxyImage,
}),

// FIXME(ArthurSens): The securityContext overrides can be removed after some PRs get merged
// 'capabilities: { drop: ['ALL'] },' can be deleted when https://github.com/kubernetes/kube-state-metrics/pull/1674 gets merged.
deployment+: {
spec+: {
template+: {
Expand All @@ -133,6 +135,9 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
readinessProbe:: null,
args: ['--host=127.0.0.1', '--port=8081', '--telemetry-host=127.0.0.1', '--telemetry-port=8082'],
resources: ksm._config.resources,
securityContext+: {
capabilities: { drop: ['ALL'] },
},
}, super.containers) + [kubeRbacProxyMain, kubeRbacProxySelf],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function(params) {
securityContext: {
allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
capabilities: { drop: ['ALL'], add: ['CAP_SYS_TIME'] },
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ function(params) {
securityContext: {
allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
capabilities: { drop: ['ALL'] },
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,17 @@ function(params)
image: po._config.kubeRbacProxyImage,
}),

// FIXME(ArthurSens): The securityContext overrides can be removed after some PRs get merged
// 'capabilities: { drop: ['ALL'] },' can be deleted when https://github.com/prometheus-operator/prometheus-operator/pull/4546 gets merged.
deployment+: {
spec+: {
template+: {
spec+: {
containers+: [kubeRbacProxy],
containers: std.map(function(c) c {
securityContext+: {
capabilities: { drop: ['ALL'] },
},
}, super.containers) + [kubeRbacProxy],
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions manifests/blackboxExporter-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65534
Expand All @@ -64,6 +67,9 @@ spec:
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65534
Expand Down Expand Up @@ -92,6 +98,9 @@ spec:
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsGroup: 65532
runAsNonRoot: true
Expand Down
3 changes: 3 additions & 0 deletions manifests/grafana-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ spec:
memory: 100Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
volumeMounts:
- mountPath: /var/lib/grafana
Expand Down
9 changes: 9 additions & 0 deletions manifests/kubeStateMetrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
memory: 190Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsUser: 65534
- args:
Expand All @@ -64,6 +67,9 @@ spec:
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsGroup: 65532
runAsNonRoot: true
Expand All @@ -87,6 +93,9 @@ spec:
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsGroup: 65532
runAsNonRoot: true
Expand Down
8 changes: 8 additions & 0 deletions manifests/nodeExporter-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ spec:
memory: 180Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- CAP_SYS_TIME
drop:
- ALL
readOnlyRootFilesystem: true
volumeMounts:
- mountPath: /host/sys
Expand Down Expand Up @@ -80,6 +85,9 @@ spec:
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsGroup: 65532
runAsNonRoot: true
Expand Down
3 changes: 3 additions & 0 deletions manifests/prometheusAdapter-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ spec:
memory: 180Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
volumeMounts:
- mountPath: /tmp
Expand Down
6 changes: 6 additions & 0 deletions manifests/prometheusOperator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ spec:
memory: 100Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
- args:
- --logtostderr
Expand All @@ -64,6 +67,9 @@ spec:
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsGroup: 65532
runAsNonRoot: true
Expand Down