Change disableHookValidation field in cr
MODIFY
deploy/cr.yaml
deploy/cr.yaml
@@ -15,7 +15,7 @@ spec:
sslSecretName: my-cluster-ssl
sslInternalSecretName: my-cluster-ssl-internal
logCollectorSecretName: my-log-collector-secrets
-# disableHookValidation: true
+# enableCRValidationWebhook: true
# tls:
# SANs:
# - pxc-1.example.com

MODIFY
e2e-tests/validation-hook/conf/cr-with-haproxy-and-proxysql.yaml
e2e-tests/validation-hook/conf/cr-with-haproxy-and-proxysql.yaml
@@ -14,7 +14,7 @@ spec:
vaultSecretName: keyring-secret-vault
sslSecretName: my-cluster-ssl
sslInternalSecretName: my-cluster-ssl-internal
-# disableHookValidation: true
+ enableCRValidationWebhook: true
# tls:
# SANs:
# - pxc-1.example.com

MODIFY
e2e-tests/validation-hook/conf/cr-with-no-storage.yaml
e2e-tests/validation-hook/conf/cr-with-no-storage.yaml
@@ -6,6 +6,7 @@ spec:
secretsName: my-cluster-secrets
sslSecretName: some-name-ssl
sslInternalSecretName: some-name-ssl-internal
+ enableCRValidationWebhook: true
pxc:
size: 3
image: -pxc

MODIFY
e2e-tests/validation-hook/conf/cr-with-too-long-name.yaml
e2e-tests/validation-hook/conf/cr-with-too-long-name.yaml
@@ -14,7 +14,7 @@ spec:
vaultSecretName: keyring-secret-vault
sslSecretName: my-cluster-ssl
sslInternalSecretName: my-cluster-ssl-internal
-# disableHookValidation: true
+ enableCRValidationWebhook: true
# tls:
# SANs:
# - pxc-1.example.com

MODIFY
pkg/apis/pxc/v1/pxc_types.go
pkg/apis/pxc/v1/pxc_types.go
@@ -37,7 +37,7 @@ type PerconaXtraDBClusterSpec struct {
UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"`
AllowUnsafeConfig bool `json:"allowUnsafeConfigurations,omitempty"`
InitImage string `json:"initImage,omitempty"`
- DisableHookValidation bool `json:"disableHookValidation,omitempty"`
+ EnableCRValidationWebhook *bool `json:"enableCRValidationWebhook,omitempty"`
}
type PXCSpec struct {
@@ -643,6 +643,11 @@ func (cr *PerconaXtraDBCluster) CheckNSetDefaults(serverVersion *version.ServerV
cr.setSecurityContext()
+ if cr.Spec.EnableCRValidationWebhook == nil {
+ falseVal := false
+ cr.Spec.EnableCRValidationWebhook = &falseVal
+ }
+
return CRVerChanged || changed, nil
}

MODIFY
pkg/webhook/hook.go
pkg/webhook/hook.go
@@ -226,7 +226,7 @@ func (h *hook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
- if cr.Spec.DisableHookValidation {
+ if cr.Spec.EnableCRValidationWebhook == nil || !*cr.Spec.EnableCRValidationWebhook {
err = sendResponse(req.Request.UID, req.TypeMeta, w, nil)
if err != nil {
log.Log.Error(err, "Can't send validation response")

K8SPXC-595: Change disableHookValidation field in cr (#721)