Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit a2962af

Browse files
committed
Introduce manifest variants
This change updates the config and Makefile to produce multiple variants of the HNC manifests. The initial list is "default" (same as today), "default-cm" (same, but configured for cert-manager instead of the internal cert-controller), and ha (replicated webhooks, using the internal cert controller). Also made some updates to the Prow tests to allow for variant testing, as well as upgrading the ability to test the Prow tests locally. Tested: verified that default.yaml is the same as the prior hnc-manager.yaml, apart from some reordered command line args. Verified that smoke tests work on ha.yaml. Did not do _any_ testing on the cert-manager variants. Locally ran the prow e2e tests on both the HA and default configs. Also did an experimental release from my personal repo and bumped up the timeout since we've added more build targets.
1 parent 55c0c2a commit a2962af

18 files changed

+344
-215
lines changed

Makefile

+48-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
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
170189
fmt:
@@ -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.
204225
deploy: 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

208229
deploy-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.
211241
undeploy: 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
228259
docker-push: docker-build
229260
@echo "Pushing ${HNC_IMG}"
230261
ifeq ($(CONFIG),kind)
231-
kind load docker-image ${HNC_IMG}
262+
kind load docker-image ${HNC_IMG} --name ${KIND}
232263
else
233264
docker push ${HNC_IMG}
234265
endif
@@ -260,7 +291,7 @@ docker-push-multi: buildx-setup generate fmt vet
260291
kind-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}"

cloudbuild.yaml

+15-3
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,30 @@ steps:
2727
echo "Building HNC manifests and plugin for $$HNC_REGISTRY/$$HNC_IMG_NAME:$$HNC_IMG_TAG"
2828
make build
2929
make krew-build
30-
# Upload manifest
30+
# Upload default manifest
3131
- name: gcr.io/cloud-builders/curl
3232
args:
3333
- '-X'
3434
- 'POST'
3535
- '-H'
3636
- 'Content-Type: application/x-application'
3737
- '--data-binary'
38-
- '@hierarchical-namespaces/manifests/hnc-manager.yaml'
38+
- '@hierarchical-namespaces/manifests/default.yaml'
3939
- '-u'
4040
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
41-
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=hnc-manager.yaml'
41+
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=default.yaml'
42+
# Upload HA manifest
43+
- name: gcr.io/cloud-builders/curl
44+
args:
45+
- '-X'
46+
- 'POST'
47+
- '-H'
48+
- 'Content-Type: application/x-application'
49+
- '--data-binary'
50+
- '@hierarchical-namespaces/manifests/ha.yaml'
51+
- '-u'
52+
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
53+
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=ha-experimental.yaml'
4254
# Upload plugin (Linux)
4355
- name: gcr.io/cloud-builders/curl
4456
args:

config/default/kustomization.yaml

-76
This file was deleted.

config/default/manager_auth_proxy_patch.yaml

-32
This file was deleted.

config/default/manager_prometheus_metrics_patch.yaml

-19
This file was deleted.

config/default/manager_webhook_patch.yaml

-23
This file was deleted.

config/manager/manager.yaml

+21-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ spec:
2121
metadata:
2222
labels:
2323
control-plane: controller-manager
24+
annotations:
25+
prometheus.io/scrape: 'true'
2426
spec:
2527
securityContext:
2628
# Generally to run as non-root, the GID and UID can be any number
@@ -32,7 +34,9 @@ spec:
3234
runAsNonRoot: true
3335
runAsUser: 1000
3436
containers:
35-
- command:
37+
- name: manager
38+
image: controller:latest # this is usually overridden by kustomize
39+
command:
3640
- /manager
3741
args:
3842
- "--webhook-server-port=9443"
@@ -42,14 +46,21 @@ spec:
4246
- "--metrics-addr=:8080"
4347
- "--max-reconciles=10"
4448
- "--apiserver-qps-throttle=50"
45-
- "--enable-internal-cert-management"
46-
- "--cert-restart-on-secret-refresh"
4749
- "--excluded-namespace=kube-system"
4850
- "--excluded-namespace=kube-public"
4951
- "--excluded-namespace=hnc-system"
5052
- "--excluded-namespace=kube-node-lease"
51-
image: controller:latest
52-
name: manager
53+
ports:
54+
- containerPort: 9443
55+
name: webhook-server
56+
protocol: TCP
57+
- containerPort: 8080
58+
name: metrics
59+
protocol: TCP
60+
volumeMounts:
61+
- mountPath: /tmp/k8s-webhook-server/serving-certs
62+
name: cert
63+
readOnly: true
5364
livenessProbe:
5465
httpGet:
5566
path: /healthz
@@ -69,4 +80,9 @@ spec:
6980
requests:
7081
cpu: 100m
7182
memory: 150Mi
83+
volumes:
84+
- name: cert
85+
secret:
86+
defaultMode: 420
87+
secretName: webhook-server-cert
7288
terminationGracePeriodSeconds: 10

config/variants/default-cc/README

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This directory is the default configuration of HNC, including internal cert
2+
management ("cc" = "Cert Controller"). It's published as "default_cc.yaml" when
3+
building the manifests ("made manifests" in the root directory) and aliased as
4+
"default.yaml." In versions of HNC prior to v1.0, this was hnc_manager.yaml.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Adds namespace to all resources.
2+
namespace: hnc-system
3+
4+
# Value of this field is prepended to the
5+
# names of all resources, e.g. a deployment named
6+
# "wordpress" becomes "alices-wordpress".
7+
# Note that it should also match with the prefix (text before '-') of the namespace
8+
# field above.
9+
namePrefix: hnc-
10+
11+
bases:
12+
- ../../crd
13+
- ../../internalcert
14+
- ../../manager
15+
- ../../rbac
16+
- ../../webhook
17+
18+
patches:
19+
- patch: |-
20+
- op: add
21+
path: /spec/template/spec/containers/0/args/-
22+
value: --enable-internal-cert-management
23+
- op: add
24+
path: /spec/template/spec/containers/0/args/-
25+
value: --cert-restart-on-secret-refresh
26+
target:
27+
group: apps
28+
version: v1
29+
kind: Deployment
30+
name: controller-manager

0 commit comments

Comments
 (0)