From 4633b39e3eb60644eaed1fa2a5eb607ac1531eae Mon Sep 17 00:00:00 2001 From: Ori Braunshtein Date: Thu, 1 Feb 2024 12:13:37 +0200 Subject: [PATCH] Remove the legacy AddressPool - Attempt number 3 We missed a few other spots, hopefully this is the last cleanup. Signed-off-by: Ori Braunshtein --- charts/metallb/templates/rbac.yaml | 8 +------- config/crd/kustomization.yaml | 4 ---- .../crd-conversion-patch-addresspools.yaml | 19 ------------------- .../manifests/metallb-frr-k8s-prometheus.yaml | 17 ----------------- config/manifests/metallb-frr-k8s.yaml | 17 ----------------- config/manifests/metallb-frr-prometheus.yaml | 17 ----------------- config/manifests/metallb-frr.yaml | 17 ----------------- .../manifests/metallb-native-prometheus.yaml | 17 ----------------- config/manifests/metallb-native.yaml | 17 ----------------- config/rbac/role.yaml | 17 ----------------- .../webhook/patches/webhook_conversion.yaml | 18 ------------------ internal/k8s/k8s.go | 9 ++++----- internal/k8s/webhook.go | 4 ---- .../k8s/webhooks/webhookv1beta1/common.go | 1 - .../webhookv1beta2/bgppeer_webhook.go | 4 ++-- .../k8s/webhooks/webhookv1beta2/common.go | 1 - troubleshooting/collect.sh | 2 +- 17 files changed, 8 insertions(+), 181 deletions(-) delete mode 100644 config/crd/patches/crd-conversion-patch-addresspools.yaml diff --git a/charts/metallb/templates/rbac.yaml b/charts/metallb/templates/rbac.yaml index 5a7d53e0359..2f7d835d420 100644 --- a/charts/metallb/templates/rbac.yaml +++ b/charts/metallb/templates/rbac.yaml @@ -27,7 +27,7 @@ rules: verbs: ["list", "watch"] - apiGroups: ["apiextensions.k8s.io"] resources: ["customresourcedefinitions"] - resourceNames: ["addresspools.metallb.io","bfdprofiles.metallb.io","bgpadvertisements.metallb.io", + resourceNames: ["bfdprofiles.metallb.io","bgpadvertisements.metallb.io", "bgppeers.metallb.io","ipaddresspools.metallb.io","l2advertisements.metallb.io","communities.metallb.io"] verbs: ["create", "delete", "get", "list", "patch", "update", "watch"] - apiGroups: ["apiextensions.k8s.io"] @@ -83,9 +83,6 @@ rules: - apiGroups: [""] resources: ["configmaps"] verbs: ["get", "list", "watch"] -- apiGroups: ["metallb.io"] - resources: ["addresspools"] - verbs: ["get", "list", "watch"] - apiGroups: ["metallb.io"] resources: ["bfdprofiles"] verbs: ["get", "list", "watch"] @@ -133,9 +130,6 @@ rules: - apiGroups: [""] resources: ["secrets"] verbs: ["create", "delete", "get", "list", "patch", "update", "watch"] -- apiGroups: ["metallb.io"] - resources: ["addresspools"] - verbs: ["get", "list", "watch"] - apiGroups: ["metallb.io"] resources: ["ipaddresspools"] verbs: ["get", "list", "watch"] diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 84b8997203d..54d7c84c52c 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -9,10 +9,6 @@ resources: - bases/metallb.io_communities.yaml patches: -- path: patches/crd-conversion-patch-addresspools.yaml - target: - kind: CustomResourceDefinition - name: addresspools.metallb.io - path: patches/crd-conversion-patch-bgppeers.yaml target: kind: CustomResourceDefinition diff --git a/config/crd/patches/crd-conversion-patch-addresspools.yaml b/config/crd/patches/crd-conversion-patch-addresspools.yaml deleted file mode 100644 index 07dae1b146c..00000000000 --- a/config/crd/patches/crd-conversion-patch-addresspools.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# The following patch enables conversion webhook for CRD -# CRD conversion requires k8s 1.13 or later. -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: addresspools.metallb.io -spec: - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1alpha1", "v1beta1"] - clientConfig: - # this is a valid pem format, otherwise the apiserver will reject the deletion of the crds - # with "unable to parse bytes as PEM block", The controller will patch it with the right content after it starts - caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tDQpNSUlGWlRDQ0EwMmdBd0lCQWdJVU5GRW1XcTM3MVpKdGkrMmlSQzk1WmpBV1MxZ3dEUVlKS29aSWh2Y05BUUVMDQpCUUF3UWp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pwNllDSVJldlBqbzg5ZytWTlJSaVFYUThJd0dybXE5c0RoVTlqTjA0SjdVL1RvRDFpNHE3VnlsRUc5DQorV1VGNkNLaEdBeTJIaEhwVncyTGFoOS9lUzdZMUZ1YURrWmhPZG1laG1BOCtqdHNZamJadnR5Mm1SWlF0UUZzDQpUU1VUUjREbUR2bVVPRVRmeStpRHdzK2RkWXVNTnJGeVVYV2dkMnpBQU4ydVl1UHFGY2pRcFNPODFzVTJTU3R3DQoxVzAyeUtYOGJEYmZFdjBzbUh3UzliQnFlSGo5NEM1Mjg0YXpsdTBmaUdpTm1OUEM4ckJLRmhBPQ0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQ== - service: - namespace: metallb-system - name: webhook-service - path: /convert diff --git a/config/manifests/metallb-frr-k8s-prometheus.yaml b/config/manifests/metallb-frr-k8s-prometheus.yaml index 7e17310c5f9..c63226f690a 100644 --- a/config/manifests/metallb-frr-k8s-prometheus.yaml +++ b/config/manifests/metallb-frr-k8s-prometheus.yaml @@ -1619,14 +1619,6 @@ rules: verbs: - get - list -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1726,14 +1718,6 @@ rules: - get - list - watch -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -2000,7 +1984,6 @@ rules: - apiGroups: - apiextensions.k8s.io resourceNames: - - addresspools.metallb.io - bfdprofiles.metallb.io - bgpadvertisements.metallb.io - bgppeers.metallb.io diff --git a/config/manifests/metallb-frr-k8s.yaml b/config/manifests/metallb-frr-k8s.yaml index 8ac1c4ec9d6..52fdde79527 100644 --- a/config/manifests/metallb-frr-k8s.yaml +++ b/config/manifests/metallb-frr-k8s.yaml @@ -1614,14 +1614,6 @@ rules: verbs: - get - list -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1721,14 +1713,6 @@ rules: - get - list - watch -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1966,7 +1950,6 @@ rules: - apiGroups: - apiextensions.k8s.io resourceNames: - - addresspools.metallb.io - bfdprofiles.metallb.io - bgpadvertisements.metallb.io - bgppeers.metallb.io diff --git a/config/manifests/metallb-frr-prometheus.yaml b/config/manifests/metallb-frr-prometheus.yaml index d7e41157424..d1243429c8d 100644 --- a/config/manifests/metallb-frr-prometheus.yaml +++ b/config/manifests/metallb-frr-prometheus.yaml @@ -1136,14 +1136,6 @@ rules: verbs: - get - list -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1215,14 +1207,6 @@ rules: - get - list - watch -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1370,7 +1354,6 @@ rules: - apiGroups: - apiextensions.k8s.io resourceNames: - - addresspools.metallb.io - bfdprofiles.metallb.io - bgpadvertisements.metallb.io - bgppeers.metallb.io diff --git a/config/manifests/metallb-frr.yaml b/config/manifests/metallb-frr.yaml index 8a54f3f0cc6..da029f3a8fd 100644 --- a/config/manifests/metallb-frr.yaml +++ b/config/manifests/metallb-frr.yaml @@ -1136,14 +1136,6 @@ rules: verbs: - get - list -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1215,14 +1207,6 @@ rules: - get - list - watch -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1341,7 +1325,6 @@ rules: - apiGroups: - apiextensions.k8s.io resourceNames: - - addresspools.metallb.io - bfdprofiles.metallb.io - bgpadvertisements.metallb.io - bgppeers.metallb.io diff --git a/config/manifests/metallb-native-prometheus.yaml b/config/manifests/metallb-native-prometheus.yaml index 6a0c0ee1450..af1ff2ec009 100644 --- a/config/manifests/metallb-native-prometheus.yaml +++ b/config/manifests/metallb-native-prometheus.yaml @@ -1136,14 +1136,6 @@ rules: verbs: - get - list -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1215,14 +1207,6 @@ rules: - get - list - watch -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1370,7 +1354,6 @@ rules: - apiGroups: - apiextensions.k8s.io resourceNames: - - addresspools.metallb.io - bfdprofiles.metallb.io - bgpadvertisements.metallb.io - bgppeers.metallb.io diff --git a/config/manifests/metallb-native.yaml b/config/manifests/metallb-native.yaml index 53d52cbfaf8..318a24e90a9 100644 --- a/config/manifests/metallb-native.yaml +++ b/config/manifests/metallb-native.yaml @@ -1136,14 +1136,6 @@ rules: verbs: - get - list -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1215,14 +1207,6 @@ rules: - get - list - watch -- apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -1341,7 +1325,6 @@ rules: - apiGroups: - apiextensions.k8s.io resourceNames: - - addresspools.metallb.io - bfdprofiles.metallb.io - bgpadvertisements.metallb.io - bgppeers.metallb.io diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index ca25578a3df..15e6008e3f4 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -69,7 +69,6 @@ rules: resources: - customresourcedefinitions resourceNames: - - addresspools.metallb.io - bfdprofiles.metallb.io - bgpadvertisements.metallb.io - bgppeers.metallb.io @@ -162,14 +161,6 @@ rules: - get - list - watch - - apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: @@ -261,14 +252,6 @@ rules: verbs: - get - list - - apiGroups: - - metallb.io - resources: - - addresspools - verbs: - - get - - list - - watch - apiGroups: - metallb.io resources: diff --git a/config/webhook/patches/webhook_conversion.yaml b/config/webhook/patches/webhook_conversion.yaml index 8188073ddca..40eae4b3728 100644 --- a/config/webhook/patches/webhook_conversion.yaml +++ b/config/webhook/patches/webhook_conversion.yaml @@ -1,23 +1,5 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition -metadata: - name: addresspools.metallb.io -spec: - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1alpha1", "v1beta1"] - clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-controller. - caBundle: Cg== - service: - namespace: metallb-system - name: webhook-service - path: /convert ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition metadata: name: bgppeers.metallb.io spec: diff --git a/internal/k8s/k8s.go b/internal/k8s/k8s.go index 0f269ac0255..6183aef5be8 100644 --- a/internal/k8s/k8s.go +++ b/internal/k8s/k8s.go @@ -58,11 +58,10 @@ const ( ) var ( - scheme = runtime.NewScheme() - setupLog = ctrl.Log.WithName("setup") - validatingWebhookName = "metallb-webhook-configuration" - addresspoolConvertingWebhookCRD = "addresspools.metallb.io" - bgppeerConvertingWebhookCRD = "bgppeers.metallb.io" + scheme = runtime.NewScheme() + setupLog = ctrl.Log.WithName("setup") + validatingWebhookName = "metallb-webhook-configuration" + bgppeerConvertingWebhookCRD = "bgppeers.metallb.io" ) func init() { diff --git a/internal/k8s/webhook.go b/internal/k8s/webhook.go index 5301a208be1..1e82c2117f2 100644 --- a/internal/k8s/webhook.go +++ b/internal/k8s/webhook.go @@ -22,10 +22,6 @@ func enableCertRotation(notifyFinished chan struct{}, cfg *Config, mgr manager.M Name: validatingWebhookName, Type: rotator.Validating, }, - { - Name: addresspoolConvertingWebhookCRD, - Type: rotator.CRDConversion, - }, { Name: bgppeerConvertingWebhookCRD, Type: rotator.CRDConversion, diff --git a/internal/k8s/webhooks/webhookv1beta1/common.go b/internal/k8s/webhooks/webhookv1beta1/common.go index 1d4982cbf49..370dbdf36b3 100644 --- a/internal/k8s/webhooks/webhookv1beta1/common.go +++ b/internal/k8s/webhooks/webhookv1beta1/common.go @@ -9,7 +9,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -// log is for logging addresspool-webhook. var ( Logger log.Logger WebhookClient client.Reader diff --git a/internal/k8s/webhooks/webhookv1beta2/bgppeer_webhook.go b/internal/k8s/webhooks/webhookv1beta2/bgppeer_webhook.go index 3b2b016ad27..5066bbad142 100644 --- a/internal/k8s/webhooks/webhookv1beta2/bgppeer_webhook.go +++ b/internal/k8s/webhooks/webhookv1beta2/bgppeer_webhook.go @@ -111,7 +111,7 @@ func validatePeerCreate(bgpPeer *v1beta2.BGPPeer) error { return nil } -// validatePeerUpdate implements webhook.Validator so a webhook will be registered for AddressPool. +// validatePeerUpdate implements webhook.Validator so a webhook will be registered for BGPPeer. func validatePeerUpdate(bgpPeer *v1beta2.BGPPeer, _ *v1beta2.BGPPeer) error { level.Debug(Logger).Log("webhook", "bgppeer", "action", "update", "name", bgpPeer.Name, "namespace", bgpPeer.Namespace) @@ -129,7 +129,7 @@ func validatePeerUpdate(bgpPeer *v1beta2.BGPPeer, _ *v1beta2.BGPPeer) error { return nil } -// validatePeerDelete implements webhook.Validator so a webhook will be registered for AddressPool. +// validatePeerDelete implements webhook.Validator so a webhook will be registered for BGPPeer. func validatePeerDelete(bgpPeer *v1beta2.BGPPeer) error { return nil } diff --git a/internal/k8s/webhooks/webhookv1beta2/common.go b/internal/k8s/webhooks/webhookv1beta2/common.go index d37ffe2ba2c..438118d14b6 100644 --- a/internal/k8s/webhooks/webhookv1beta2/common.go +++ b/internal/k8s/webhooks/webhookv1beta2/common.go @@ -9,7 +9,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -// log is for logging addresspool-webhook. var ( Logger log.Logger WebhookClient client.Reader diff --git a/troubleshooting/collect.sh b/troubleshooting/collect.sh index ac1910c17b1..7c494e57982 100755 --- a/troubleshooting/collect.sh +++ b/troubleshooting/collect.sh @@ -9,7 +9,7 @@ METALLB_NS="${METALLB_NS:-metallb-system}" OUTPUT="./report" function get_metallb_crs() { - declare -a METALLB_CRDS=("addresspools" "bgppeers" "bfdprofiles" "bgpAdvertisements" "ipaddresspools" "l2advertisements" "communities") + declare -a METALLB_CRDS=("bgppeers" "bfdprofiles" "bgpAdvertisements" "ipaddresspools" "l2advertisements" "communities") mkdir -p ${OUTPUT}/crds/ for CRD in "${METALLB_CRDS[@]}"; do