@@ -180,12 +180,23 @@ controller-gen:
180
180
181
181
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config.
182
182
#
183
- # We only delete and redeploy the deployment, and nothing else, because a)
184
- # deleting the CRDs will cause all the existing hierarchy configs to be wiped
185
- # away and b) if we don't delete the deployment, a new image won't be pulled
186
- # unless the tag changes.
183
+ # We only delete the deployment and the validatingwebhookconfiguration if they
184
+ # exist before applying the manifest, because
185
+ # a) deleting the CRDs will cause all the existing CRs to be wiped away;
186
+ # b) if not deleting the deployment, a new image won't be pulled unless the tag changes;
187
+ # c) if not deleting the validatingwebhookconfiguration, we cannot label
188
+ # namespaces to exclude them if the HNC pod is already in a bad state.
189
+ #
190
+ # Then we ensure the system namespaces are excluded before we deploy HNC. This
191
+ # step is critical because if the HNC pod is ever in a bad state, the object
192
+ # webhook service would not respond and would stop everything in the system
193
+ # namespaces, such as "kube-system", thus breaking the whole cluster.
187
194
deploy : docker-push kubectl manifests
188
195
-kubectl -n hnc-system delete deployment hnc-controller-manager
196
+ -kubectl delete validatingwebhookconfiguration hnc-validating-webhook-configuration
197
+ -kubectl label ns kube-node-lease hnc.x-k8s.io/excluded-namespace=true --overwrite
198
+ -kubectl label ns kube-public hnc.x-k8s.io/excluded-namespace=true --overwrite
199
+ -kubectl label ns kube-system hnc.x-k8s.io/excluded-namespace=true --overwrite
189
200
kubectl apply -f manifests/${HNC_IMG_NAME} .yaml
190
201
191
202
deploy-watch :
@@ -262,6 +273,11 @@ test-e2e-batch: exclude-system-namespaces
262
273
go test -v -timeout 0 ./test/e2e/... ; \
263
274
done
264
275
276
+ # exclude-system-namespaces is called before we run any e2e tests. We do ensure
277
+ # the system namespaces are excluded in the "deploy" target. However, we need to
278
+ # do it here too in case users install HNC by applying manifests. Ensuring the
279
+ # system namespaces excluded is critical, because otherwise when HNC pod is in a
280
+ # bad state, the whole cluster will break.
265
281
exclude-system-namespaces :
266
282
@echo
267
283
@echo " Ensuring all system namespaces are excluded from HNC..."
0 commit comments