Problem

While reinstalling Metallb, the following error appears if the old entries are not removed.
error: installation failed: rendered manifests contain a resource that already exists. unable to continue with install: customresourcedefinition "addresspools.metallb.io"

Solution

  • Delete all the Kubernetes Custom Resource Definition (CRD)s related to Metallb.
    1. Run the following command to get the list of Kubernetes CRDs.
      kubectl get crds | grep metallb

      The list of Kubernetes CRDs appear.

    2. Run the following commands to delete each Kubernetes CRDs.
      kubectl delete crds <crds_name>
      customresourcedefinition.apiextensions.k8s.io "<crds_name>" deleted
    3. Run the following command to delete all the Metallb related clusterrolebindings.
      kubectl get clusterrolebindings | grep metallb
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl get clusterrolebindings | grep metallb
      metallb:controller          ClusterRole/metallb:controller                26m
      metallb:speaker             ClusterRole/metallb:speaker                   26m
       
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl delete clusterrolebinding metallb:controller
      clusterrolebinding.rbac.authorization.k8s.io "metallb:controller" deleted
       
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl delete clusterrolebinding metallb:speaker
      clusterrolebinding.rbac.authorization.k8s.io "metallb:speaker" deleted
       
    4. Run the following command to delete all the Metallb related clusterroles.
      kubectl get clusterrole | grep metallb
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl get clusterrole | grep metallb
      metallb:controller              2023-03-25T17:32:54Z
      metallb:speaker                 2023-03-25T17:32:54Z
       
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl delete clusterrole metallb:controller
      clusterrole.rbac.authorization.k8s.io "metallb:controller" deleted
       
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl delete clusterrole metallb:speaker
      clusterrole.rbac.authorization.k8s.io "metallb:speaker" deleted
    5. Run the following command to delete the webhook for metallb.
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl get validatingwebhookconfiguration
      NAME                            WEBHOOKS   AGE
      metallb-webhook-configuration   7          32m
      nodeconfig-validator            1          73d
       
       
      capv@wc-dev-master-control-plane-fcg4g [ ~ ]$ kubectl delete validatingwebhookconfiguration metallb-webhook-configuration
      validatingwebhookconfiguration.admissionregistration.k8s.io "metallb-webhook-configuration" deleted