From 36ad95842aa732815cadc678dda361c5009c76ef Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Thu, 19 Oct 2023 16:19:16 -0500 Subject: [PATCH 1/3] Update to kustomize v5.1.1 (#55) This is the version that is installed by the current kubebuilder, v3.12.0. There will be a deprecation warning about patchesStrategicMerge, but this can be ignored. This warning is tracked in kubebuilder issue #3539. Signed-off-by: Dean Roehrich --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b1dbcfa..3bc44ba 100644 --- a/Makefile +++ b/Makefile @@ -103,12 +103,12 @@ $(LOCALBIN): KUSTOMIZE ?= $(LOCALBIN)/kustomize ## Tool Versions -KUSTOMIZE_VERSION ?= v4.5.7 +KUSTOMIZE_VERSION ?= v5.1.1 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize kustomize: $(LOCALBIN) ## Download kustomize locally if necessary. - if [[ ! -s $(LOCALBIN)/kustomize || $$($(LOCALBIN)/kustomize version | awk '{print $$1}' | awk -F/ '{print $$2}') != $(KUSTOMIZE_VERSION) ]]; then \ + if [[ ! -s $(LOCALBIN)/kustomize || ! $$($(LOCALBIN)/kustomize version) =~ $(KUSTOMIZE_VERSION) ]]; then \ rm -f $(LOCALBIN)/kustomize && \ { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }; \ fi From 4d9b845219044a13d107979ee160b0f281b6e0aa Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Fri, 20 Oct 2023 09:57:41 -0500 Subject: [PATCH 2/3] Dynamically create an overlay for the image tag (#56) Avoid editing config/manager/kustomization.yaml to set the image tag. This causes git to consider the workarea to be dirty, so two consecutive deploys from a workarea that has no other changes will result in the second deploy looking for an image with a "-dirty" tag. Instead, from the makefile we create a throw-away, and untracked, overlay that will be used to set the image tag. Signed-off-by: Dean Roehrich --- .gitignore | 6 +++++- Makefile | 5 +++-- hack/boilerplate.go.txt | 18 ++++++++++++++++ hack/make-kustomization.sh | 42 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 hack/boilerplate.go.txt create mode 100755 hack/make-kustomization.sh diff --git a/.gitignore b/.gitignore index 3c80a04..c423c83 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,8 @@ testbin/* .version # Go-generated vendor/ directory -vendor/ \ No newline at end of file +vendor/ + +# Generated overlay for setting image tag +deploy/kubernetes/begin/* + diff --git a/Makefile b/Makefile index 3bc44ba..4bd01f0 100644 --- a/Makefile +++ b/Makefile @@ -51,14 +51,14 @@ docker-build: .version Dockerfile fmt vet edit-image: VERSION ?= $(shell cat .version) edit-image: .version ## Replace plugin.yaml image with name "controller" -> ghcr tagged container reference - cd deploy/kubernetes/base && $(KUSTOMIZE) edit set image controller=$(IMAGE_TAG_BASE):$(VERSION) + $(KUSTOMIZE_IMAGE_TAG) deploy/kubernetes/begin $(OVERLAY) $(IMAGE_TAG_BASE) $(VERSION) kind-push: VERSION ?= $(shell cat .version) kind-push: .version ## Push image to Kind environment kind load docker-image $(IMAGE_TAG_BASE):$(VERSION) deploy_overlay: kustomize edit-image ## Deploy controller to the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build deploy/kubernetes/$(OVERLAY) | kubectl apply -f - + $(KUSTOMIZE) build deploy/kubernetes/begin | kubectl apply -f - deploy: OVERLAY ?= base deploy: deploy_overlay @@ -100,6 +100,7 @@ $(LOCALBIN): mkdir -p $(LOCALBIN) ## Tool Binaries +KUSTOMIZE_IMAGE_TAG ?= ./hack/make-kustomization.sh KUSTOMIZE ?= $(LOCALBIN)/kustomize ## Tool Versions diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt new file mode 100644 index 0000000..4798354 --- /dev/null +++ b/hack/boilerplate.go.txt @@ -0,0 +1,18 @@ +/* + * Copyright 2023 Hewlett Packard Enterprise Development LP + * Other additional copyright holders may be indicated within. + * + * The entirety of this work is licensed under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/hack/make-kustomization.sh b/hack/make-kustomization.sh new file mode 100755 index 0000000..78034df --- /dev/null +++ b/hack/make-kustomization.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright 2023 Hewlett Packard Enterprise Development LP +# Other additional copyright holders may be indicated within. +# +# The entirety of this work is licensed under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +OVERLAY_DIR=$1 +OVERLAY=$2 +IMAGE_TAG_BASE=$3 +TAG=$4 + +if [[ ! -d $OVERLAY_DIR ]] +then + mkdir "$OVERLAY_DIR" +fi + +cat < "$OVERLAY_DIR"/kustomization.yaml +resources: +- ../$OVERLAY + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: $IMAGE_TAG_BASE + newTag: $TAG +EOF + From e58b06cb55bc91e756ccbb4d9e60abbb8a40a8b6 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Tue, 9 Jan 2024 16:13:30 -0600 Subject: [PATCH 3/3] Provide a default overlay (#57) Signed-off-by: Dean Roehrich --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4bd01f0..bdcde16 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Copyright 2021-2023 Hewlett Packard Enterprise Development LP +# Copyright 2021-2024 Hewlett Packard Enterprise Development LP # Other additional copyright holders may be indicated within. # # The entirety of this work is licensed under the Apache License, @@ -28,6 +28,7 @@ IMAGE_TAG_BASE ?= ghcr.io/hewlettpackard/lustre-csi-driver # Or, make kind-deploy # To deploy the base lustre config: # make deploy +OVERLAY ?= overlays/kind all: build