forked from kyverno/kyverno
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b017762
commit 42b101d
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Require Pods Drop All Capabilities | ||
|
||
Containers may optionally ask for specific Linux capabilities without requiring root on the node. As a security best practice, containers should only specify exactly which capabilities they need. This starts with dropping all capabilities and only selectively adding ones back. | ||
|
||
This example policy requires that all containers drop all capabilities. | ||
|
||
## More information | ||
|
||
* [Set Capabilities for a Container](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container) | ||
|
||
## Policy YAML | ||
|
||
[require_drop_all.yaml](more/require_drop_all.yaml) | ||
|
||
```yaml | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: drop-all-capabilities | ||
spec: | ||
validationFailureAction: audit | ||
rules: | ||
- name: drop-all-containers | ||
match: | ||
resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
message: "Drop all must be defined for every container in the Pod." | ||
pattern: | ||
spec: | ||
containers: | ||
- securityContext: | ||
capabilities: | ||
drop: ["ALL"] | ||
- name: drop-all-initcontainers | ||
match: | ||
resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
message: "Drop all must be defined for every container in the Pod." | ||
pattern: | ||
spec: | ||
initContainers: | ||
- securityContext: | ||
capabilities: | ||
drop: ["ALL"] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: drop-all-capabilities | ||
spec: | ||
validationFailureAction: audit | ||
rules: | ||
- name: drop-all-containers | ||
match: | ||
resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
message: "Drop all must be defined for every container in the Pod." | ||
pattern: | ||
spec: | ||
containers: | ||
- securityContext: | ||
capabilities: | ||
drop: ["ALL"] | ||
- name: drop-all-initcontainers | ||
match: | ||
resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
message: "Drop all must be defined for every container in the Pod." | ||
pattern: | ||
spec: | ||
initContainers: | ||
- securityContext: | ||
capabilities: | ||
drop: ["ALL"] |