22.PHONY : release
33
44# If CONFIG is `kind`, various defaults will be optimized for deploying locally to Kind
5- CONFIG ?= "default"
5+ CONFIG ?= default
6+
7+ # Set the Kind name (by default, it's "kind"). If you set this explicitly,
8+ # CONFIG is automatically set to "kind" as well, overriding any existing
9+ # setting.
10+ ifeq ($(CONFIG ) ,kind)
11+ KIND ?= "kind"
12+ else
13+ KIND ?= ""
14+ endif
15+ ifneq ($(KIND ) ,"")
16+ CONFIG = kind
17+ endif
618
719# The GCP project ID useful to have when performing operations that require one
820# (e.g. release). If you don't have gcloud, all other operations in this
@@ -157,14 +169,21 @@ manifests: controller-gen
157169 cd manifests && \
158170 touch kustomization.yaml && \
159171 ${KUSTOMIZE} edit add resource ../config/crd
160- ${KUSTOMIZE} build manifests/ -o manifests/hnc-crds.yaml
161- @echo " Building full manifest"
162- rm manifests/kustomization.yaml
163- cd manifests && \
164- touch kustomization.yaml && \
165- ${KUSTOMIZE} edit add resource ../config/default && \
166- ${KUSTOMIZE} edit set image controller=${HNC_IMG}
167- ${KUSTOMIZE} build manifests/ -o manifests/${HNC_IMG_NAME} .yaml
172+ ${KUSTOMIZE} build manifests/ -o manifests/crds.yaml
173+ @cd manifests && \
174+ for variant in default-cc default-cm nowebhooks-cc ha-webhooks-cc ; do \
175+ echo " Building $$ {variant} manifest" ; \
176+ rm kustomization.yaml; \
177+ touch kustomization.yaml && \
178+ ${KUSTOMIZE} edit add resource ../config/variants/$$ {variant} && \
179+ ${KUSTOMIZE} edit set image controller=${HNC_IMG} ; \
180+ ${KUSTOMIZE} build . -o ./$$ {variant}.yaml; \
181+ done
182+ @echo " Creating alias and summary manifests"
183+ @cp manifests/default-cc.yaml manifests/default.yaml
184+ @cat manifests/nowebhooks-cc.yaml > manifests/ha.yaml
185+ @echo " ---" >> manifests/ha.yaml
186+ @cat manifests/ha-webhooks-cc.yaml >> manifests/ha.yaml
168187
169188# Run go fmt against code
170189fmt :
@@ -200,14 +219,25 @@ controller-gen:
200219#
201220# We only delete the deployment if it exists before applying the manifest, because
202221# a) deleting the CRDs will cause all the existing CRs to be wiped away;
203- # b) if not deleting the deployment, a new image won't be pulled unless the tag changes.
222+ # b) if we don't delete the deployment, a new image won't be pulled unless the
223+ # tag changes, which it frequently won't since we use the "latest" tag during
224+ # development.
204225deploy : docker-push kubectl manifests
205- -kubectl -n hnc-system delete deployment hnc-controller-manager
206- kubectl apply -f manifests/${HNC_IMG_NAME} .yaml
226+ -kubectl -n hnc-system delete deployment --all
227+ kubectl apply -f manifests/default .yaml
207228
208229deploy-watch :
209230 kubectl logs -n hnc-system --follow deployment/hnc-controller-manager manager
210231
232+ deploy-ha : docker-push kubectl manifests
233+ -kubectl -n hnc-system delete deployment --all
234+ kubectl apply -f manifests/ha.yaml
235+
236+ ha-deploy-watch-ha :
237+ kubectl logs -n hnc-system --follow deployment/hnc-controller-manager-ha manager
238+
239+ # No need to delete the HA configuration here - everything "extra" that it
240+ # installs is in hnc-system, which gets deleted by the default manifest.
211241undeploy : manifests
212242 @echo " ********************************************************************************"
213243 @echo " ********************************************************************************"
@@ -220,15 +250,16 @@ undeploy: manifests
220250 @echo " ********************************************************************************"
221251 @sleep 5
222252 @echo " Deleting all CRDs to ensure all finalizers are removed"
223- -kubectl delete -f manifests/hnc- crds.yaml
253+ -kubectl delete -f manifests/crds.yaml
224254 @echo " Deleting the rest of HNC"
225- -kubectl delete -f manifests/hnc-manager.yaml
255+ -kubectl delete -f manifests/default.yaml
256+ @echo Please ignore any \' not found\' errors, these are expected.
226257
227258# Push the docker image
228259docker-push : docker-build
229260 @echo " Pushing ${HNC_IMG} "
230261ifeq ($(CONFIG ) ,kind)
231- kind load docker-image ${HNC_IMG}
262+ kind load docker-image ${HNC_IMG} --name ${KIND}
232263else
233264 docker push ${HNC_IMG}
234265endif
@@ -260,7 +291,7 @@ docker-push-multi: buildx-setup generate fmt vet
260291kind-reboot :
261292 @echo " Warning: the 'kind' command must be in your path for this to work"
262293 -kind delete cluster
263- kind create cluster
294+ kind create cluster --name ${KIND}
264295
265296# Creates a local kind cluster, destroying the old one if necessary. It's not
266297# *necessary* to call this wih CONFIG=kind but it's not a bad idea either so
@@ -375,7 +406,7 @@ endif
375406 @echo "Starting build."
376407 @echo "*********************************************"
377408 @echo "*********************************************"
378- gcloud builds submit --config cloudbuild.yaml --no-source --substitutions=${HNC_GCB_SUBS} --timeout=30m
409+ gcloud builds submit --config cloudbuild.yaml --no-source --substitutions=${HNC_GCB_SUBS} --timeout=60m
379410 @echo "*********************************************"
380411 @echo "*********************************************"
381412 @echo "Pushing ${HNC_IMG} to ${HNC_RELEASE_IMG}"
0 commit comments