Skip to content

Commit 26c792f

Browse files
authored
Build using K8s 1.28 and Go 1.20 (#616)
* Update K8s dependencies * Change Istio versions for tests
1 parent c3dcaf9 commit 26c792f

38 files changed

+532
-1609
lines changed

.github/workflows/istio-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ jobs:
3838
matrix:
3939
istioVersion:
4040
- latest
41-
- 1.16.1
42-
- 1.15.4
41+
- 1.18.2
42+
- 1.17.5
4343

4444
steps:
4545
- uses: actions/checkout@v3

Makefile

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ COMPATIBLE_SELECTOR = control-plane=coherence
3232
# The GitHub project URL
3333
PROJECT_URL = https://github.com/oracle/coherence-operator
3434

35-
KUBERNETES_DOC_VERSION=v1.26
35+
KUBERNETES_DOC_VERSION=v1.28
3636

3737
# ----------------------------------------------------------------------------------------------------------------------
3838
# The Coherence image to use for deployments that do not specify an image
@@ -325,6 +325,7 @@ GOS = $(shell find . -type f -name "*.go" ! -name "*_test.go")
325325
HELM_FILES = $(shell find helm-charts/coherence-operator -type f)
326326
API_GO_FILES = $(shell find . -type f -name "*.go" ! -name "*_test.go" ! -name "zz*.go")
327327
CRDV1_FILES = $(shell find ./config/crd -type f)
328+
JAVA_FILES = $(shell find ./java -type f)
328329

329330
TEST_SSL_SECRET := coherence-ssl-secret
330331

@@ -431,7 +432,7 @@ clean-tools: ## Cleans the locally downloaded build tools (i.e. need a new tool
431432
.PHONY: build-operator
432433
build-operator: $(BUILD_TARGETS)/build-operator ## Build the Coherence Operator image
433434

434-
$(BUILD_TARGETS)/build-operator: $(BUILD_BIN)/runner build-mvn coherence-cli
435+
$(BUILD_TARGETS)/build-operator: $(BUILD_BIN)/runner $(BUILD_TARGETS)/java $(BUILD_TARGETS)/cli
435436
docker build --no-cache --build-arg version=$(VERSION) \
436437
--build-arg BASE_IMAGE=$(OPERATOR_BASE_IMAGE) \
437438
--build-arg coherence_image=$(COHERENCE_IMAGE) \
@@ -448,7 +449,7 @@ $(BUILD_TARGETS)/build-operator: $(BUILD_BIN)/runner build-mvn coherence-cli
448449
touch $(BUILD_TARGETS)/build-operator
449450

450451
.PHONY: build-operator-with-tools
451-
build-operator-with-tools: $(BUILD_BIN)/runner build-mvn ## Build the Coherence Operator image on OL-8 with debug tools
452+
build-operator-with-tools: $(BUILD_BIN)/runner $(BUILD_TARGETS)/java ## Build the Coherence Operator image on OL-8 with debug tools
452453
mkdir -p $(BUILD_OUTPUT)/images || true
453454
cat Dockerfile debug/Tools.Dockerfile > $(BUILD_OUTPUT)/images/Dockerfile
454455
docker build --no-cache --build-arg version=$(VERSION) \
@@ -460,7 +461,7 @@ build-operator-with-tools: $(BUILD_BIN)/runner build-mvn ## Build the Coherence
460461
. -t $(OPERATOR_IMAGE)
461462

462463
.PHONY: build-operator-debug
463-
build-operator-debug: $(BUILD_BIN)/linux/amd64/runner-debug build-mvn ## Build the Coherence Operator image with the Delve debugger
464+
build-operator-debug: $(BUILD_BIN)/linux/amd64/runner-debug $(BUILD_TARGETS)/java ## Build the Coherence Operator image with the Delve debugger
464465
docker build --no-cache --build-arg version=$(VERSION) \
465466
--build-arg BASE_IMAGE=$(OPERATOR_IMAGE_DELVE) \
466467
--build-arg coherence_image=$(COHERENCE_IMAGE) \
@@ -486,7 +487,7 @@ build-operator-images: $(BUILD_TARGETS)/build-operator ## Build all operator ima
486487
# Build the Operator Test images
487488
# ----------------------------------------------------------------------------------------------------------------------
488489
.PHONY: build-test-images
489-
build-test-images: build-mvn build-client-image build-basic-test-image ## Build all of the test images
490+
build-test-images: $(BUILD_TARGETS)/java build-client-image build-basic-test-image ## Build all of the test images
490491
./mvnw -B -f java/operator-test-helidon package jib:dockerBuild -DskipTests -Djib.to.image=$(TEST_APPLICATION_IMAGE_HELIDON) $(MAVEN_BUILD_OPTS)
491492
./mvnw -B -f java/operator-test-spring package jib:dockerBuild -DskipTests -Djib.to.image=$(TEST_APPLICATION_IMAGE_SPRING) $(MAVEN_BUILD_OPTS)
492493
./mvnw -B -f java/operator-test-spring package spring-boot:build-image -DskipTests -Dcnbp-image-name=$(TEST_APPLICATION_IMAGE_SPRING_CNBP) $(MAVEN_BUILD_OPTS)
@@ -500,7 +501,7 @@ build-test-images: build-mvn build-client-image build-basic-test-image ## Build
500501
# Build the basic Operator Test image
501502
# ----------------------------------------------------------------------------------------------------------------------
502503
.PHONY: build-basic-test-image
503-
build-basic-test-image: build-mvn ## Build the basic Operator test image
504+
build-basic-test-image: $(BUILD_TARGETS)/java ## Build the basic Operator test image
504505
./mvnw -B -f java/operator-test clean package jib:dockerBuild -DskipTests -Djib.to.image=$(TEST_APPLICATION_IMAGE) $(MAVEN_BUILD_OPTS) -Dcoherence.version=$(COHERENCE_IMAGE_TAG)
505506

506507
.PHONY: build-client-image
@@ -538,16 +539,20 @@ $(BUILD_BIN)/runner: $(BUILD_PROPS) $(GOS) $(BUILD_TARGETS)/generate $(BUILD_TAR
538539
# Build the Java artifacts
539540
# ----------------------------------------------------------------------------------------------------------------------
540541
.PHONY: build-mvn
541-
build-mvn: ## Build the Java artefacts
542+
build-mvn: $(BUILD_TARGETS)/java ## Build the Java artefacts
543+
544+
$(BUILD_TARGETS)/java: $(JAVA_FILES)
542545
./mvnw -B -f java clean install -DskipTests $(MAVEN_BUILD_OPTS)
546+
touch $(BUILD_TARGETS)/java
547+
543548

544549
# ---------------------------------------------------------------------------
545550
# Build the Coherence operator Helm chart and package it into a tar.gz
546551
# ---------------------------------------------------------------------------
547552
.PHONY: helm-chart
548553
helm-chart: $(BUILD_PROPS) $(BUILD_HELM)/coherence-operator-$(VERSION).tgz ## Build the Coherence Operator Helm chart
549554

550-
$(BUILD_HELM)/coherence-operator-$(VERSION).tgz: $(BUILD_PROPS) $(HELM_FILES) $(BUILD_TARGETS)/generate $(BUILD_TARGETS)/manifests kustomize
555+
$(BUILD_HELM)/coherence-operator-$(VERSION).tgz: $(BUILD_PROPS) $(HELM_FILES) $(BUILD_TARGETS)/generate $(BUILD_TARGETS)/manifests $(TOOLS_BIN)/kustomize
551556
# Copy the Helm chart from the source location to the distribution folder
552557
-mkdir -p $(BUILD_HELM)
553558
cp -R ./helm-charts/coherence-operator $(BUILD_HELM)
@@ -587,7 +592,7 @@ manifests: $(BUILD_TARGETS)/manifests ## Generate the CustomResourceDefinition a
587592
$(BUILD_TARGETS)/manifests: $(BUILD_PROPS) config/crd/bases/coherence.oracle.com_coherence.yaml docs/about/04_coherence_spec.adoc $(BUILD_MANIFESTS_PKG)
588593
touch $(BUILD_TARGETS)/manifests
589594

590-
config/crd/bases/coherence.oracle.com_coherence.yaml: kustomize $(API_GO_FILES) controller-gen
595+
config/crd/bases/coherence.oracle.com_coherence.yaml: $(TOOLS_BIN)/kustomize $(API_GO_FILES) $(TOOLS_BIN)/controller-gen
591596
$(CONTROLLER_GEN) "crd:crdVersions={v1}" \
592597
rbac:roleName=manager-role paths="{./api/...,./controllers/...}" \
593598
output:crd:dir=config/crd/bases
@@ -621,7 +626,7 @@ generate: $(BUILD_TARGETS)/generate ## Run Kubebuilder code and configuration g
621626
$(BUILD_TARGETS)/generate: $(BUILD_PROPS) $(BUILD_OUTPUT)/config.json api/v1/zz_generated.deepcopy.go
622627
touch $(BUILD_TARGETS)/generate
623628

624-
api/v1/zz_generated.deepcopy.go: $(API_GO_FILES) controller-gen
629+
api/v1/zz_generated.deepcopy.go: $(API_GO_FILES) $(TOOLS_BIN)/controller-gen
625630
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
626631

627632
# ----------------------------------------------------------------------------------------------------------------------
@@ -787,7 +792,7 @@ stop: ## kill any locally running operator process
787792
# Generate bundle manifests and metadata, then validate generated files.
788793
# ----------------------------------------------------------------------------------------------------------------------
789794
.PHONY: bundle
790-
bundle: $(BUILD_PROPS) ensure-sdk kustomize $(BUILD_TARGETS)/manifests ## Generate OLM bundle manifests and metadata, then validate generated files.
795+
bundle: $(BUILD_PROPS) ensure-sdk $(TOOLS_BIN)/kustomize $(BUILD_TARGETS)/manifests ## Generate OLM bundle manifests and metadata, then validate generated files.
791796
$(OPERATOR_SDK) generate kustomize manifests -q
792797
cd config/manager && $(KUSTOMIZE) edit set image controller=$(OPERATOR_IMAGE)
793798
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
@@ -869,7 +874,7 @@ test-operator: $(BUILD_PROPS) $(BUILD_TARGETS)/manifests $(BUILD_TARGETS)/genera
869874
# Build and test the Java artifacts
870875
# ----------------------------------------------------------------------------------------------------------------------
871876
.PHONY: test-mvn
872-
test-mvn: $(BUILD_OUTPUT)/certs build-mvn ## Run the Java artefact tests
877+
test-mvn: $(BUILD_OUTPUT)/certs $(BUILD_TARGETS)/java ## Run the Java artefact tests
873878
./mvnw -B -f java verify -Dtest.certs.location=$(BUILD_OUTPUT)/certs $(MAVEN_BUILD_OPTS)
874879

875880

@@ -1305,7 +1310,7 @@ deploy-and-wait: deploy wait-for-deploy ## Deploy the Coherence Operator and w
13051310
OPERATOR_HA ?= true
13061311

13071312
.PHONY: deploy
1308-
deploy: prepare-deploy create-namespace kustomize ## Deploy the Coherence Operator
1313+
deploy: prepare-deploy create-namespace $(TOOLS_BIN)/kustomize ## Deploy the Coherence Operator
13091314
ifneq (,$(WATCH_NAMESPACE))
13101315
cd $(BUILD_DEPLOY)/manager && $(KUSTOMIZE) edit add configmap env-vars --from-literal WATCH_NAMESPACE=$(WATCH_NAMESPACE)
13111316
endif
@@ -1322,11 +1327,11 @@ just-deploy: ## Deploy the Coherence Operator without rebuilding anything
13221327
$(KUSTOMIZE) build $(BUILD_DEPLOY)/default | kubectl apply -f -
13231328

13241329
.PHONY: prepare-deploy
1325-
prepare-deploy: $(BUILD_TARGETS)/manifests $(BUILD_TARGETS)/build-operator kustomize
1330+
prepare-deploy: $(BUILD_TARGETS)/manifests $(BUILD_TARGETS)/build-operator $(TOOLS_BIN)/kustomize
13261331
$(call prepare_deploy,$(OPERATOR_IMAGE),$(OPERATOR_NAMESPACE))
13271332

13281333
.PHONY: deploy-debug
1329-
deploy-debug: prepare-deploy-debug create-namespace kustomize ## Deploy the Coherence Operator running with Delve
1334+
deploy-debug: prepare-deploy-debug create-namespace $(TOOLS_BIN)/kustomize ## Deploy the Coherence Operator running with Delve
13301335
ifneq (,$(WATCH_NAMESPACE))
13311336
cd $(BUILD_DEPLOY)/manager && $(KUSTOMIZE) edit add configmap env-vars --from-literal WATCH_NAMESPACE=$(WATCH_NAMESPACE)
13321337
endif
@@ -1356,7 +1361,7 @@ port-forward-debug: ## Run a port-forward process to forward localhost:2345 to
13561361
kubectl -n $(OPERATOR_NAMESPACE) port-forward $(POD) 2345:2345 || true
13571362

13581363
.PHONY: prepare-deploy-debug
1359-
prepare-deploy-debug: $(BUILD_TARGETS)/manifests build-operator-debug kustomize
1364+
prepare-deploy-debug: $(BUILD_TARGETS)/manifests build-operator-debug $(TOOLS_BIN)/kustomize
13601365
$(call prepare_deploy,$(OPERATOR_IMAGE_DEBUG),$(OPERATOR_NAMESPACE))
13611366

13621367
.PHONY: wait-for-deploy
@@ -1387,7 +1392,7 @@ endef
13871392
# Un-deploy controller from the configured Kubernetes cluster in ~/.kube/config
13881393
# ----------------------------------------------------------------------------------------------------------------------
13891394
.PHONY: undeploy
1390-
undeploy: $(BUILD_PROPS) $(BUILD_TARGETS)/manifests kustomize ## Undeploy the Coherence Operator
1395+
undeploy: $(BUILD_PROPS) $(BUILD_TARGETS)/manifests $(TOOLS_BIN)/kustomize ## Undeploy the Coherence Operator
13911396
@echo "Undeploy Coherence Operator..."
13921397
$(call prepare_deploy,$(OPERATOR_IMAGE),$(OPERATOR_NAMESPACE))
13931398
$(KUSTOMIZE) build $(BUILD_DEPLOY)/default | kubectl delete -f - || true
@@ -1406,7 +1411,7 @@ tail-logs: ## Tail the Coherence Operator Pod logs (with follow)
14061411
kubectl -n $(OPERATOR_NAMESPACE) logs $(POD) -c manager -f
14071412

14081413

1409-
$(BUILD_MANIFESTS_PKG): kustomize
1414+
$(BUILD_MANIFESTS_PKG): $(TOOLS_BIN)/kustomize
14101415
rm -rf $(BUILD_MANIFESTS) || true
14111416
mkdir -p $(BUILD_MANIFESTS)/crd
14121417
$(KUSTOMIZE) build config/crd > $(BUILD_MANIFESTS)/crd/coherence.oracle.com_coherence.yaml
@@ -1728,7 +1733,7 @@ tanzu-delete-cluster: ## Delete the local Tanzu unmanaged cluster named "$(KIND_
17281733
$(TANZU) uc delete $(KIND_CLUSTER)
17291734

17301735
.PHONY: tanzu-package-internal
1731-
tanzu-package-internal: $(BUILD_PROPS) $(BUILD_TARGETS)/generate $(BUILD_TARGETS)/manifests kustomize
1736+
tanzu-package-internal: $(BUILD_PROPS) $(BUILD_TARGETS)/generate $(BUILD_TARGETS)/manifests $(TOOLS_BIN)/kustomize
17321737
rm -r $(TANZU_PACKAGE_DIR) || true
17331738
mkdir -p $(TANZU_PACKAGE_DIR)/config $(TANZU_PACKAGE_DIR)/.imgpkg || true
17341739
cp -vR tanzu/package/* $(TANZU_PACKAGE_DIR)/config/
@@ -1826,7 +1831,9 @@ endif
18261831
# ----------------------------------------------------------------------------------------------------------------------
18271832
.PHONY: controller-gen
18281833
CONTROLLER_GEN = $(TOOLS_BIN)/controller-gen
1829-
controller-gen: ## Download controller-gen locally if necessary.
1834+
controller-gen: $(TOOLS_BIN)/controller-gen ## Download controller-gen locally if necessary.
1835+
1836+
$(TOOLS_BIN)/controller-gen:
18301837
@echo "Downloading controller-gen"
18311838
test -s $(TOOLS_BIN)/controller-gen || GOBIN=$(TOOLS_BIN) go install sigs.k8s.io/controller-tools/cmd/[email protected]
18321839
ls -al $(TOOLS_BIN)
@@ -1839,14 +1846,19 @@ KUSTOMIZE_VERSION ?= v3.8.7
18391846

18401847
.PHONY: kustomize
18411848
KUSTOMIZE = $(TOOLS_BIN)/kustomize
1842-
kustomize: ## Download kustomize locally if necessary.
1849+
kustomize: $(TOOLS_BIN)/kustomize ## Download kustomize locally if necessary.
1850+
1851+
$(TOOLS_BIN)/kustomize:
18431852
test -s $(TOOLS_BIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) --header $(GH_AUTH) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(TOOLS_BIN); }
18441853

18451854
# ----------------------------------------------------------------------------------------------------------------------
18461855
# find or download the Coherence CLI
18471856
# ----------------------------------------------------------------------------------------------------------------------
18481857
.PHONY: coherence-cli
1849-
coherence-cli: $(BUILD_BIN_AMD64)/cohctl $(BUILD_BIN_ARM64)/cohctl ## Download the Coherence CLI locally if necessary.
1858+
coherence-cli: $(BUILD_TARGETS)/cli ## Download the Coherence CLI locally if necessary.
1859+
1860+
$(BUILD_TARGETS)/cli: $(BUILD_BIN_AMD64)/cohctl $(BUILD_BIN_ARM64)/cohctl
1861+
touch $(BUILD_TARGETS)/cli
18501862

18511863
$(BUILD_BIN_AMD64)/cohctl: export COHCTL_HOME=$(BUILD_BIN_AMD64)
18521864
$(BUILD_BIN_AMD64)/cohctl: export OS=Linux
@@ -1948,7 +1960,7 @@ push-ttl-test-images:
19481960
# Build the Operator Test images
19491961
# ----------------------------------------------------------------------------------------------------------------------
19501962
.PHONY: build-compatibility-image
1951-
build-compatibility-image: build-mvn
1963+
build-compatibility-image: $(BUILD_TARGETS)/java
19521964
./mvnw -B -f java/operator-compatibility package -DskipTests \
19531965
-Dcoherence.compatibility.image.name=$(TEST_COMPATIBILITY_IMAGE) \
19541966
-Dcoherence.compatibility.coherence.image=$(COHERENCE_IMAGE) $(MAVEN_BUILD_OPTS)
@@ -2105,7 +2117,7 @@ install-istio: get-istio ## Install the latest version of Istio into k8s (or ove
21052117
.PHONY: uninstall-istio
21062118
uninstall-istio: get-istio ## Uninstall Istio from k8s
21072119
$(eval ISTIO_HOME := $(shell find $(TOOLS_DIRECTORY) -maxdepth 1 -type d | grep istio))
2108-
$(ISTIO_HOME)/bin/istioctl x uninstall --purge -y
2120+
$(ISTIO_HOME)/bin/istioctl uninstall --purge -y
21092121

21102122

21112123
# ----------------------------------------------------------------------------------------------------------------------

api/v1/coherence_webhook.go

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2121
logf "sigs.k8s.io/controller-runtime/pkg/log"
2222
"sigs.k8s.io/controller-runtime/pkg/webhook"
23+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2324
)
2425

2526
// log is for logging in this package.
@@ -78,7 +79,7 @@ func SetCommonDefaults(in CoherenceResource) {
7879

7980
// set the default Coherence local port and local port adjust if not present
8081
if spec.Coherence == nil {
81-
lpa := intstr.FromInt(int(DefaultUnicastPortAdjust))
82+
var lpa = intstr.FromInt32(DefaultUnicastPortAdjust)
8283
spec.Coherence = &CoherenceSpec{
8384
LocalPort: pointer.Int32(DefaultUnicastPort),
8485
LocalPortAdjust: &lpa,
@@ -88,7 +89,7 @@ func SetCommonDefaults(in CoherenceResource) {
8889
spec.Coherence.LocalPort = pointer.Int32(DefaultUnicastPort)
8990
}
9091
if spec.Coherence.LocalPortAdjust == nil {
91-
lpa := intstr.FromInt(int(DefaultUnicastPortAdjust))
92+
lpa := intstr.FromInt32(DefaultUnicastPortAdjust)
9293
spec.Coherence.LocalPortAdjust = &lpa
9394
}
9495
}
@@ -128,33 +129,41 @@ var _ webhook.Validator = &Coherence{}
128129
var commonWebHook = CommonWebHook{}
129130

130131
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
131-
func (in *Coherence) ValidateCreate() error {
132+
// The optional warnings will be added to the response as warning messages.
133+
// Return an error if the object is invalid.
134+
func (in *Coherence) ValidateCreate() (admission.Warnings, error) {
132135
var err error
136+
var warnings admission.Warnings
137+
133138
webhookLogger.Info("validate create", "name", in.Name)
134139
err = commonWebHook.validateReplicas(in)
135140
if err != nil {
136-
return err
141+
return warnings, err
137142
}
138143
err = commonWebHook.validateNodePorts(in)
139-
return err
144+
return warnings, err
140145
}
141146

142147
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
143-
func (in *Coherence) ValidateUpdate(previous runtime.Object) error {
148+
// The optional warnings will be added to the response as warning messages.
149+
// Return an error if the object is invalid.
150+
func (in *Coherence) ValidateUpdate(previous runtime.Object) (admission.Warnings, error) {
144151
webhookLogger.Info("validate update", "name", in.Name)
152+
var warnings admission.Warnings
153+
145154
if err := commonWebHook.validateReplicas(in); err != nil {
146-
return err
155+
return warnings, err
147156
}
148157
prev := previous.(*Coherence)
149158

150159
if err := commonWebHook.validatePersistence(in, prev); err != nil {
151-
return err
160+
return warnings, err
152161
}
153162
if err := in.validateVolumeClaimTemplates(prev); err != nil {
154-
return err
163+
return warnings, err
155164
}
156165
if err := commonWebHook.validateNodePorts(in); err != nil {
157-
return err
166+
return warnings, err
158167
}
159168

160169
var errorList field.ErrorList
@@ -163,16 +172,18 @@ func (in *Coherence) ValidateUpdate(previous runtime.Object) error {
163172
errorList = ValidateStatefulSetUpdate(&sts, &stsOld)
164173

165174
if len(errorList) > 0 {
166-
return fmt.Errorf("rejecting update as it would have resulted in an invalid StatefulSet: %v", errorList)
175+
return warnings, fmt.Errorf("rejecting update as it would have resulted in an invalid StatefulSet: %v", errorList)
167176
}
168177

169-
return nil
178+
return warnings, nil
170179
}
171180

172181
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
173-
func (in *Coherence) ValidateDelete() error {
182+
// The optional warnings will be added to the response as warning messages.
183+
// Return an error if the object is invalid.
184+
func (in *Coherence) ValidateDelete() (admission.Warnings, error) {
174185
// we do not need to validate deletions
175-
return nil
186+
return nil, nil
176187
}
177188

178189
func (in *Coherence) validateVolumeClaimTemplates(previous *Coherence) error {

0 commit comments

Comments
 (0)