1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

Allow some helm policies to be excluded (#1611)

* Allow some helm policies to be excluded

Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>

* Make Helm security policies opt-in when podSecurityStandard=custom

Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
This commit is contained in:
treydock 2021-02-18 14:50:35 -05:00 committed by GitHub
parent 164885d087
commit 48f0d90dd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 69 additions and 30 deletions

View file

@ -101,7 +101,8 @@ Parameter | Description | Default
`service.type` | type of service | `ClusterIP`
`tolerations` | list of node taints to tolerate | `[]`
`securityContext` | security context configuration | `{}`
`podSecurityStandard` | set desired pod security level `privileged`, `default`, `restricted`. Set to `restricted` for maximum security for your cluster. See: https://kyverno.io/policies/pod-security/ | `default`
`podSecurityStandard` | set desired pod security level `privileged`, `default`, `restricted`, `custom`. Set to `restricted` for maximum security for your cluster. See: https://kyverno.io/policies/pod-security/ | `default`
`podSecurityPolicies` | Policies to include when `podSecurityStandard` is set to `custom` | `[]`
`validationFailureAction` | set to get response in failed validation check. Supported values- `audit`, `enforce`. See: https://kyverno.io/docs/writing-policies/validate/ | `audit`
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

View file

@ -70,3 +70,25 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{ default "default" .Values.rbac.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/* Set if a default policy is managed */}}
{{- define "kyverno.podSecurityDefault" -}}
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{- true }}
{{- else if and (eq .Values.podSecurityStandard "custom") (has .name .Values.podSecurityPolicies) }}
{{- true }}
{{- else -}}
{{- false }}
{{- end -}}
{{- end -}}
{{/* Set if a restricted policy is managed */}}
{{- define "kyverno.podSecurityRestricted" -}}
{{- if eq .Values.podSecurityStandard "restricted" }}
{{- true }}
{{- else if and (eq .Values.podSecurityStandard "custom") (has .name .Values.podSecurityPolicies) }}
{{- true }}
{{- else -}}
{{- false }}
{{- end -}}
{{- end -}}

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{ $name := "disallow-add-capabilities" -}}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-add-capabilities
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Default)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{ $name := "disallow-host-namespaces" -}}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-namespaces
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Default)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{ $name := "disallow-host-path" -}}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-path
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Default)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{- $name := "disallow-host-ports" }}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-ports
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Default)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{- $name := "disallow-privileged-containers" }}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-privileged-containers
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Default)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{- $name := "require-default-proc-mount" }}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-default-proc-mount
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Default)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{- $name := "disallow-selinux" }}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-selinux
name: {{ $name }}
annotations:
policies.kyverno.io/title: Disallow SELinux
policies.kyverno.io/category: Pod Security Standards (Default)

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{ $name := "restrict-apparmor-profiles" -}}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-apparmor-profiles
name: {{ $name }}
annotations:
policies.kyverno.io/title: Restrict AppArmor
policies.kyverno.io/category: Pod Security Standards (Default)

View file

@ -1,8 +1,9 @@
{{- if or (eq .Values.podSecurityStandard "default") (eq .Values.podSecurityStandard "restricted") }}
{{ $name := "restrict-sysctls" -}}
{{- if eq (include "kyverno.podSecurityDefault" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-sysctls
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Default)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if eq .Values.podSecurityStandard "restricted" }}
{{ $name := "deny-privilege-escalation" -}}
{{- if eq (include "kyverno.podSecurityRestricted" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: deny-privilege-escalation
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Restricted)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if eq .Values.podSecurityStandard "restricted" }}
{{ $name := "require-non-root-groups" -}}
{{- if eq (include "kyverno.podSecurityRestricted" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-non-root-groups
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Restricted)
policies.kyverno.io/description: >-

View file

@ -1,8 +1,9 @@
{{- if eq .Values.podSecurityStandard "restricted" }}
{{ $name := "require-run-as-non-root" -}}
{{- if eq (include "kyverno.podSecurityRestricted" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-run-as-non-root
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Restricted)
policies.kyverno.io/description: Containers must be required to run as non-root users.

View file

@ -1,8 +1,9 @@
{{- if eq .Values.podSecurityStandard "restricted" }}
{{ $name := "restrict-seccomp" -}}
{{- if eq (include "kyverno.podSecurityRestricted" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-seccomp
name: {{ $name }}
annotations:
policies.kyverno.io/title: Restrict Seccomp
policies.kyverno.io/category: Pod Security Standards (Restricted)

View file

@ -1,8 +1,9 @@
{{- if eq .Values.podSecurityStandard "restricted" }}
{{ $name := "restrict-volume-types" -}}
{{- if eq (include "kyverno.podSecurityRestricted" (merge (dict "name" $name) .)) "true" }}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-volume-types
name: {{ $name }}
annotations:
policies.kyverno.io/category: Pod Security Standards (Restricted)
policies.kyverno.io/description: >-

View file

@ -1,9 +1,11 @@
nameOverride:
fullnameOverride:
namespace:
# Supported- default/restricted/privileged
# Supported- default/restricted/privileged/custom
# For more info- https://kyverno.io/policies/pod-security
podSecurityStandard: default
# Policies to include when podSecurityStandard is custom
podSecurityPolicies: []
# Supported values- `audit`, `enforce`
# For more info- https://kyverno.io/docs/writing-policies/validate/
validationFailureAction: audit