Namespace Operations Fail with Gatekeeper Webhook Connection Refused Error
search cancel

Namespace Operations Fail with Gatekeeper Webhook Connection Refused Error

book

Article ID: 437222

calendar_today

Updated On:

Products

Tanzu Kubernetes Runtime VMware Tanzu Mission Control VMware vSphere Kubernetes Service VMware vSphere ESXi

Issue/Introduction

  • Unable to perform Kubernetes namespace operations on VKS Cluster. The create/update operation fails with the following API server error indicating a webhook timeout:

Error from server (InternalError): Internal error occurred: failed calling webhook "check-ignore-label.gatekeeper.sh": failed to call webhook: Post "https://gatekeeper-webhook-service.gatekeeper-system.svc:443/v1/admitlabel?timeout=3s": dial tcp <IP>:443: connect: connection refused

  • Additionally, inspecting the configuration of the webhook reveals the presence of the tmc.cloud.vmware.com/managed: "true" annotation, indicating the resource is a remnant of Tanzu Mission Control - SAAS.

Environment

  • VMware vSphere Kubernetes Service
  • VMware Tanzu Mission Control - SAAS

Cause

  • The Tanzu Mission Control (TMC) agents were improperly or manually removed from the cluster. This action deleted namespace-scoped resources, including the Gatekeeper controller pods and services, but orphaned the cluster-scoped gatekeeper-validating-webhook-configuration.
  • The active webhook intercepts namespace modification requests and routes them to a non-existent service endpoint.

Resolution

  1. Connect to the affected cluster with cluster-admin privileges.

  2. Verify the orphaned webhook configuration was managed by TMC by checking for the tmc.cloud.vmware.com/managed annotation:
    kubectl get validatingwebhookconfiguration gatekeeper-validating-webhook-configuration -o yaml | grep "tmc"

  3. Backup the orphaned validating webhook configuration:
    kubectl get validatingwebhookconfiguration gatekeeper-validating-webhook-configuration -o yaml > gatekeeper-webhook-backup.yaml

  4. Delete the validating webhook configuration:
    kubectl delete validatingwebhookconfiguration gatekeeper-validating-webhook-configuration

  5. Verify that namespace labeling operations now complete successfully.