-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1037 from Vyom-Yadav/tempRelease
Modify policy template schema for Kyverno policies
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
generic/kyverno/kyverno-automount-service-account-token.yaml
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,25 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: restrict-automount-sa-token | ||
namespace: default | ||
spec: | ||
validationFailureAction: Audit | ||
background: true | ||
rules: | ||
- name: validate-automountServiceAccountToken | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
preconditions: | ||
all: | ||
- key: "{{ request.operation || 'BACKGROUND' }}" | ||
operator: NotEquals | ||
value: DELETE | ||
validate: | ||
message: "Auto-mounting of Service Account tokens is not allowed." | ||
pattern: | ||
spec: | ||
automountServiceAccountToken: "false" |
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,15 @@ | ||
version: v0.1.9 | ||
policyRules: | ||
- name: restrict-automount-sa-token | ||
description: | ||
refs: | ||
- name: Restrict Mounting Service Account Token | ||
url: | ||
- https://kyverno.io/policies/other/restrict_automount_sa_token/restrict_automount_sa_token/ | ||
tldr: Don't mount service account token when it is not needed | ||
detailed: If the Service Account Token is not used by a pod, then it should not be | ||
automounted. Service account token provide access to the kubeapi-server which potentially | ||
increases the surface area of attack. | ||
kyvernoPolicyTags: | ||
- "AUTOMOUNT_SERVICE_ACCOUNT" | ||
yaml: kyverno-automount-service-account-token.yaml |