1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

Release 1.6.3 (#4134)

* fix: do not remove webhooks during initialization (#3641)

* Do not remove webhooks during initialization

During initialization the Kyverno leader Pod deletes all the
existing webhooks and recreates them. There is a small time window were
the cluster is not protected by the webhooks, allowing a user to apply
resources without any verfication.
This commit updates the leader registration logic to not remove and
recreate the webhooks but, in the case that the webhooks already exist,
update them.

Signed-off-by: Ioannis Bouloumpasis <buluba@arrikto.com>

* Fix linter errors

Signed-off-by: Ioannis Bouloumpasis <buluba@arrikto.com>

* Use the Lister to get webhook configurations

Signed-off-by: Ioannis Bouloumpasis <buluba@arrikto.com>
Signed-off-by: ShutingZhao <shuting@nirmata.com>

* Tag v1.6.3

Signed-off-by: ShutingZhao <shuting@nirmata.com>

Co-authored-by: Ioannis Bouloumpasis <buluba89@gmail.com>
This commit is contained in:
shuting 2022-06-17 23:16:19 +08:00 committed by GitHub
parent e0f6fa1b3e
commit 38ca9e702e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 192 additions and 87 deletions

View file

@ -1,7 +1,7 @@
apiVersion: v1 apiVersion: v1
name: kyverno-policies name: kyverno-policies
version: v2.3.4 version: v2.3.5
appVersion: v1.6.2 appVersion: v1.6.3
icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
description: Kubernetes Pod Security Standards implemented as Kyverno policies description: Kubernetes Pod Security Standards implemented as Kyverno policies
keywords: keywords:

View file

@ -1,7 +1,7 @@
apiVersion: v1 apiVersion: v1
name: kyverno name: kyverno
version: v2.3.3 version: v2.3.4
appVersion: v1.6.2 appVersion: v1.6.3
icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
description: Kubernetes Native Policy Management description: Kubernetes Native Policy Management
keywords: keywords:

View file

@ -11,7 +11,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterpolicies.kyverno.io name: clusterpolicies.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -1388,7 +1388,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterpolicyreports.wgpolicyk8s.io name: clusterpolicyreports.wgpolicyk8s.io
spec: spec:
group: wgpolicyk8s.io group: wgpolicyk8s.io
@ -1880,7 +1880,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterreportchangerequests.kyverno.io name: clusterreportchangerequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -2372,7 +2372,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: generaterequests.kyverno.io name: generaterequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -2553,7 +2553,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: policies.kyverno.io name: policies.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -3930,7 +3930,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: policyreports.wgpolicyk8s.io name: policyreports.wgpolicyk8s.io
spec: spec:
group: wgpolicyk8s.io group: wgpolicyk8s.io
@ -4422,7 +4422,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: reportchangerequests.kyverno.io name: reportchangerequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io

View file

@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno name: kyverno
--- ---
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
@ -21,7 +21,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterpolicies.kyverno.io name: clusterpolicies.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -2202,7 +2202,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterpolicyreports.wgpolicyk8s.io name: clusterpolicyreports.wgpolicyk8s.io
spec: spec:
group: wgpolicyk8s.io group: wgpolicyk8s.io
@ -2882,7 +2882,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterreportchangerequests.kyverno.io name: clusterreportchangerequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -3562,7 +3562,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: generaterequests.kyverno.io name: generaterequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -3759,7 +3759,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: policies.kyverno.io name: policies.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -5942,7 +5942,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: policyreports.wgpolicyk8s.io name: policyreports.wgpolicyk8s.io
spec: spec:
group: wgpolicyk8s.io group: wgpolicyk8s.io
@ -6620,7 +6620,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: reportchangerequests.kyverno.io name: reportchangerequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -7298,7 +7298,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-service-account name: kyverno-service-account
namespace: kyverno namespace: kyverno
--- ---
@ -7311,7 +7311,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:leaderelection name: kyverno:leaderelection
namespace: kyverno namespace: kyverno
rules: rules:
@ -7345,7 +7345,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
rbac.authorization.k8s.io/aggregate-to-admin: "true" rbac.authorization.k8s.io/aggregate-to-admin: "true"
name: kyverno:admin-policies name: kyverno:admin-policies
rules: rules:
@ -7372,7 +7372,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
rbac.authorization.k8s.io/aggregate-to-admin: "true" rbac.authorization.k8s.io/aggregate-to-admin: "true"
name: kyverno:admin-policyreport name: kyverno:admin-policyreport
rules: rules:
@ -7399,7 +7399,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
rbac.authorization.k8s.io/aggregate-to-admin: "true" rbac.authorization.k8s.io/aggregate-to-admin: "true"
name: kyverno:admin-reportchangerequest name: kyverno:admin-reportchangerequest
rules: rules:
@ -7426,7 +7426,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:events name: kyverno:events
rules: rules:
- apiGroups: - apiGroups:
@ -7448,7 +7448,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:generate name: kyverno:generate
rules: rules:
- apiGroups: - apiGroups:
@ -7495,7 +7495,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:policies name: kyverno:policies
rules: rules:
- apiGroups: - apiGroups:
@ -7546,7 +7546,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:userinfo name: kyverno:userinfo
rules: rules:
- apiGroups: - apiGroups:
@ -7569,7 +7569,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:view name: kyverno:view
rules: rules:
- apiGroups: - apiGroups:
@ -7590,7 +7590,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:webhook name: kyverno:webhook
rules: rules:
- apiGroups: - apiGroups:
@ -7616,7 +7616,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:leaderelection name: kyverno:leaderelection
namespace: kyverno namespace: kyverno
roleRef: roleRef:
@ -7637,7 +7637,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:events name: kyverno:events
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7657,7 +7657,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:generate name: kyverno:generate
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7677,7 +7677,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:policies name: kyverno:policies
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7697,7 +7697,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:userinfo name: kyverno:userinfo
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7717,7 +7717,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:view name: kyverno:view
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7737,7 +7737,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:webhook name: kyverno:webhook
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7761,7 +7761,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno name: kyverno
namespace: kyverno namespace: kyverno
--- ---
@ -7777,7 +7777,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-metrics name: kyverno-metrics
namespace: kyverno namespace: kyverno
--- ---
@ -7790,7 +7790,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-svc name: kyverno-svc
namespace: kyverno namespace: kyverno
spec: spec:
@ -7811,7 +7811,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-svc-metrics name: kyverno-svc-metrics
namespace: kyverno namespace: kyverno
spec: spec:
@ -7832,7 +7832,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno name: kyverno
namespace: kyverno namespace: kyverno
spec: spec:
@ -7854,7 +7854,7 @@ spec:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
spec: spec:
affinity: affinity:
podAntiAffinity: podAntiAffinity:
@ -7885,7 +7885,7 @@ spec:
value: kyverno-svc value: kyverno-svc
- name: TUF_ROOT - name: TUF_ROOT
value: /.sigstore value: /.sigstore
image: ghcr.io/kyverno/kyverno:v1.6.2 image: ghcr.io/kyverno/kyverno:v1.6.3
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
livenessProbe: livenessProbe:
failureThreshold: 2 failureThreshold: 2
@ -7940,7 +7940,7 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: metadata.namespace fieldPath: metadata.namespace
image: ghcr.io/kyverno/kyvernopre:v1.6.2 image: ghcr.io/kyverno/kyvernopre:v1.6.3
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: kyverno-pre name: kyverno-pre
resources: resources:

View file

@ -7,7 +7,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno name: kyverno
--- ---
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
@ -21,7 +21,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterpolicies.kyverno.io name: clusterpolicies.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -2202,7 +2202,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterpolicyreports.wgpolicyk8s.io name: clusterpolicyreports.wgpolicyk8s.io
spec: spec:
group: wgpolicyk8s.io group: wgpolicyk8s.io
@ -2882,7 +2882,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: clusterreportchangerequests.kyverno.io name: clusterreportchangerequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -3562,7 +3562,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: generaterequests.kyverno.io name: generaterequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -3759,7 +3759,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: policies.kyverno.io name: policies.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -5942,7 +5942,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: policyreports.wgpolicyk8s.io name: policyreports.wgpolicyk8s.io
spec: spec:
group: wgpolicyk8s.io group: wgpolicyk8s.io
@ -6620,7 +6620,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: reportchangerequests.kyverno.io name: reportchangerequests.kyverno.io
spec: spec:
group: kyverno.io group: kyverno.io
@ -7298,7 +7298,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-service-account name: kyverno-service-account
namespace: kyverno namespace: kyverno
--- ---
@ -7311,7 +7311,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:leaderelection name: kyverno:leaderelection
namespace: kyverno namespace: kyverno
rules: rules:
@ -7345,7 +7345,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
rbac.authorization.k8s.io/aggregate-to-admin: "true" rbac.authorization.k8s.io/aggregate-to-admin: "true"
name: kyverno:admin-policies name: kyverno:admin-policies
rules: rules:
@ -7372,7 +7372,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
rbac.authorization.k8s.io/aggregate-to-admin: "true" rbac.authorization.k8s.io/aggregate-to-admin: "true"
name: kyverno:admin-policyreport name: kyverno:admin-policyreport
rules: rules:
@ -7399,7 +7399,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
rbac.authorization.k8s.io/aggregate-to-admin: "true" rbac.authorization.k8s.io/aggregate-to-admin: "true"
name: kyverno:admin-reportchangerequest name: kyverno:admin-reportchangerequest
rules: rules:
@ -7426,7 +7426,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:events name: kyverno:events
rules: rules:
- apiGroups: - apiGroups:
@ -7448,7 +7448,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:generate name: kyverno:generate
rules: rules:
- apiGroups: - apiGroups:
@ -7495,7 +7495,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:policies name: kyverno:policies
rules: rules:
- apiGroups: - apiGroups:
@ -7546,7 +7546,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:userinfo name: kyverno:userinfo
rules: rules:
- apiGroups: - apiGroups:
@ -7569,7 +7569,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:view name: kyverno:view
rules: rules:
- apiGroups: - apiGroups:
@ -7590,7 +7590,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:webhook name: kyverno:webhook
rules: rules:
- apiGroups: - apiGroups:
@ -7616,7 +7616,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:leaderelection name: kyverno:leaderelection
namespace: kyverno namespace: kyverno
roleRef: roleRef:
@ -7637,7 +7637,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:events name: kyverno:events
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7657,7 +7657,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:generate name: kyverno:generate
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7677,7 +7677,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:policies name: kyverno:policies
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7697,7 +7697,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:userinfo name: kyverno:userinfo
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7717,7 +7717,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:view name: kyverno:view
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7737,7 +7737,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno:webhook name: kyverno:webhook
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
@ -7761,7 +7761,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno name: kyverno
namespace: kyverno namespace: kyverno
--- ---
@ -7777,7 +7777,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-metrics name: kyverno-metrics
namespace: kyverno namespace: kyverno
--- ---
@ -7790,7 +7790,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-svc name: kyverno-svc
namespace: kyverno namespace: kyverno
spec: spec:
@ -7811,7 +7811,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno-svc-metrics name: kyverno-svc-metrics
namespace: kyverno namespace: kyverno
spec: spec:
@ -7832,7 +7832,7 @@ metadata:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
name: kyverno name: kyverno
namespace: kyverno namespace: kyverno
spec: spec:
@ -7854,7 +7854,7 @@ spec:
app.kubernetes.io/instance: kyverno app.kubernetes.io/instance: kyverno
app.kubernetes.io/name: kyverno app.kubernetes.io/name: kyverno
app.kubernetes.io/part-of: kyverno app.kubernetes.io/part-of: kyverno
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
spec: spec:
affinity: affinity:
podAntiAffinity: podAntiAffinity:
@ -7885,7 +7885,7 @@ spec:
value: kyverno-svc value: kyverno-svc
- name: TUF_ROOT - name: TUF_ROOT
value: /.sigstore value: /.sigstore
image: ghcr.io/kyverno/kyverno:v1.6.2 image: ghcr.io/kyverno/kyverno:v1.6.3
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
livenessProbe: livenessProbe:
failureThreshold: 2 failureThreshold: 2
@ -7940,7 +7940,7 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: metadata.namespace fieldPath: metadata.namespace
image: ghcr.io/kyverno/kyvernopre:v1.6.2 image: ghcr.io/kyverno/kyvernopre:v1.6.3
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: kyverno-pre name: kyverno-pre
resources: resources:

View file

@ -9,6 +9,6 @@ transformers:
images: images:
- name: ghcr.io/kyverno/kyverno - name: ghcr.io/kyverno/kyverno
newTag: v1.6.2 newTag: v1.6.3
- name: ghcr.io/kyverno/kyvernopre - name: ghcr.io/kyverno/kyvernopre
newTag: v1.6.2 newTag: v1.6.3

View file

@ -4,7 +4,7 @@ kind: LabelTransformer
metadata: metadata:
name: labelTransformer name: labelTransformer
labels: labels:
app.kubernetes.io/version: v1.6.2 app.kubernetes.io/version: v1.6.3
fieldSpecs: fieldSpecs:
- path: metadata/labels - path: metadata/labels
create: true create: true

View file

@ -126,7 +126,6 @@ func (wrc *Register) Register() error {
return err return err
} }
} }
wrc.removeWebhookConfigurations()
caData := wrc.readCaData() caData := wrc.readCaData()
if caData == nil { if caData == nil {
@ -318,9 +317,12 @@ func (wrc *Register) createResourceMutatingWebhookConfiguration(caData []byte) e
_, err := wrc.client.CreateResource("", kindMutating, "", *config, false) _, err := wrc.client.CreateResource("", kindMutating, "", *config, false)
if errorsapi.IsAlreadyExists(err) { if errorsapi.IsAlreadyExists(err) {
logger.V(6).Info("resource mutating webhook configuration already exists", "name", config.Name) logger.V(6).Info("resource mutating webhook configuration already exists", "name", config.Name)
err = wrc.updateMutatingWebhookConfiguration(config)
if err != nil {
return err
}
return nil return nil
} }
if err != nil { if err != nil {
logger.Error(err, "failed to create resource mutating webhook configuration", "name", config.Name) logger.Error(err, "failed to create resource mutating webhook configuration", "name", config.Name)
return err return err
@ -344,6 +346,10 @@ func (wrc *Register) createResourceValidatingWebhookConfiguration(caData []byte)
_, err := wrc.client.CreateResource("", kindValidating, "", *config, false) _, err := wrc.client.CreateResource("", kindValidating, "", *config, false)
if errorsapi.IsAlreadyExists(err) { if errorsapi.IsAlreadyExists(err) {
logger.V(6).Info("resource validating webhook configuration already exists", "name", config.Name) logger.V(6).Info("resource validating webhook configuration already exists", "name", config.Name)
err = wrc.updateValidatingWebhookConfiguration(config)
if err != nil {
return err
}
return nil return nil
} }
@ -369,6 +375,10 @@ func (wrc *Register) createPolicyValidatingWebhookConfiguration(caData []byte) e
if _, err := wrc.client.CreateResource("", kindValidating, "", *config, false); err != nil { if _, err := wrc.client.CreateResource("", kindValidating, "", *config, false); err != nil {
if errorsapi.IsAlreadyExists(err) { if errorsapi.IsAlreadyExists(err) {
wrc.log.V(6).Info("webhook already exists", "kind", kindValidating, "name", config.Name) wrc.log.V(6).Info("webhook already exists", "kind", kindValidating, "name", config.Name)
err = wrc.updateValidatingWebhookConfiguration(config)
if err != nil {
return err
}
return nil return nil
} }
@ -392,6 +402,10 @@ func (wrc *Register) createPolicyMutatingWebhookConfiguration(caData []byte) err
if _, err := wrc.client.CreateResource("", kindMutating, "", *config, false); err != nil { if _, err := wrc.client.CreateResource("", kindMutating, "", *config, false); err != nil {
if errorsapi.IsAlreadyExists(err) { if errorsapi.IsAlreadyExists(err) {
wrc.log.V(6).Info("webhook already exists", "kind", kindMutating, "name", config.Name) wrc.log.V(6).Info("webhook already exists", "kind", kindMutating, "name", config.Name)
err = wrc.updateMutatingWebhookConfiguration(config)
if err != nil {
return err
}
return nil return nil
} }
@ -414,6 +428,10 @@ func (wrc *Register) createVerifyMutatingWebhookConfiguration(caData []byte) err
if _, err := wrc.client.CreateResource("", kindMutating, "", *config, false); err != nil { if _, err := wrc.client.CreateResource("", kindMutating, "", *config, false); err != nil {
if errorsapi.IsAlreadyExists(err) { if errorsapi.IsAlreadyExists(err) {
wrc.log.V(6).Info("webhook already exists", "kind", kindMutating, "name", config.Name) wrc.log.V(6).Info("webhook already exists", "kind", kindMutating, "name", config.Name)
err = wrc.updateMutatingWebhookConfiguration(config)
if err != nil {
return err
}
return nil return nil
} }
@ -684,9 +702,6 @@ func (wrc *Register) checkEndpoint() error {
} }
} }
// clean up old webhook configurations, if any
wrc.removeWebhookConfigurations()
err = fmt.Errorf("endpoint not ready") err = fmt.Errorf("endpoint not ready")
wrc.log.V(3).Info(err.Error(), "ns", config.KyvernoNamespace, "name", config.KyvernoServiceName) wrc.log.V(3).Info(err.Error(), "ns", config.KyvernoNamespace, "name", config.KyvernoServiceName)
return err return err
@ -851,3 +866,93 @@ func (wrc *Register) updateResourceMutatingWebhookConfiguration(nsSelector map[s
return nil return nil
} }
// updateMutatingWebhookConfiguration updates an existing MutatingWebhookConfiguration with the rules provided by
// the targetConfig. If the targetConfig doesn't provide any rules, the existing rules will be preserved.
func (wrc *Register) updateMutatingWebhookConfiguration(targetConfig *admregapi.MutatingWebhookConfiguration) error {
// Fetch the existing webhook.
currentConfiguration, err := wrc.mwcLister.Get(targetConfig.Name)
if err != nil {
return fmt.Errorf("failed to get %s %s: %v", kindMutating, targetConfig.Name, err)
}
// Create a map of the target webhooks.
targetWebhooksMap := make(map[string]admregapi.MutatingWebhook)
for _, w := range targetConfig.Webhooks {
targetWebhooksMap[w.Name] = w
}
// Update the webhooks.
newWebhooks := make([]admregapi.MutatingWebhook, 0)
for _, w := range currentConfiguration.Webhooks {
target, exist := targetWebhooksMap[w.Name]
if !exist {
continue
}
delete(targetWebhooksMap, w.Name)
// Update the webhook configuration
w.ClientConfig.URL = target.ClientConfig.URL
w.ClientConfig.Service = target.ClientConfig.Service
w.ClientConfig.CABundle = target.ClientConfig.CABundle
if target.Rules != nil {
// If the target webhook has rule definitions override the current.
w.Rules = target.Rules
}
newWebhooks = append(newWebhooks, w)
}
// Check if there are additional webhooks defined and add them.
for _, w := range targetWebhooksMap {
newWebhooks = append(newWebhooks, w)
}
// Update the current configuration.
currentConfiguration.Webhooks = newWebhooks
_, err = wrc.client.UpdateResource("", kindMutating, "", currentConfiguration, false)
if err != nil {
return err
}
wrc.log.V(3).Info("successfully updated mutatingWebhookConfigurations", "name", targetConfig.Name)
return nil
}
// updateValidatingWebhookConfiguration updates an existing ValidatingWebhookConfiguration with the rules provided by
// the targetConfig. If the targetConfig doesn't provide any rules, the existing rules will be preserved.
func (wrc *Register) updateValidatingWebhookConfiguration(targetConfig *admregapi.ValidatingWebhookConfiguration) error {
// Fetch the existing webhook.
currentConfiguration, err := wrc.vwcLister.Get(targetConfig.Name)
if err != nil {
return fmt.Errorf("failed to get %s %s: %v", kindValidating, targetConfig.Name, err)
}
// Create a map of the target webhooks.
targetWebhooksMap := make(map[string]admregapi.ValidatingWebhook)
for _, w := range targetConfig.Webhooks {
targetWebhooksMap[w.Name] = w
}
// Update the webhooks.
newWebhooks := make([]admregapi.ValidatingWebhook, 0)
for _, w := range currentConfiguration.Webhooks {
target, exist := targetWebhooksMap[w.Name]
if !exist {
continue
}
delete(targetWebhooksMap, w.Name)
// Update the webhook configuration
w.ClientConfig.URL = target.ClientConfig.URL
w.ClientConfig.Service = target.ClientConfig.Service
w.ClientConfig.CABundle = target.ClientConfig.CABundle
if target.Rules != nil {
// If the target webhook has rule definitions override the current.
w.Rules = target.Rules
}
newWebhooks = append(newWebhooks, w)
}
// Check if there are additional webhooks defined and add them.
for _, w := range targetWebhooksMap {
newWebhooks = append(newWebhooks, w)
}
// Update the current configuration.
currentConfiguration.Webhooks = newWebhooks
_, err = wrc.client.UpdateResource("", kindValidating, "", currentConfiguration, false)
if err != nil {
return err
}
wrc.log.V(3).Info("successfully updated validatingWebhookConfigurations", "name", targetConfig.Name)
return nil
}