diff --git a/Makefile b/Makefile index 20dd384..2eb877b 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ export E2E_CONTROLLER_TOOLS_VERSION ?= $(CONTROLLER_TOOLS_VERSION) export E2E_MARKLOGIC_IMAGE_VERSION ?= progressofficial/marklogic-db:11.3.1-ubi-rootless-2.1.0 export E2E_KUBERNETES_VERSION ?= v1.30.4 +# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. +ENVTEST_K8S_VERSION = 1.31.0 + # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") @@ -62,8 +65,7 @@ OPERATOR_SDK_VERSION ?= v1.34.2 # Image URL to use all building/pushing image targets IMG ?= ml-marklogic-operator-dev.bed-artifactory.bedford.progress.com/marklogic-kubernetes-operator:1.0.0-ea2 -# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.28.3 + # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -195,8 +197,8 @@ run: manifests generate fmt vet ## Run a controller from your host. # (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: docker-build -docker-build: ## Build docker image with the manager. - $(CONTAINER_TOOL) build --platform="linux/amd64" -t ${IMG} . +docker-build: ## Build docker image with the manager. to build for linux, add --platform="linux/amd64" + $(CONTAINER_TOOL) buildx build -t ${IMG} . .PHONY: docker-push docker-push: ## Push docker image with the manager. @@ -257,9 +259,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions KUSTOMIZE_VERSION ?= v5.5.0 -CONTROLLER_TOOLS_VERSION ?= v0.16.4 - - +CONTROLLER_TOOLS_VERSION ?= v0.17.1 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading. diff --git a/api/v1alpha1/marklogiccluster_types.go b/api/v1alpha1/marklogiccluster_types.go index 8d6c2f6..452a5ad 100644 --- a/api/v1alpha1/marklogiccluster_types.go +++ b/api/v1alpha1/marklogiccluster_types.go @@ -64,6 +64,9 @@ type MarklogicClusterSpec struct { HAProxy *HAProxy `json:"haproxy,omitempty"` Tls *Tls `json:"tls,omitempty"` + // +kubebuilder:validation:MaxItems=100 + // +kubebuilder:validation:XValidation:rule="size(self) == 1 || (size(self) == size(self.map(x, x.groupConfig.name).filter(y, self.map(x, x.groupConfig.name).filter(z, z == y).size() == 1)))", message="MarkLogicGroups must have unique groupConfig names" + // +kubebuilder:validation:XValidation:rule="size(self) == size(self.map(x, x.name).filter(y, self.map(x, x.name).filter(z, z == y).size() == 1))", message="MarkLogicGroups must have unique names" MarkLogicGroups []*MarklogicGroups `json:"markLogicGroups,omitempty"` } diff --git a/api/v1alpha1/marklogicgroup_types.go b/api/v1alpha1/marklogicgroup_types.go index 438c8a5..c6297ae 100644 --- a/api/v1alpha1/marklogicgroup_types.go +++ b/api/v1alpha1/marklogicgroup_types.go @@ -130,6 +130,7 @@ func (status *MarklogicGroupStatus) GetConditionStatus(conditionType string) met } type GroupConfig struct { + // +kubebuilder:default:="Default" Name string `json:"name,omitempty"` EnableXdqpSsl bool `json:"enableXdqpSsl,omitempty"` } diff --git a/config/crd/bases/database.marklogic.com_marklogicclusters.yaml b/config/crd/bases/database.marklogic.com_marklogicclusters.yaml index c40e2ff..21c94c7 100644 --- a/config/crd/bases/database.marklogic.com_marklogicclusters.yaml +++ b/config/crd/bases/database.marklogic.com_marklogicclusters.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4 + controller-gen.kubebuilder.io/version: v0.17.1 name: marklogicclusters.database.marklogic.com spec: group: database.marklogic.com @@ -3345,6 +3345,7 @@ spec: enableXdqpSsl: type: boolean name: + default: Default type: string type: object haproxy: @@ -6929,7 +6930,15 @@ spec: type: object type: array type: object + maxItems: 100 type: array + x-kubernetes-validations: + - message: MarkLogicGroups must have unique groupConfig names + rule: size(self) == 1 || (size(self) == size(self.map(x, x.groupConfig.name).filter(y, + self.map(x, x.groupConfig.name).filter(z, z == y).size() == 1))) + - message: MarkLogicGroups must have unique names + rule: size(self) == size(self.map(x, x.name).filter(y, self.map(x, + x.name).filter(z, z == y).size() == 1)) networkPolicy: properties: egress: diff --git a/config/crd/bases/database.marklogic.com_marklogicgroups.yaml b/config/crd/bases/database.marklogic.com_marklogicgroups.yaml index ac3ed4c..5fdf853 100644 --- a/config/crd/bases/database.marklogic.com_marklogicgroups.yaml +++ b/config/crd/bases/database.marklogic.com_marklogicgroups.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4 + controller-gen.kubebuilder.io/version: v0.17.1 name: marklogicgroups.database.marklogic.com spec: group: database.marklogic.com @@ -985,6 +985,7 @@ spec: enableXdqpSsl: type: boolean name: + default: Default type: string type: object hugePages: diff --git a/internal/controller/marklogiccluster_controller_test.go b/internal/controller/marklogiccluster_controller_test.go index 39eba2a..3afad01 100644 --- a/internal/controller/marklogiccluster_controller_test.go +++ b/internal/controller/marklogiccluster_controller_test.go @@ -46,11 +46,17 @@ var policy = []networkingv1.PolicyType{networkingv1.PolicyTypeIngress, networkin var marklogicGroups = []*databasev1alpha1.MarklogicGroups{ { - Name: "dnode", + Name: "dnode", + GroupConfig: &databasev1alpha1.GroupConfig{ + Name: "dnode", + }, Replicas: &dnodeReplicas, }, { - Name: "enode", + Name: "enode", + GroupConfig: &databasev1alpha1.GroupConfig{ + Name: "enode", + }, Replicas: &enodeReplicas, }, } diff --git a/test/e2e/3_ml_cluster_ednode_test.go b/test/e2e/3_ml_cluster_ednode_test.go index 95953a3..eee49e2 100644 --- a/test/e2e/3_ml_cluster_ednode_test.go +++ b/test/e2e/3_ml_cluster_ednode_test.go @@ -131,12 +131,12 @@ func TestMlClusterWithEdnode(t *testing.T) { // Assessment to check for MarkLogic groups are created feature.Assess("MarkLogic groups created", func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context { + t.Log("Checking MarkLogic groups") podName := "dnode-0" - containerName := "marklogic-server" url := "http://localhost:8002/manage/v2/groups" curlCommand := fmt.Sprintf("curl %s --anyauth -u %s:%s", url, adminUsername, adminPassword) - output, err := utils.ExecCmdInPod(podName, mlClusterNs, containerName, curlCommand) + output, err := utils.ExecCmdInPod(podName, mlClusterNs, mlContainerName, curlCommand) if err != nil { t.Fatalf("Failed to execute curl command in pod: %v", err) }