From 64e600e8d75404d60f87ede13547adbe546720b2 Mon Sep 17 00:00:00 2001 From: Peng Zhou Date: Tue, 1 Oct 2024 23:08:50 -0700 Subject: [PATCH 1/3] fix CRD Validation --- api/v1alpha1/common_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1alpha1/common_types.go b/api/v1alpha1/common_types.go index 2f4c20f..4058b89 100644 --- a/api/v1alpha1/common_types.go +++ b/api/v1alpha1/common_types.go @@ -77,7 +77,7 @@ type NetworkPolicy struct { type HAProxy struct { Enabled bool `json:"enabled,omitempty"` // +kubebuilder:default:="haproxytech/haproxy-alpine:3.1" - Image string `json:"image"` + Image string `json:"image,omitempty"` // +kubebuilder:default:=1 ReplicaCount int32 `json:"replicas,omitempty"` // +kubebuilder:default:=80 From 2971fab8d7a55b2e7e056de83d0d003febfa0715 Mon Sep 17 00:00:00 2001 From: Peng Zhou Date: Tue, 1 Oct 2024 23:10:37 -0700 Subject: [PATCH 2/3] MLE-11585: Implement CRD Validation for ML version Check --- .../database.marklogic.com_marklogicclusters.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/crd/bases/database.marklogic.com_marklogicclusters.yaml b/config/crd/bases/database.marklogic.com_marklogicclusters.yaml index ee03c94..1187168 100644 --- a/config/crd/bases/database.marklogic.com_marklogicclusters.yaml +++ b/config/crd/bases/database.marklogic.com_marklogicclusters.yaml @@ -37,7 +37,6 @@ spec: metadata: type: object spec: - description: MarklogicClusterSpec defines the desired state of MarklogicCluster properties: affinity: description: Affinity is a group of affinity scheduling rules. @@ -2048,8 +2047,6 @@ spec: secretName: type: string type: object - required: - - image type: object hugePages: default: @@ -4200,8 +4197,6 @@ spec: secretName: type: string type: object - required: - - image type: object hugePages: properties: @@ -9391,6 +9386,12 @@ spec: required: - image type: object + x-kubernetes-validations: + - message: HAProxy and Pathbased Routing is enabled. PathBasedRouting + is only supported for MarkLogic 11.1 and above + rule: '!(self.haproxy.enabled == true && self.haproxy.pathBasedRouting + == true) || int(self.image.split('':'')[1].split(''.'')[0] + self.image.split('':'')[1].split(''.'')[1]) + >= 111' status: description: MarklogicClusterStatus defines the observed state of MarklogicCluster properties: From f9cb1b06ed740d3a778009a30ad336b9f450a839 Mon Sep 17 00:00:00 2001 From: Peng Zhou Date: Wed, 2 Oct 2024 09:35:35 -0700 Subject: [PATCH 3/3] MLE-11585 Implement path based routing ML version check --- api/v1alpha1/marklogiccluster_types.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/v1alpha1/marklogiccluster_types.go b/api/v1alpha1/marklogiccluster_types.go index f46f055..e68e338 100644 --- a/api/v1alpha1/marklogiccluster_types.go +++ b/api/v1alpha1/marklogiccluster_types.go @@ -26,6 +26,8 @@ import ( // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. // MarklogicClusterSpec defines the desired state of MarklogicCluster + +// +kubebuilder:validation:XValidation:rule="!(self.haproxy.enabled == true && self.haproxy.pathBasedRouting == true) || int(self.image.split(':')[1].split('.')[0] + self.image.split(':')[1].split('.')[1]) >= 111", message="HAProxy and Pathbased Routing is enabled. PathBasedRouting is only supported for MarkLogic 11.1 and above" type MarklogicClusterSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file