From 6effa7d837c85eb976b0a08ca2b603a18ecba8da Mon Sep 17 00:00:00 2001 From: Matt Jenkinson <75292329+mattdjenkinson@users.noreply.github.com> Date: Fri, 22 May 2026 15:20:24 +0100 Subject: [PATCH] fix: install PaymentMethod CRDs + restore webhook Service name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two release-process bugs that landed in v0.2.0 and stuck around on main; together they take down the billing-controller-manager and break BillingAccount admission against the deployed bundle: 1. config/base/crd/kustomization.yaml only listed four CRDs even though controller-gen had emitted six. PaymentMethod and PaymentMethodClass were in config/base/crd/bases/ but never referenced, so the bundle that ships to Flux installed only the four originals. The controller-manager then tried to watch PaymentMethod, hit `no matches for kind "PaymentMethod" in version "billing.miloapis.com/v1alpha1"`, timed out waiting for the cache to sync, and exited 1. Result: CrashLoopBackOff on the manager replicas in staging. 2. config/base/webhook/manifests.yaml shipped with the kubebuilder placeholder Service name (`webhook-service`) instead of the billing-webhook Service this repo actually declares. Kustomize's nameReference transformer cannot bridge the two because nothing ever renames a Service — they are simply different identifiers. The deployed MutatingWebhookConfiguration therefore pointed at webhook-service.billing-system.svc, which does not exist, and every BillingAccount mutating-admission call failed DNS lookup. For (2) the existing fix-up was a comment in webhook/kustomization.yaml asking devs to hand-restore the service name after each `task manifests` regeneration. v0.2.0 demonstrates how reliable that is. Wire the fix-up into the manifests task itself so the regenerated file is always consistent with the declared Service. --- Taskfile.yaml | 8 ++++++++ config/base/crd/kustomization.yaml | 2 ++ config/base/webhook/kustomization.yaml | 7 ++++--- config/base/webhook/manifests.yaml | 16 ++++++++-------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index a1855cd..bb7940f 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -52,6 +52,14 @@ tasks: output:crd:artifacts:config=config/base/crd/bases \ output:rbac:artifacts:config=config/components/controller_rbac \ output:webhook:artifacts:config=config/base/webhook + # controller-gen always emits the kubebuilder placeholder + # service name (`webhook-service`) on every regeneration, + # which does not match the Service this repo actually + # declares (`billing-webhook`). Restore it in-place so the + # generated manifest matches the declared Service without + # requiring an out-of-band manual fix-up. + perl -pi -e 's/^( name: )webhook-service$/${1}billing-webhook/' \ + config/base/webhook/manifests.yaml echo "Manifests generated!" deps: - install-tools diff --git a/config/base/crd/kustomization.yaml b/config/base/crd/kustomization.yaml index 1b3b189..7e40e36 100644 --- a/config/base/crd/kustomization.yaml +++ b/config/base/crd/kustomization.yaml @@ -6,6 +6,8 @@ resources: - bases/billing.miloapis.com_billingaccountbindings.yaml - bases/billing.miloapis.com_meterdefinitions.yaml - bases/billing.miloapis.com_monitoredresourcetypes.yaml +- bases/billing.miloapis.com_paymentmethods.yaml +- bases/billing.miloapis.com_paymentmethodclasses.yaml # +kubebuilder:scaffold:crdkustomizeresource patches: diff --git a/config/base/webhook/kustomization.yaml b/config/base/webhook/kustomization.yaml index b3703c4..142b5f9 100644 --- a/config/base/webhook/kustomization.yaml +++ b/config/base/webhook/kustomization.yaml @@ -2,9 +2,10 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component resources: # manifests.yaml is generated by controller-gen and should NOT be edited -# directly — `task manifests` will overwrite it. After regeneration, restore -# the service name from the controller-gen default (`webhook-service`) to -# `billing-webhook` to match the declared Service. +# directly — `task manifests` will overwrite it. The service name fix-up +# (`webhook-service` → `billing-webhook`) is applied in-place by the +# manifests task itself, so regenerating no longer leaves the file in a +# broken state. - manifests.yaml # Teach kustomize about the webhook clientConfig.service.{name,namespace} diff --git a/config/base/webhook/manifests.yaml b/config/base/webhook/manifests.yaml index e578d98..c7a0042 100644 --- a/config/base/webhook/manifests.yaml +++ b/config/base/webhook/manifests.yaml @@ -8,7 +8,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /mutate-billing-miloapis-com-v1alpha1-billingaccount failurePolicy: Fail @@ -28,7 +28,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /mutate-billing-miloapis-com-v1alpha1-paymentmethod failurePolicy: Fail @@ -54,7 +54,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /validate-billing-miloapis-com-v1alpha1-billingaccount failurePolicy: Fail @@ -75,7 +75,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /validate-billing-miloapis-com-v1alpha1-billingaccountbinding failurePolicy: Fail @@ -96,7 +96,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /validate-billing-miloapis-com-v1alpha1-meterdefinition failurePolicy: Fail @@ -117,7 +117,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /validate-billing-miloapis-com-v1alpha1-monitoredresourcetype failurePolicy: Fail @@ -138,7 +138,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /validate-billing-miloapis-com-v1alpha1-paymentmethod failurePolicy: Fail @@ -158,7 +158,7 @@ webhooks: - v1 clientConfig: service: - name: webhook-service + name: billing-webhook namespace: system path: /validate-billing-miloapis-com-v1alpha1-paymentmethodclass failurePolicy: Fail