Symptoms
Internal error occurred: failed calling webhook "validate.policy.example.com":
failed to call webhook: Post "https://policy-webhook.policy.svc:443/validate?timeout=10s":
context deadline exceeded
kubectl applyis slow or fails, but reads work.- ReplicaSets create no pods, and nothing is wrong on the nodes.
- The failure starts after a node pool cycle, NSG change or certificate rotation.
The webhook call goes from the OKE managed control plane to your pods. Testing from a pod to the service does not exercise that path.
Step 1: identify the failing layer
kubectl get events -A --field-selector type=Warning \
--sort-by=.lastTimestamp | grep -i webhook
kubectl describe rs -n app -l app=web | sed -n '/Events/,$p'
| Error text | Layer | Go to |
|---|---|---|
no endpoints available for service | Pods are not Ready or selector is wrong | Step 2 |
connection refused | Nothing listens on the target port | Step 2 |
context deadline exceeded, i/o timeout | Security rules, NetworkPolicy or slow handler | Steps 3 and 4 |
x509: certificate signed by unknown authority | caBundle doesn't match the serving certificate | Step 5 |
x509: certificate is valid for ..., not ... | SAN doesn't contain <svc>.<ns>.svc | Step 5 |
denied the request | Webhook works and rejected the object | Fix the object or policy |
List the webhooks with the fields that matter:
kubectl get validatingwebhookconfigurations,mutatingwebhookconfigurations -o json |
jq -r '.items[] | .kind as $k | .metadata.name as $n | .webhooks[]? |
[$k, $n, .name, .failurePolicy, .timeoutSeconds,
((.clientConfig.service.namespace // "") + "/" + (.clientConfig.service.name // "url")),
([.rules[]?.resources[]?] | unique | join(","))] | @tsv'
failurePolicy: Fail with resources such as pods or * has the largest blast radius.
Step 2: check the endpoint
NS=policy; SVC=policy-webhook
kubectl -n $NS get svc $SVC -o yaml
kubectl -n $NS get endpointslices -l kubernetes.io/service-name=$SVC
kubectl -n $NS get pods -o wide
kubectl -n $NS logs deploy/policy-webhook --since=15m
The service targetPort is the port the pod must accept. Port 443 on the service doesn't mean that the API server connects to 443 on the pod.
Check hostNetwork too:
kubectl -n $NS get pods -o json |
jq -r '.items[] | [.metadata.name, .status.podIP, (.spec.hostNetwork // false)] | @tsv'
Step 3: check the OCI path from the API endpoint
Find the API endpoint subnet and NSGs:
oci ce cluster get --cluster-id "$CLUSTER" \
--query 'data.{endpoint:"endpoint-config",cni:"cluster-pod-network-options"}'
The rules Oracle documents differ by CNI:
| CNI | API endpoint egress | Matching ingress |
|---|---|---|
| VCN-native | All protocols to the pods CIDR; TCP 10250 and ICMP to workers | Pod subnet: all protocols from API endpoint CIDR. Worker subnet: TCP 10250 and ICMP from API endpoint CIDR |
| Flannel | All TCP to the workers CIDR | Worker subnet: all TCP from API endpoint CIDR |
Three failures follow from this table.
- Tightened pod rules. Someone limited API-endpoint-to-pod traffic to 443, while the webhook listens on 8443 or 9443.
hostNetworkwebhook on VCN-native. Its IP is the worker's IP. The documented worker rule permits only TCP 10250, so a webhook on another port times out.- New pod subnet. A new node pool uses another pod subnet, and the API endpoint rules don't include its CIDR. The webhook fails only when its pod lands on the new pool.
List NSG rules:
oci network nsg rules list --nsg-id "$API_NSG" --direction EGRESS --all \
--query 'data[].{dst:destination,proto:protocol,tcp:"tcp-options"}'
oci network nsg rules list --nsg-id "$POD_NSG" --direction INGRESS --all \
--query 'data[].{src:source,proto:protocol,tcp:"tcp-options"}'
Security lists also apply, and a flow is permitted if either permits it. Stateless rules need a return rule.
Enable flow logs on the API endpoint and pod subnets if you can't see the gap. A REJECT from the API endpoint IP to the webhook port is conclusive.
Step 4: check NetworkPolicy and latency
A default-deny policy may admit only pod selectors. The API server is not a pod, so it needs an ipBlock:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-apiserver-to-webhook
namespace: policy
spec:
podSelector:
matchLabels:
app: policy-webhook
policyTypes: [Ingress]
ingress:
- from:
- ipBlock:
cidr: 10.0.0.0/28 # API endpoint subnet
ports:
- protocol: TCP
port: 9443
The source address can differ with the CNI and NAT behaviour, so confirm it in the webhook's access log or flow logs.
For a path that works but is slow, read the API server metrics:
kubectl get --raw /metrics |
grep -E 'apiserver_admission_webhook_(rejection_count|fail_open_count|admission_duration_seconds_(sum|count))'
A managed control plane can have several API servers, and each request samples only one. Use trends rather than a single reading. fail_open_count shows requests that skipped an Ignore webhook; metric names vary by version.
Step 5: check the certificate
kubectl get validatingwebhookconfiguration policy-webhook -o json |
jq -r '.webhooks[0].clientConfig.caBundle' | base64 -d |
openssl x509 -noout -subject -enddate -fingerprint
kubectl -n policy port-forward svc/policy-webhook 9443:443 &
openssl s_client -connect 127.0.0.1:9443 \
-servername policy-webhook.policy.svc -showcerts </dev/null 2>/dev/null |
openssl x509 -noout -issuer -enddate -ext subjectAltName
If the CA changed, restart or repair the component that injects caBundle. With cert-manager, check the cainjector logs.
Step 6: break a deadlock
A deadlock occurs when the webhook must approve the pods that would restore it. All of its nodes were recycled, the new pods need admission, and admission needs the webhook.
The webhook configuration objects themselves aren't sent to admission webhooks, so you can still change them.
Caution
Relaxing a policy webhook lets unvalidated objects into the cluster. A relaxed mutating webhook may omit sidecars or security settings. Get approval, restrict who can deploy, and record the window.
Back up, then relax only the failing entry:
kubectl get validatingwebhookconfiguration policy-webhook -o yaml > webhook-backup.yaml
# Confirm the index first
kubectl get validatingwebhookconfiguration policy-webhook \
-o jsonpath='{range .webhooks[*]}{.name}{"\n"}{end}'
kubectl patch validatingwebhookconfiguration policy-webhook --type=json \
-p='[{"op":"replace","path":"/webhooks/0/failurePolicy","value":"Ignore"}]'
Ignore still waits for the timeout on each call. If many calls queue, also set timeoutSeconds to 1 or 2. A controller such as GitOps may revert the patch; suspend it first.
Recover the webhook, then restore and test:
kubectl -n policy rollout status deploy/policy-webhook --timeout=5m
kubectl patch validatingwebhookconfiguration policy-webhook --type=json \
-p='[{"op":"replace","path":"/webhooks/0/failurePolicy","value":"Fail"}]'
kubectl -n app run admission-test --image=busybox --dry-run=server -o yaml >/dev/null && echo OK
--dry-run=server runs admission without storing the pod. Webhooks that declare side effects reject dry-run calls. Finally, audit the objects created during the window.
Prevent it next time
- Run at least two replicas, with topology spread across fault domains and a PodDisruptionBudget. Check that the PDB still allows node cycling.
- Exclude the webhook's own namespace and
kube-system:
namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: NotIn
values: [kube-system, policy]
- Protect excluded namespaces with RBAC, because their objects skip the policy.
- Never match
*resources. Intercepting leases can disrupt node heartbeats and leader election. - Use short timeouts. Mutating webhooks run in sequence, so their delays add up.
- Consider ValidatingAdmissionPolicy for simple rules; CEL runs in the API server with no network call.
- Add each new pod subnet to the API endpoint rules as part of node pool provisioning.
- Alert on webhook latency and certificate expiry, and drill a full recycle in staging.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get