mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
Exclude Kyverno namespace by default (#4079)
* Exclude Kyverno namespace by default Fixes #4075 Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
This commit is contained in:
parent
a064a1960e
commit
660e8f34f9
6 changed files with 40 additions and 14 deletions
|
@ -26,11 +26,5 @@ annotations:
|
|||
url: https://kyverno.io/docs
|
||||
# valid kinds are: added, changed, deprecated, removed, fixed and security
|
||||
artifacthub.io/changes: |
|
||||
- kind: added
|
||||
description: Support for artifacthub.io/changes annotation
|
||||
- kind: added
|
||||
description: Allow defining imagePullSecrets
|
||||
- kind: fixed
|
||||
description: Replica count handling
|
||||
- kind: changed
|
||||
description: Use cluster role aggregation
|
||||
description: Exclude Kyverno namespace by default
|
||||
|
|
|
@ -105,11 +105,12 @@ The command removes all the Kubernetes components associated with the chart and
|
|||
| livenessProbe | object | See [values.yaml](values.yaml) | Liveness probe. The block is directly forwarded into the deployment, so you can use whatever livenessProbe configuration you want. ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ |
|
||||
| readinessProbe | object | See [values.yaml](values.yaml) | Readiness Probe. The block is directly forwarded into the deployment, so you can use whatever readinessProbe configuration you want. ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ |
|
||||
| generatecontrollerExtraResources | string | `nil` | |
|
||||
| excludeKyvernoNamespace | bool | `true` | Exclude Kyverno namespace Determines if default Kyverno namespace exclusion is enabled for webhooks and resourceFilters |
|
||||
| config.resourceFilters | list | See [values.yaml](values.yaml) | Resource types to be skipped by the Kyverno policy engine. Make sure to surround each entry in quotes so that it doesn't get parsed as a nested YAML list. These are joined together without spaces, run through `tpl`, and the result is set in the config map. |
|
||||
| config.existingConfig | string | `""` | Name of an existing config map (ignores default/provided resourceFilters) |
|
||||
| config.excludeGroupRole | string | `nil` | Exclude group role |
|
||||
| config.excludeUsername | string | `nil` | Exclude username |
|
||||
| config.webhooks | string | `nil` | Defines the `namespaceSelector` in the webhook configurations. Note that it takes a list of `namespaceSelector` and/or `objectSelector` in the JSON format, and only the first element will be forwarded to the webhook configurations. |
|
||||
| config.webhooks | string | `nil` | Defines the `namespaceSelector` in the webhook configurations. Note that it takes a list of `namespaceSelector` and/or `objectSelector` in the JSON format, and only the first element will be forwarded to the webhook configurations. The Kyverno namespace is excluded if `excludeKyvernoNamespace` is `true` (default) |
|
||||
| config.generateSuccessEvents | bool | `false` | Generate success events. |
|
||||
| config.metricsConfig | object | `{"namespaces":{"exclude":[],"include":[]}}` | Metrics config. |
|
||||
| updateStrategy | object | See [values.yaml](values.yaml) | Deployment update strategy. Ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy |
|
||||
|
|
|
@ -116,3 +116,24 @@ maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
|
|||
{{- define "kyverno.imagePullSecret" }}
|
||||
{{- printf "{\"auths\":{\"%s\":{\"auth\":\"%s\"}}}" .registry (printf "%s:%s" .username .password | b64enc) | b64enc }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{- define "kyverno.resourceFilters" -}}
|
||||
{{- $resourceFilters := .Values.config.resourceFilters }}
|
||||
{{- if .Values.excludeKyvernoNamespace }}
|
||||
{{- $resourceFilters = prepend .Values.config.resourceFilters (printf "[*,%s,*]" (include "kyverno.namespace" .)) }}
|
||||
{{- end }}
|
||||
{{- tpl (join "" $resourceFilters) . }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "kyverno.webhooks" -}}
|
||||
{{- $excludeDefault := dict "key" "kubernetes.io/metadata.name" "operator" "NotIn" "values" (list (include "kyverno.namespace" .)) }}
|
||||
{{- $newWebhook := list }}
|
||||
{{- range $webhook := .Values.config.webhooks }}
|
||||
{{- $namespaceSelector := default dict $webhook.namespaceSelector }}
|
||||
{{- $matchExpressions := default list $namespaceSelector.matchExpressions }}
|
||||
{{- $newNamespaceSelector := dict "matchLabels" $namespaceSelector.matchLabels "matchExpressions" (append $matchExpressions $excludeDefault) }}
|
||||
{{- $newWebhook = append $newWebhook (merge (omit $webhook "namespaceSelector") (dict "namespaceSelector" $newNamespaceSelector)) }}
|
||||
{{- end }}
|
||||
{{- $newWebhook | toJson }}
|
||||
{{- end }}
|
|
@ -9,7 +9,7 @@ metadata:
|
|||
data:
|
||||
# resource types to be skipped by kyverno policy engine
|
||||
{{- if .Values.config.resourceFilters }}
|
||||
resourceFilters: {{ tpl (join "" .Values.config.resourceFilters) . | quote }}
|
||||
resourceFilters: {{ include "kyverno.resourceFilters" . | quote }}
|
||||
{{- end -}}
|
||||
{{- if .Values.config.excludeGroupRole }}
|
||||
excludeGroupRole: {{ join "," .Values.config.excludeGroupRole | quote }}
|
||||
|
@ -17,8 +17,12 @@ data:
|
|||
{{- if .Values.config.excludeUsername }}
|
||||
excludeUsername: {{ join "," .Values.config.excludeUsername | quote }}
|
||||
{{- end -}}
|
||||
{{- if .Values.config.webhooks }}
|
||||
webhooks: {{ .Values.config.webhooks | toJson | quote }}
|
||||
{{- if and .Values.config.webhooks .Values.excludeKyvernoNamespace }}
|
||||
webhooks: {{ include "kyverno.webhooks" . | quote }}
|
||||
{{- else if .Values.config.webhooks }}
|
||||
webhooks: {{ .Values.config.webhooks | toJson | quote }}
|
||||
{{- else if .Values.excludeKyvernoNamespace }}
|
||||
webhooks: '[{"namespaceSelector": {"matchExpressions": [{"key":"kubernetes.io/metadata.name","operator":"NotIn","values":["{{ include "kyverno.namespace" . }}"]}]}}]'
|
||||
{{- end -}}
|
||||
{{- if .Values.config.generateSuccessEvents }}
|
||||
generateSuccessEvents: {{ .Values.config.generateSuccessEvents | quote }}
|
||||
|
|
|
@ -212,6 +212,10 @@ generatecontrollerExtraResources:
|
|||
# - ResourceA
|
||||
# - ResourceB
|
||||
|
||||
# -- Exclude Kyverno namespace
|
||||
# Determines if default Kyverno namespace exclusion is enabled for webhooks and resourceFilters
|
||||
excludeKyvernoNamespace: true
|
||||
|
||||
config:
|
||||
# -- Resource types to be skipped by the Kyverno policy engine.
|
||||
# Make sure to surround each entry in quotes so that it doesn't get parsed as a nested YAML list.
|
||||
|
@ -260,15 +264,16 @@ config:
|
|||
# -- Defines the `namespaceSelector` in the webhook configurations.
|
||||
# Note that it takes a list of `namespaceSelector` and/or `objectSelector` in the JSON format, and only the first element
|
||||
# will be forwarded to the webhook configurations.
|
||||
# The Kyverno namespace is excluded if `excludeKyvernoNamespace` is `true` (default)
|
||||
webhooks:
|
||||
# Exclude namespaces
|
||||
# - namespaceSelector:
|
||||
# matchExpressions:
|
||||
# - key: kubernetes.io/metadata.name
|
||||
# operator: In
|
||||
# operator: NotIn
|
||||
# values:
|
||||
# - kube-system
|
||||
# - kyverno
|
||||
# - kyverno
|
||||
# Exclude objects
|
||||
# - objectSelector:
|
||||
# matchExpressions:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
apiVersion: v1
|
||||
data:
|
||||
resourceFilters: '[Event,*,*][*,kube-system,*][*,kube-public,*][*,kube-node-lease,*][Node,*,*][APIService,*,*][TokenReview,*,*][SubjectAccessReview,*,*][SelfSubjectAccessReview,*,*][*,kyverno,kyverno*][Binding,*,*][ReplicaSet,*,*][ReportChangeRequest,*,*][ClusterReportChangeRequest,*,*][PolicyReport,*,*][ClusterPolicyReport,*,*]'
|
||||
resourceFilters: '[Event,*,*][*,kube-system,*][*,kube-public,*][*,kube-node-lease,*][*,kyverno,*][Node,*,*][APIService,*,*][TokenReview,*,*][SubjectAccessReview,*,*][SelfSubjectAccessReview,*,*][*,kyverno,kyverno*][Binding,*,*][ReplicaSet,*,*][ReportChangeRequest,*,*][ClusterReportChangeRequest,*,*][PolicyReport,*,*][ClusterPolicyReport,*,*]'
|
||||
webhooks: '[{"namespaceSelector": {"matchExpressions": [{"key":"kubernetes.io/metadata.name","operator":"NotIn","values":["kyverno"]}]}}]'
|
||||
excludeGroupRole: 'system:serviceaccounts:kube-system,system:nodes,system:kube-scheduler'
|
||||
generateSuccessEvents: 'false'
|
||||
kind: ConfigMap
|
||||
|
|
Loading…
Reference in a new issue