Skip to content

Commit 06989d7

Browse files
author
Andi Li
committed
Update documentation.
Minor cleanup and change default fail policy and timeout on webhook config.
1 parent 42b6b37 commit 06989d7

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@ Install CSI Driver:
8383

8484
### Validating Webhook
8585

86-
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/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md) to tighten validation for volume snapshot objects. This webhook introduces the [ratcheting validation](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md#backwards-compatibility) mechanism targeting the tighter validation.
86+
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/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md) to tighten validation for volume snapshot objects. This webhook introduces the [ratcheting validation](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md#backwards-compatibility) mechanism targeting the tighter validation. The cluster admin or Kubernetes distribution admin should install the webhook alongside the snapshot controllers and CRDs.
8787

88-
> :warning: **WARNING**: Choosing not to install the webhook server and participate in the phased release process can cause future problems when upgrading from `v1beta1` to `v1` volumesnapshot API if there are currently persisted objects which fail the new stricter validation. Potential impacts include being unable to delete invalid snapshot objects.
88+
> :warning: **WARNING**: Cluster admins choosing not to install the webhook server and participate in the phased release process can cause future problems when upgrading from `v1beta1` to `v1` volumesnapshot API, if there are currently persisted objects which fail the new stricter validation. Potential impacts include being unable to delete invalid snapshot objects.
8989
9090
Read more about how to install the example webhook [here](deploy/kubernetes/webhook-example/README.md).
9191

92+
#### Validating Webhook Command Line Options
93+
94+
* `--tls-cert-file`: File containing the x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert). Required.
95+
* `--tls-private-key-file`: File containing the x509 private key matching --tls-cert-file. Required.
96+
* `--port`: Secure port that the webhook listens on (default 443)
97+
9298
### Snapshot controller command line options
9399

94100
#### Important optional arguments that are highly recommended to be used

deploy/kubernetes/webhook-example/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Validating Webhook
22

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/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md) to tighten validation for volume snapshot objects. This webhook introduces the [ratcheting validation](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md#backwards-compatibility) mechanism targeting the tighter validation.
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/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md) to tighten validation for volume snapshot objects. This webhook introduces the [ratcheting validation](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md#backwards-compatibility) mechanism targeting the tighter validation. The cluster admin or Kubernetes distribution admin should install the webhook alongside the snapshot controllers and CRDs.
44

5-
> :warning: **WARNING**: Choosing not to install the webhook server and participate in the phased release process can cause future problems when upgrading from `v1beta1` to `v1` volumesnapshot API if there are currently persisted objects which fail the new stricter validation. Potential impacts include being unable to delete invalid snapshot objects.
5+
> :warning: **WARNING**: Cluster admins choosing not to install the webhook server and participate in the phased release process can cause future problems when upgrading from `v1beta1` to `v1` volumesnapshot API, if there are currently persisted objects which fail the new stricter validation. Potential impacts include being unable to delete invalid snapshot objects.
66
77
## Prerequisites
88

deploy/kubernetes/webhook-example/admission-configuration-template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: admissionregistration.k8s.io/v1
22
kind: ValidatingWebhookConfiguration
33
metadata:
4-
name: "validation-webhook.storage.sigs.k8s.io"
4+
name: "validation-webhook.snapshot.storage.k8s.io"
55
namespace: "default"
66
webhooks:
7-
- name: "snapshot.validation-webhook.storage.sigs.k8s.io"
7+
- name: "validation-webhook.snapshot.storage.k8s.io"
88
rules:
99
- apiGroups: ["snapshot.storage.k8s.io"]
1010
apiVersions: ["v1beta1"]
@@ -19,5 +19,5 @@ webhooks:
1919
caBundle: ${CA_BUNDLE}
2020
admissionReviewVersions: ["v1", "v1beta1"]
2121
sideEffects: None
22-
failurePolicy: Fail # We recommend switching to Fail only after successful installation of the server and webhook.
23-
timeoutSeconds: 10 # This will affect the latency and performance. Finetune this value based on your application's tolerance.
22+
failurePolicy: Ignore # We recommend switching to Fail only after successful installation of the webhook server and webhook.
23+
timeoutSeconds: 2 # This will affect the latency and performance. Finetune this value based on your application's tolerance.

pkg/validation-webhook/webhook.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import (
2828
"k8s.io/api/admission/v1beta1"
2929
"k8s.io/apimachinery/pkg/runtime"
3030
"k8s.io/klog"
31-
// TODO: try this library to see if it generates correct json patch
32-
// https://github.com/mattbaird/jsonpatch
3331
)
3432

3533
var (
@@ -38,22 +36,22 @@ var (
3836
port int
3937
)
4038

41-
// CmdWebhook is used by agnhost Cobra.
39+
// CmdWebhook is used by Cobra.
4240
var CmdWebhook = &cobra.Command{
4341
Use: "validation-webhook",
44-
Short: "Starts a HTTP server, useful for testing MutatingAdmissionWebhook and ValidatingAdmissionWebhook",
45-
Long: `Starts a HTTP server, useful for testing MutatingAdmissionWebhook and ValidatingAdmissionWebhook.
42+
Short: "Starts a HTTPS server, uses ValidatingAdmissionWebhook to perform ratcheting validation on VolumeSnapshot and VolumeSnapshotContent",
43+
Long: `Starts a HTTPS server, uses ValidatingAdmissionWebhook to perform ratcheting validation on VolumeSnapshot and VolumeSnapshotContent.
4644
After deploying it to Kubernetes cluster, the Administrator needs to create a ValidatingWebhookConfiguration
47-
in the Kubernetes cluster to register remote webhook admission controllers.`,
45+
in the Kubernetes cluster to register remote webhook admission controllers. Phase one of https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md`,
4846
Args: cobra.MaximumNArgs(0),
4947
Run: main,
5048
}
5149

5250
func init() {
5351
CmdWebhook.Flags().StringVar(&certFile, "tls-cert-file", "",
54-
"File containing the default x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert).")
52+
"File containing the x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert). Required.")
5553
CmdWebhook.Flags().StringVar(&keyFile, "tls-private-key-file", "",
56-
"File containing the default x509 private key matching --tls-cert-file.")
54+
"File containing the x509 private key matching --tls-cert-file. Required.")
5755
CmdWebhook.Flags().IntVar(&port, "port", 443,
5856
"Secure port that the webhook listens on")
5957
CmdWebhook.MarkFlagRequired("tls-cert-file")

0 commit comments

Comments
 (0)