apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: deny-allspec: podSelector: {} policyTypes: - Egress - Ingress---apiVersion: crd.antrea.io/v1beta1kind: NetworkPolicymetadata: name: allow-ingress-kube-apispec: appliedTo: - podSelector: {} ingress: - action: Allow from: - namespaceSelector: matchLabels: kubernetes.io/metadata.name: kube-system podSelector: matchLabels: component: kube-apiserver tier: control-plane name: allow-ingress-kube-api priority: 5 tier: platform
kubectl -n test create -f test-pod.yaml Error from server (InternalError): error when creating "test.yaml": Internal error occurred: failed calling webhook "validate-resources.example.com": failed to call webhook: Post "https://webhook-service.webhook-system.svc:443/validate?timeout=2s": context deadline exceededapiVersion: crd.antrea.io/v1beta1kind: NetworkPolicymetadata: name: allow-control-plane-nodesspec: appliedTo: - podSelector: {} ingress: - action: Allow from: - nodeSelector: matchExpressions: - key: node-role.kubernetes.io/control-plane operator: Exists name: allow-control-plane-nodes priority: 5 tier: platform
VMware Container Networking with Antrea
VMware Kubernetes Service
Antrea allows traffic from nodes labeled node-role.kubernetes.io/control-plane. However, a new node does not receive this label until the end of its boot process. Because it is unlabeled during boot, the Antrea Cluster Network Policy (ANCP) blocks API requests to the webhook.
For Antrea, there is no way to manipulate the labels to allow this traffic.
Similarly, in VKS, there is no way around the delay in node labelling which was introduced to resolve Bounding Self-Labeling Kubelets issue.
To workaround this issue, for web hooks that support the change, you can reduce the timeout to 2 or 3 seconds. Example:
webhooks:- name: resources-webhook-service timeoutSeconds: 2 failurePolicy: Ignore
This particular behaviour can also cause issue during VKS upgrades. The following VKS KB outlines issues and VKS general support for web hooks.