You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This patch makes several corrections to the conversion webhook:
- fixes several occurrences of the old validation webhook codebase
- simplify the webhook command and drops the direct cobra dependency
- align the README with what the code really does
- removes the unneeded structure in the unit tests
- removes unneeded code and the unneeded dependencies
- drop support for converting VolumeSnapshots and VolumeSnapshotClasses as they
are structurally identical
Signed-off-by: Leonardo Cecchi <[email protected]>
Copy file name to clipboardExpand all lines: deploy/kubernetes/webhook-example/README.md
+29-12Lines changed: 29 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,11 @@
1
-
# Validating Webhook
1
+
# Conversion Webhook
2
2
3
-
The snapshot validating webhook is an HTTP callback which responds to [admission requests](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/). It is part of a larger [plan](https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1900-volume-snapshot-validation-webhook#proposal) to tighten validation for volume snapshot objects. This webhook introduces the [ratcheting validation](https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1900-volume-snapshot-validation-webhook#backwards-compatibility) mechanism targeting the tighter validation. The cluster admin or Kubernetes distribution admin should install the webhook alongside the snapshot controllers and CRDs.
3
+
The snapshot conversion webhook is an HTTP callback which responds to
The webhook server is provided as an image which can be built from this repository. It can be deployed anywhere, as long as the api server is able to reach it over HTTPS. It is recommended to deploy the webhook server in the cluster as snapshotting is latency sensitive. A `ValidatingWebhookConfiguration` object is needed to configure the api server to contact the webhook server. Please see the [documentation](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/) for more details. The webhook server code is adapted from the [webhook server](https://github.com/kubernetes/kubernetes/tree/v1.18.6/test/images/agnhost/webhook) used in the kubernetes/kubernetes end to end testing code.
26
+
The webhook server is provided as an image which can be built from this repository. It can be deployed anywhere,
27
+
as long as the api server is able to reach it over HTTPS. It is recommended to deploy the webhook server in the
28
+
cluster as snapshotting is latency sensitive.
29
+
30
+
The CRD may need to be patched to allow safe TLS communication to the webhook server.
31
+
Please see the [documentation](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#webhook-conversion)
32
+
for more details.
33
+
34
+
The webhook server code is adapted from the [webhook server](https://github.com/kubernetes/kubernetes/blob/v1.25.3/test/images/agnhost/crd-conversion-webhook/main.go)
35
+
used in the kubernetes/kubernetes e2e testing code.
22
36
23
37
### Example in-cluster deployment using Kubernetes Secrets
24
38
25
-
Please note this is not considered to be a production ready method to deploy the certificates and is only provided for demo purposes. This is only one of many ways to deploy the certificates, it is your responsibility to ensure the security of your cluster. TLS certificates and private keys should be handled with care and you may not want to keep them in plain Kubernetes secrets.
39
+
Please note this is not considered to be a production ready method to deploy the certificates and is only provided
40
+
for demo purposes. This is only one of many ways to deploy the certificates, it is your responsibility to
41
+
ensure the security of your cluster.
42
+
43
+
TLS certificates and private keys should be handled with care and you may not want to keep them in plain
44
+
Kubernetes secrets.
26
45
27
46
This method was heavily adapted from [banzai cloud](https://banzaicloud.com/blog/k8s-admission-webhooks/).
28
47
@@ -38,7 +57,7 @@ These commands should be run from the top level directory.
38
57
./deploy/kubernetes/webhook-example/create-cert.sh --service snapshot-conversion-webhook-service --secret snapshot-conversion-webhook-secret --namespace default # Make sure to use a different namespace
39
58
```
40
59
41
-
2. Patch the VolumeGroupSnapshot, VolumeGroupSnapshotContent and VolumeGroupSnapshotClass CRDs filling in the CA bundle field.
60
+
2. Patch the VolumeGroupSnapshotContent CRD filling in the CA bundle field.
@@ -56,20 +75,18 @@ Once all the pods from the deployment are up and running, you should be ready to
56
75
57
76
#### Verify the webhook works
58
77
59
-
Try to query the API server fora VolumeGroupSnapshot objectin the version `v1beta1`.
78
+
Try to query the API server fora VolumeGroupSnapshotContent objectin the version `v1beta1`.
60
79
61
80
```bash
62
-
kubectl get volumegroupsnapshotclass.v1beta1.groupsnapshot.storage.k8s.io
63
-
64
81
kubectl get volumegroupsnapshotcontent.v1beta1.groupsnapshot.storage.k8s.io
65
-
66
-
kubectl get volumegroupsnapshot.v1beta1.groupsnapshot.storage.k8s.io
67
82
```
68
83
69
84
### Other methods to deploy the webhook server
70
85
71
-
Look into [cert-manager](https://cert-manager.io/) to handle the certificates, and this kube-builder [tutorial](https://book.kubebuilder.io/cronjob-tutorial/cert-manager.html) on how to deploy a webhook.
86
+
Look into [cert-manager](https://cert-manager.io/) to handle the certificates,
87
+
and this kube-builder [tutorial](https://book.kubebuilder.io/cronjob-tutorial/cert-manager.html) on how to deploy a webhook.
72
88
73
89
#### Important
74
90
75
-
Please see the deployment [yaml](./webhook.yaml) for the arguments expected by the webhook server. The snapshot validation webhook is served at the path `/volumesnapshot`.
91
+
Please see the deployment [yaml](./webhook.yaml) for the arguments expected by the
92
+
webhook server. The conversion webhook is served at the path `/convert`.
0 commit comments