Skip to content

Operator down: "conversion webhook … failed: connection refused"

Python & Gotested on Go 1.26, Kubebuilder v4, controller-runtime, envtest

With two API versions, every access that needs conversion depends on the operator's webhook server. If the operator crashes, even simple labels fail.

Symptom

Error from server (InternalError): Internal error occurred: Internal error occurred:
  conversion webhook for web.lab.example/v1, Kind=StaticSite failed: Post
  "https://127.0.0.1:9443/convert?timeout=30s": dial tcp 127.0.0.1:9443: connect:
  connection refused

The operator has crashed; afterwards a label is to be added to the site demo.

Diagnosis

Where do conversion and validation point, and does anyone listen there? (niemand hört auf = nobody listens on)

kubectl get crd staticsites.web.lab.example \
  -o jsonpath='{.spec.conversion.webhook.clientConfig.url}{"\n"}'
kubectl get $VWC -o jsonpath=\
'{.webhooks[0].clientConfig.url} {.webhooks[0].failurePolicy}{"\n"}'
nc -z 127.0.0.1 9443 && echo "Port offen" || echo "niemand hört auf 9443"
https://127.0.0.1:9443/convert
https://127.0.0.1:9443/validate-web-lab-example-v1alpha1-staticsite Fail
niemand hört auf 9443

Causes

ConversionConversion via the same dead port

The admission webhooks are only registered for v1alpha1. So the API server must first convert the object – via the webhook server that is not running.

StorageReadErrorOld version unreadable

Reading via the old API version fails too, because every object would have to be converted.

Fix

Start the operator again; afterwards the label goes through. The manager starts the webhook server before the caches.
kubectl label site demo lab/test=1 --overwrite

Don't: Trying to remove the finalizer of a stuck object while the webhook is down – that is an update too and fails the same way.

▶
Break it yourself and find it – free
Kubernetes operators hands-on, Day 15: a competition with eight typical operator faults, from hot loop to orphans.
Go to day 15 →

FAQ

Why did the status patch go through anyway?

It went to v1 – no conversion needed – and the webhook rules for staticsites do not cover staticsites/status.

How do I make webhooks resilient?

Several replicas with a PodDisruptionBudget, readiness only after the webhook server, and short timeouts.

Related error patterns

More