Kubernetes Flag: max-endpoints-per-slice Explained

When Kubernetes services scale to hundreds or thousands of pods, managing their network endpoints efficiently becomes critical. This is where EndpointSlices come in.
And one of the key tuning knobs for EndpointSlices is the max-endpoints-per-slice flag.


What Is max-endpoints-per-slice?

  • By default, Kubernetes groups pod endpoints into EndpointSlices (instead of one big Endpoints object).
  • Each slice holds up to N endpoints (default: 100).
  • The flag --max-endpoints-per-slice defines that maximum number.

In simple words: it controls how many pod addresses go into a single EndpointSlice.


Why Does It Matter?

  1. Performance

    • Large slices = fewer objects, less overhead for the API server.
    • Small slices = more objects, but less churn when pods scale up/down.
  2. Scalability

    • If you run services with thousands of pods, tuning this value can reduce API pressure.
  3. Networking Stability

    • Smaller slices mean changes affect fewer endpoints per update.
    • This can improve rollout stability.

When Should You Change It?

  • Default (100) works for most clusters.

  • Consider lowering it if:

    • You have very dynamic workloads (pods scale up/down frequently).
    • You want to minimize the blast radius of updates.
  • Consider increasing it if:

    • You run huge services (1000+ pods).
    • You want fewer EndpointSlice objects for better API server performance.

How To Configure

This is a flag on the kube-controller-manager:

kube-controller-manager \
  --max-endpoints-per-slice=150

Or in kubeadm clusters, edit /etc/kubernetes/manifests/kube-controller-manager.yaml:

spec:
  containers:
  - command:
    - kube-controller-manager
    - --max-endpoints-per-slice=150

Summary

  • max-endpoints-per-slice = controls how many endpoints fit into one EndpointSlice.
  • Default: 100.
  • Lower it for dynamic workloads.
  • Raise it for very large services.
  • Always test changes in staging before applying cluster-wide.