diff --git a/.gitignore b/.gitignore index 9044c01f..25242f3a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ bin testbin/* nnf-dm .version +config/begin/* # Test binary, build with `go test -c` *.test diff --git a/Makefile b/Makefile index 5f105d1b..26e77d6a 100644 --- a/Makefile +++ b/Makefile @@ -168,10 +168,11 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified deploy: VERSION ?= $(shell cat .version) deploy: .version kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - ./deploy.sh deploy $(KUSTOMIZE) $(IMAGE_TAG_BASE):$(VERSION) $(NNFMFU_TAG_BASE):$(NNFMFU_VERSION) + $(KUSTOMIZE_IMAGE_TAG) config/begin default $(IMAGE_TAG_BASE) $(VERSION) $(NNFMFU_TAG_BASE) $(NNFMFU_VERSION) + ./deploy.sh deploy $(KUSTOMIZE) config/begin undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. - ./deploy.sh undeploy $(KUSTOMIZE) + ./deploy.sh undeploy $(KUSTOMIZE) config/default # Let .version be phony so that a git update to the workarea can be reflected # in it each time it's needed. @@ -191,6 +192,7 @@ clean-bin: fi ## Tool Binaries +KUSTOMIZE_IMAGE_TAG ?= ./hack/make-kustomization2.sh KUSTOMIZE ?= $(LOCALBIN)/kustomize CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest diff --git a/deploy.sh b/deploy.sh index 481b52c1..d23097c9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -22,7 +22,7 @@ usage() { cat < Commands: deploy Deploy data movement @@ -32,16 +32,11 @@ EOF CMD=$1 KUSTOMIZE=$2 -IMG=$3 -NNFMFU_IMG=$4 +OVERLAY_DIR=$3 case $CMD in deploy) - (cd config/manager && - $KUSTOMIZE edit set image controller="$IMG" && - $KUSTOMIZE edit set image nnf-mfu="$NNFMFU_IMG") - - $KUSTOMIZE build config/default | kubectl apply -f - || true + $KUSTOMIZE build $OVERLAY_DIR | kubectl apply -f - || true # Sometimes the deployment of the DataMovementManager occurs too quickly for k8s to digest the CRD # Retry the deployment if this is the case. It seems to be fast enough where we can just @@ -49,7 +44,7 @@ deploy) echo "Waiting for DataMovementManager resource to become ready" while :; do [[ $(kubectl get datamovementmanager -n nnf-dm-system 2>&1) == "No resources found" ]] && sleep 1 && continue - $KUSTOMIZE build config/default | kubectl apply -f - + $KUSTOMIZE build $OVERLAY_DIR | kubectl apply -f - break done ;; @@ -57,7 +52,7 @@ undeploy) # When the DataMovementManager CRD gets deleted all related resource are also # removed, so the delete will always fail. We ignore all errors at our # own risk. - $KUSTOMIZE build config/default | kubectl delete --ignore-not-found -f - + $KUSTOMIZE build $OVERLAY_DIR | kubectl delete --ignore-not-found -f - ;; *) usage diff --git a/hack/make-kustomization2.sh b/hack/make-kustomization2.sh new file mode 100755 index 00000000..c01cea9d --- /dev/null +++ b/hack/make-kustomization2.sh @@ -0,0 +1,46 @@ +#!/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_1=$3 +TAG_1=$4 +IMAGE_TAG_BASE_2=$5 +TAG_2=$6 + +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_1 + newTag: $TAG_1 +- name: $IMAGE_TAG_BASE_2 + newTag: $TAG_2 +EOF +