kubernetes/kubernetes · error

max-endpoints-per-slice must not be more than %d, but got %d

Error message

max-endpoints-per-slice must not be more than %d, but got %d

What it means

Validation error from EndpointSliceControllerOptions.Validate() when --max-endpoints-per-slice exceeds 1000 (the maxMaxEndpointsPerSlice constant). Each EndpointSlice is a single API object with size limits; values above 1000 would create oversized objects that risk etcd request limits and API throttling.

Source

Thrown at cmd/kube-controller-manager/app/options/endpointslicecontroller.go:80

// Validate checks validation of EndpointSliceControllerOptions.
func (o *EndpointSliceControllerOptions) Validate() []error {
	if o == nil {
		return nil
	}

	errs := []error{}

	if o.ConcurrentServiceEndpointSyncs < minConcurrentServiceEndpointSyncs {
		errs = append(errs, fmt.Errorf("concurrent-service-endpoint-syncs must not be less than %d, but got %d", minConcurrentServiceEndpointSyncs, o.ConcurrentServiceEndpointSyncs))
	} else if o.ConcurrentServiceEndpointSyncs > maxConcurrentServiceEndpointSyncs {
		errs = append(errs, fmt.Errorf("concurrent-service-endpoint-syncs must not be more than %d, but got %d", maxConcurrentServiceEndpointSyncs, o.ConcurrentServiceEndpointSyncs))
	}

	if o.MaxEndpointsPerSlice < minMaxEndpointsPerSlice {
		errs = append(errs, fmt.Errorf("max-endpoints-per-slice must not be less than %d, but got %d", minMaxEndpointsPerSlice, o.MaxEndpointsPerSlice))
	} else if o.MaxEndpointsPerSlice > maxMaxEndpointsPerSlice {
		errs = append(errs, fmt.Errorf("max-endpoints-per-slice must not be more than %d, but got %d", maxMaxEndpointsPerSlice, o.MaxEndpointsPerSlice))
	}

	return errs
}

View on GitHub (pinned to b882c60b40)

Solutions

  1. Reduce --max-endpoints-per-slice to 1000 or below (default is 100).
  2. Keep the default of 100 unless you have a specific reason to increase it — higher values create larger objects.
  3. Check config files for an inflated maxEndpointsPerSlice value.

Example fix

# before
kube-controller-manager --max-endpoints-per-slice=5000

# after
kube-controller-manager --max-endpoints-per-slice=1000
Defensive patterns

Strategy: validation

Validate before calling

// Validate the max endpoints per slice upper bound before starting:
const maxMaxEndpointsPerSlice = 1000
if o.MaxEndpointsPerSlice > maxMaxEndpointsPerSlice {
    return fmt.Errorf("max-endpoints-per-slice must be <= %d, got %d", maxMaxEndpointsPerSlice, o.MaxEndpointsPerSlice)
}

Type guard

func isValidMaxEndpointsPerSlice(n int32) bool {
    return n >= 1 && n <= 1000
}

Prevention

When it happens

Trigger: Starting kube-controller-manager with --max-endpoints-per-slice set above 1000 (e.g. 5000). Validate() enforces the upper bound.

Common situations: Operator tries to minimize the number of EndpointSlice objects by cramming endpoints in, not realizing the 1000 cap; a config map or Helm value is set too high; copy-pasting a value from a non-Kubernetes load balancer max-endpoints setting.

Related errors


AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07). Data as JSON: /api/errors/2117ece67f326a29. Report an issue: GitHub.