From 37489d8a5c5eb7f30447437c6ce4c183014d498b Mon Sep 17 00:00:00 2001 From: "Ciro S. Costa" Date: Thu, 25 Aug 2022 12:33:11 -0400 Subject: [PATCH] config: prefix generic objects (validatingwebhook and issuer) (#995) * config: prefix issuer w/ cartographer- despite the object being namespace-scoped, it's such a generic name that it makes sense to have it prefixed with `cartographer-` so that we're able to carry the component nomenclature. * hack: override default validatingwebhook name by default, controller-tools' controller-gen generates the object with a hardcoded name of `validating-webhook-configuration` for those using kustomize (like kubebuilder does), that's not a problem as the configuration usually specifies what the prefix for objects should look like, e.g. # in kustomization.yaml namePrefix: cartographer-conventions- but, given that this repository _doens't_ make use of kustomize (as it wasn't initialized w/ kubebuilder), here we resort to using ytt overlays for it (we already had one for webhook configs anyway, so, just update it). see https://github.com/kubernetes-sigs/controller-tools/blob/ebdf5177ad92f89da82686f4100c06d428ab3ce5/pkg/webhook/parser.go#L384-L405 for details on that hardcoded name. Signed-off-by: Ciro S. Costa --- config/webhook/support.yaml | 4 ++-- hack/overlays/webhook-configuration.yaml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/webhook/support.yaml b/config/webhook/support.yaml index 9448dbbed..4d8834b7f 100644 --- a/config/webhook/support.yaml +++ b/config/webhook/support.yaml @@ -25,14 +25,14 @@ spec: - cartographer-webhook.cartographer-system.svc.cluster.local issuerRef: kind: Issuer - name: selfsigned-issuer + name: cartographer-selfsigned-issuer secretName: cartographer-webhook --- apiVersion: cert-manager.io/v1 kind: Issuer metadata: - name: selfsigned-issuer + name: cartographer-selfsigned-issuer namespace: cartographer-system spec: selfSigned: {} diff --git a/hack/overlays/webhook-configuration.yaml b/hack/overlays/webhook-configuration.yaml index 4cf0b9340..7a8ddb354 100644 --- a/hack/overlays/webhook-configuration.yaml +++ b/hack/overlays/webhook-configuration.yaml @@ -21,6 +21,7 @@ metadata: #@overlay/match missing_ok=True annotations: cert-manager.io/inject-ca-from: cartographer-system/cartographer-webhook + name: cartographer-validating-webhook-configuration webhooks: #@overlay/match by=overlay.all, expects="1+"