diff --git a/.github/workflows/k8s-matrix.yaml b/.github/workflows/k8s-matrix.yaml index 71c31033..1113b511 100644 --- a/.github/workflows/k8s-matrix.yaml +++ b/.github/workflows/k8s-matrix.yaml @@ -40,6 +40,7 @@ jobs: fail-fast: false matrix: matrixName: + - v1.31 - v1.30 - v1.29 - v1.28 @@ -47,20 +48,24 @@ jobs: - v1.26 - v1.25 include: + - matrixName: v1.31 + k8s: kindest/node:v1.31.0@sha256:53df588e04085fd41ae12de0c3fe4c72f7013bba32a20e7325357a1ac94ba865 + kindCommand: kind-calico + runNetTests: true - matrixName: v1.30 - k8s: kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e + k8s: kindest/node:v1.30.4@sha256:976ea815844d5fa93be213437e3ff5754cd599b040946b5cca43ca45c2047114 kindCommand: kind-calico runNetTests: true - matrixName: v1.29 - k8s: kindest/node:v1.29.4@sha256:3abb816a5b1061fb15c6e9e60856ec40d56b7b52bcea5f5f1350bc6e2320b6f8 + k8s: kindest/node:v1.29.8@sha256:d46b7aa29567e93b27f7531d258c372e829d7224b25e3fc6ffdefed12476d3aa kindCommand: kind-calico runNetTests: true - matrixName: v1.28 - k8s: kindest/node:v1.28.9@sha256:dca54bc6a6079dd34699d53d7d4ffa2e853e46a20cd12d619a09207e35300bd0 + k8s: kindest/node:v1.28.13@sha256:45d319897776e11167e4698f6b14938eb4d52eb381d9e3d7a9086c16c69a8110 kindCommand: kind-calico runNetTests: true - matrixName: v1.27 - k8s: kindest/node:v1.27.13@sha256:17439fa5b32290e3ead39ead1250dca1d822d94a10d26f1981756cd51b24b9d8 + k8s: kindest/node:v1.27.17@sha256:3fd82731af34efe19cd54ea5c25e882985bafa2c9baefe14f8deab1737d9fabe kindCommand: kind-calico runNetTests: true - matrixName: v1.26 diff --git a/Makefile b/Makefile index 4ccaef99..b6dcd7c1 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ COMPATIBLE_SELECTOR ?= control-plane=coherence # The GitHub project URL PROJECT_URL = https://github.com/oracle/coherence-operator -KUBERNETES_DOC_VERSION=v1.29 +KUBERNETES_DOC_VERSION=v1.30 # ---------------------------------------------------------------------------------------------------------------------- # The Coherence image to use for deployments that do not specify an image @@ -1569,7 +1569,7 @@ create-ssl-secrets: $(BUILD_OUTPUT)/certs ##@ KinD KIND_CLUSTER ?= operator -KIND_IMAGE ?= "kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e" +KIND_IMAGE ?= "kindest/node:v1.31.0@sha256:53df588e04085fd41ae12de0c3fe4c72f7013bba32a20e7325357a1ac94ba865" CALICO_TIMEOUT ?= 300s # ---------------------------------------------------------------------------------------------------------------------- @@ -1829,7 +1829,7 @@ tanzu-install: ## Install the Coherence Operator package into Tanzu # ====================================================================================================================== ##@ Miscellaneous -TRIVY_IMAGE=ghcr.io/aquasecurity/trivy:0.51.2 +TRIVY_IMAGE=ghcr.io/aquasecurity/trivy:0.54.1 .PHONY: trivy-scan trivy-scan: $(BUILD_TARGETS)/build-operator ## Scan the Operator image using Trivy docker pull $(TRIVY_IMAGE) @@ -1848,7 +1848,7 @@ controller-gen: $(TOOLS_BIN)/controller-gen ## Download controller-gen locally i $(TOOLS_BIN)/controller-gen: @echo "Downloading controller-gen" - test -s $(TOOLS_BIN)/controller-gen || GOBIN=$(TOOLS_BIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0 + test -s $(TOOLS_BIN)/controller-gen || GOBIN=$(TOOLS_BIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.2 ls -al $(TOOLS_BIN) # ---------------------------------------------------------------------------------------------------------------------- diff --git a/api/v1/coherence_types.go b/api/v1/coherence_types.go index 7a231d87..8516274a 100644 --- a/api/v1/coherence_types.go +++ b/api/v1/coherence_types.go @@ -589,6 +589,16 @@ type CoherenceWKASpec struct { // +listType=atomic // +optional Addresses []string `json:"addresses,omitempty"` + + // Labels is a map of optional additional labels to apply to the WKA Service. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ + // +optional + Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` + + // Annotations is a map of optional additional labels to apply to the WKA Service. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ + // +optional + Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` } // ----- CoherenceTracingSpec struct ---------------------------------------- diff --git a/api/v1/coherenceresourcespec_types.go b/api/v1/coherenceresourcespec_types.go index f4164f01..75e4f0c3 100644 --- a/api/v1/coherenceresourcespec_types.go +++ b/api/v1/coherenceresourcespec_types.go @@ -523,6 +523,20 @@ func (in *CoherenceResourceSpec) CreateWKAService(deployment CoherenceResource) } ann["service.alpha.kubernetes.io/tolerate-unready-endpoints"] = "true" + if in != nil { + cohSpec := in.Coherence + if cohSpec != nil { + if cohSpec.WKA != nil { + for k, v := range cohSpec.WKA.Labels { + labels[k] = v + } + for k, v := range cohSpec.WKA.Annotations { + ann[k] = v + } + } + } + } + svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: deployment.GetNamespace(), diff --git a/api/v1/create_job_wka_services_test.go b/api/v1/create_job_wka_services_test.go index e74d96f8..4c937f05 100644 --- a/api/v1/create_job_wka_services_test.go +++ b/api/v1/create_job_wka_services_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -198,6 +198,123 @@ func TestCreateWKAServiceForJobWithClusterName(t *testing.T) { assertWKAServiceForJob(t, deployment, expected) } +func TestCreateWKAServiceForJobWithAdditionalLabels(t *testing.T) { + extraLabels := make(map[string]string) + extraLabels["one"] = "label-one" + extraLabels["two"] = "label-two" + + // Create the test deployment + deployment := &coh.CoherenceJob{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test", + }, + Spec: coh.CoherenceJobResourceSpec{ + CoherenceResourceSpec: coh.CoherenceResourceSpec{ + Coherence: &coh.CoherenceSpec{ + WKA: &coh.CoherenceWKASpec{ + Labels: extraLabels, + }, + }, + }, + Cluster: "test-cluster", + }, + } + + // create the expected WKA service + labels := deployment.CreateCommonLabels() + labels[coh.LabelCoherenceCluster] = "test-cluster" + labels[coh.LabelComponent] = coh.LabelComponentWKA + labels["one"] = "label-one" + labels["two"] = "label-two" + + // The selector for the service (match all Pods with the same cluster label) + selector := make(map[string]string) + selector[coh.LabelCoherenceCluster] = "test-cluster" + selector[coh.LabelComponent] = coh.LabelComponentCoherencePod + selector[coh.LabelCoherenceWKAMember] = "true" + + expected := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test-wka", + Labels: labels, + Annotations: map[string]string{ + "service.alpha.kubernetes.io/tolerate-unready-endpoints": "true", + }, + }, + Spec: corev1.ServiceSpec{ + ClusterIP: corev1.ClusterIPNone, + // Pods must be part of the WKA service even if not ready + PublishNotReadyAddresses: true, + Ports: getDefaultServicePorts(), + Selector: selector, + }, + } + + // assert that the Services are as expected + assertWKAServiceForJob(t, deployment, expected) +} + +func TestCreateWKAServiceForJobWithAdditionalAnnotations(t *testing.T) { + extraAnnotations := make(map[string]string) + extraAnnotations["one"] = "label-one" + extraAnnotations["two"] = "label-two" + + // Create the test deployment + deployment := &coh.CoherenceJob{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test", + }, + Spec: coh.CoherenceJobResourceSpec{ + CoherenceResourceSpec: coh.CoherenceResourceSpec{ + Coherence: &coh.CoherenceSpec{ + WKA: &coh.CoherenceWKASpec{ + Annotations: extraAnnotations, + }, + }, + }, + Cluster: "test-cluster", + }, + } + + // create the expected WKA service + labels := deployment.CreateCommonLabels() + labels[coh.LabelCoherenceCluster] = "test-cluster" + labels[coh.LabelComponent] = coh.LabelComponentWKA + + ann := make(map[string]string) + ann["service.alpha.kubernetes.io/tolerate-unready-endpoints"] = "true" + ann["one"] = "label-one" + ann["two"] = "label-two" + + // The selector for the service (match all Pods with the same cluster label) + selector := make(map[string]string) + selector[coh.LabelCoherenceCluster] = "test-cluster" + selector[coh.LabelComponent] = coh.LabelComponentCoherencePod + selector[coh.LabelCoherenceWKAMember] = "true" + + expected := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test-wka", + Labels: labels, + Annotations: ann, + }, + Spec: corev1.ServiceSpec{ + ClusterIP: corev1.ClusterIPNone, + // Pods must be part of the WKA service even if not ready + PublishNotReadyAddresses: true, + Ports: getDefaultServicePorts(), + Selector: selector, + }, + } + + // assert that the Services are as expected + assertWKAServiceForJob(t, deployment, expected) +} + func assertWKAServiceForJob(t *testing.T, deployment *coh.CoherenceJob, expected *corev1.Service) { g := NewGomegaWithT(t) diff --git a/api/v1/create_wka_services_test.go b/api/v1/create_wka_services_test.go index 72514f62..3e7dd306 100644 --- a/api/v1/create_wka_services_test.go +++ b/api/v1/create_wka_services_test.go @@ -200,6 +200,123 @@ func TestCreateWKAServiceForDeploymentWithClusterName(t *testing.T) { assertWKAService(t, deployment, expected) } +func TestCreateWKAServiceForDeploymentWithAdditionalLabels(t *testing.T) { + extraLabels := make(map[string]string) + extraLabels["one"] = "label-one" + extraLabels["two"] = "label-two" + + // Create the test deployment + deployment := &coh.Coherence{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test", + }, + Spec: coh.CoherenceStatefulSetResourceSpec{ + CoherenceResourceSpec: coh.CoherenceResourceSpec{ + Coherence: &coh.CoherenceSpec{ + WKA: &coh.CoherenceWKASpec{ + Labels: extraLabels, + }, + }, + }, + Cluster: ptr.To("test-cluster"), + }, + } + + // create the expected WKA service + labels := deployment.CreateCommonLabels() + labels[coh.LabelCoherenceCluster] = "test-cluster" + labels[coh.LabelComponent] = coh.LabelComponentWKA + labels["one"] = "label-one" + labels["two"] = "label-two" + + // The selector for the service (match all Pods with the same cluster label) + selector := make(map[string]string) + selector[coh.LabelCoherenceCluster] = "test-cluster" + selector[coh.LabelComponent] = coh.LabelComponentCoherencePod + selector[coh.LabelCoherenceWKAMember] = "true" + + expected := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test-wka", + Labels: labels, + Annotations: map[string]string{ + "service.alpha.kubernetes.io/tolerate-unready-endpoints": "true", + }, + }, + Spec: corev1.ServiceSpec{ + ClusterIP: corev1.ClusterIPNone, + // Pods must be part of the WKA service even if not ready + PublishNotReadyAddresses: true, + Ports: getDefaultServicePorts(), + Selector: selector, + }, + } + + // assert that the Services are as expected + assertWKAService(t, deployment, expected) +} + +func TestCreateWKAServiceForDeploymentWithAdditionalAnnotations(t *testing.T) { + extraAnnotations := make(map[string]string) + extraAnnotations["one"] = "label-one" + extraAnnotations["two"] = "label-two" + + // Create the test deployment + deployment := &coh.Coherence{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test", + }, + Spec: coh.CoherenceStatefulSetResourceSpec{ + CoherenceResourceSpec: coh.CoherenceResourceSpec{ + Coherence: &coh.CoherenceSpec{ + WKA: &coh.CoherenceWKASpec{ + Annotations: extraAnnotations, + }, + }, + }, + Cluster: ptr.To("test-cluster"), + }, + } + + // create the expected WKA service + labels := deployment.CreateCommonLabels() + labels[coh.LabelCoherenceCluster] = "test-cluster" + labels[coh.LabelComponent] = coh.LabelComponentWKA + + ann := make(map[string]string) + ann["service.alpha.kubernetes.io/tolerate-unready-endpoints"] = "true" + ann["one"] = "label-one" + ann["two"] = "label-two" + + // The selector for the service (match all Pods with the same cluster label) + selector := make(map[string]string) + selector[coh.LabelCoherenceCluster] = "test-cluster" + selector[coh.LabelComponent] = coh.LabelComponentCoherencePod + selector[coh.LabelCoherenceWKAMember] = "true" + + expected := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: "test-wka", + Labels: labels, + Annotations: ann, + }, + Spec: corev1.ServiceSpec{ + ClusterIP: corev1.ClusterIPNone, + // Pods must be part of the WKA service even if not ready + PublishNotReadyAddresses: true, + Ports: getDefaultServicePorts(), + Selector: selector, + }, + } + + // assert that the Services are as expected + assertWKAService(t, deployment, expected) +} + func assertWKAService(t *testing.T, deployment *coh.Coherence, expected *corev1.Service) { g := NewGomegaWithT(t) diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 44fb6886..5a74af02 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -947,6 +947,20 @@ func (in *CoherenceWKASpec) DeepCopyInto(out *CoherenceWKASpec) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceWKASpec. diff --git a/docs/about/04_coherence_spec.adoc b/docs/about/04_coherence_spec.adoc index c6400243..e4e51a37 100644 --- a/docs/about/04_coherence_spec.adoc +++ b/docs/about/04_coherence_spec.adoc @@ -275,6 +275,8 @@ CoherenceWKASpec configures Coherence well-known-addressing to use an existing C m| deployment | The name of the existing Coherence deployment to use for WKA. m| string | true m| namespace | The optional namespace of the existing Coherence deployment to use for WKA if different from this deployment's namespace. m| string | false m| addresses | A list of addresses to be used for WKA. If this field is set, the WKA property for the Coherence cluster will be set using this value and the other WKA fields will be ignored. m| []string | false +m| labels | Labels is a map of optional additional labels to apply to the WKA Service. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ m| map[string]string | false +m| annotations | Annotations is a map of optional additional labels to apply to the WKA Service. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ m| map[string]string | false |=== <