IBM Cloud Docs
Deleting webhooks from a cluster

Deleting webhooks from a cluster

Some troubleshooting and debugging steps might require you to temporarily remove certain webhooks from your cluster. Follow these steps to remove webhooks, then reapply them after you have resolved your issue.

Checking webhooks that are rejecting requests

  1. Before you delete webhooks, run the following command to get a list of webhooks that are rejecting requests.

    kubectl get --raw /metrics | grep apiserver_admission_webhook_admission_duration_seconds
    
  2. Review the output for webhooks that have rejected="true" status.

  3. Continue troubleshooting the webhooks that are rejecting requests.

Deleting webhooks

  1. List the mutating webhooks in your cluster.

    kubectl get mutatingwebhookconfigurations
    
  2. For each mutating webhook, copy the component YAML file and delete the webhook.

    1. Run the command to copy the YAML file. Save the YAML file so you can reapply it later.

      kubectl get mutatingwebhookconfigurations <WEBHOOK-NAME> -o yaml > <WEBHOOK-NAME>.yml
      
    2. Delete the mutating webhook.

      kubectl delete mutatingwebhookconfigurations <WEBHOOK-NAME>
      
  3. List the validating webhooks in your cluster.

    kubectl get validatingwebhookconfigurations
    
  4. Identify any validating webhooks that aren't included in the following list.

    • alertmanagerconfigs.openshift.io
    • managed-storage-validation-webhooks
    • multus.openshift.io
    • performance-addon-operator
    • prometheusrules.openshift.io
    • snapshot.storage.k8s.io

    Any validating webhook that's included in this list shouldn't be deleted in the following steps.

  5. For each validating webhook that isn't included in the previous list, copy the component YAML file and delete the webhook.

    1. Run the command to copy the YAML file. Save the YAML file so you can reapply it later.

      kubectl get validatingwebhookconfigurations <WEBHOOK-NAME> -o yaml > <WEBHOOK-NAME>.yml
      
    2. Delete the validating webhook.

      kubectl delete validatingwebhookconfigurations <WEBHOOK-NAME>
      
  6. When you are done troubleshooting your worker node issue, reapply the webhook YAML files.

    kubectl apply -f <webhook-yaml-file>