Skip to main content

API server-to-webhook connectivity

Use this setting when an admission webhook or aggregated API runs in a pod with hostNetwork: true. On Syself nodes, the API server can only reach such a pod on the ports you list in the apiserverEgressHostPorts cluster variable, so until you add its port, calls to the webhook fail. Some operators run their webhooks this way. Check the operator's Helm chart for hostNetwork: true.

Webhooks without hostNetwork

If the webhook runs in a regular pod behind a Service, you don't need this setting. If you control the deployment, running the webhook without hostNetwork is the simpler fix.

Unreachable webhooks block or skip requests

While the API server cannot reach the webhook, requests it matches are rejected if it uses failurePolicy: Fail, and pass unchecked if it uses failurePolicy: Ignore.

Allow the API server to reach the webhook 

Add the webhook's listening port to apiserverEgressHostPorts in spec.topology.variables on your Cluster object.

For example, if your webhook listens on port 8443:

yaml
				apiVersion: cluster.x-k8s.io/v1beta2
kind: Cluster
metadata:
  name: mycluster
spec:
  topology:
    variables:
      - name: apiserverEgressHostPorts
        value:
          - 8443
			

Keep the following restrictions in mind:

  • You can specify up to 16 ports. Each port must be unique and between 1 and 65535.
  • The ports apply to all nodes, including control-plane and worker nodes.
  • You cannot use ports already reserved by the node: 22, 100, 2379, 2380, 4240, 4244, 4245, 6443, 6444, 7443, 8180, 8181, 8182, 9443, 10250, 10255, 10256, 10257, and 10259. If your webhook uses one of these ports, configure it to listen on another port.

This setting only allows the API server to reach the specified ports through that connection.

Apply the change 

Changing apiserverEgressHostPorts triggers a rollout of the control plane and all worker pools.

If an operator uses a host-network webhook, configure apiserverEgressHostPorts before installing the operator. Otherwise, the API server won't be able to reach its webhook until the node rollout is complete.

Verify connectivity 

After all nodes have finished rolling, test the webhook with a server-side dry run:

				$ kubectl apply --dry-run=server -f <object-the-webhook-matches>.yaml
			

This sends the object through the API server's admission chain without saving it.

If the webhook accepts the object, or rejects it with its own validation message, the API server successfully reached it.

If you still get an error saying that the API server failed to call the webhook, check the following:

  • The port in apiserverEgressHostPorts matches the port on which the webhook listens.
  • The webhook pod is running and listening on the expected node port.
  • All nodes have finished rolling out the configuration.