kubernetes/kops · error

cannot set more than one CIDR or IPv6CIDR

Error message

cannot set more than one CIDR or IPv6CIDR

What it means

This validation error is raised in Route task CheckChanges when both CIDR (IPv4) and IPv6CIDR destination fields are set on a route. AWS routes can only have one destination CIDR block — either IPv4 or IPv6 — never both simultaneously. It is a pre-flight guard before calling AWS.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/route.go:143

	return nil, nil
}

func (e *Route) Run(c *fi.CloudupContext) error {
	return fi.CloudupDefaultDeltaRunMethod(e, c)
}

func (s *Route) CheckChanges(a, e, changes *Route) error {
	if a == nil {
		// TODO: Create validate method?
		if e.RouteTable == nil {
			return fi.RequiredField("RouteTable")
		}
		if e.CIDR == nil && e.IPv6CIDR == nil {
			return fi.RequiredField("CIDR/IPv6CIDR")
		}
		if e.CIDR != nil && e.IPv6CIDR != nil {
			return fmt.Errorf("cannot set more than one CIDR or IPv6CIDR")
		}
		targetCount := 0
		if e.EgressOnlyInternetGateway != nil {
			targetCount++
			if e.CIDR != nil {
				return fmt.Errorf("cannot route IPv4 to an EgressOnlyInternetGateway")
			}
		}
		if e.InternetGateway != nil {
			targetCount++
		}
		if e.Instance != nil {
			targetCount++
		}
		if e.NatGateway != nil {
			targetCount++
		}
		if e.TransitGatewayID != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Remove the CIDR field if this route is IPv6-only
  2. Remove the IPv6CIDR field if this route is IPv4-only
  3. Split into two separate Route tasks, one for each CIDR
  4. Regenerate the manifest with kops toolbox to eliminate the duplicate

Example fix

// before
route:
  cidr: 0.0.0.0/0
  ipv6Cidr: ::/0
// after
route:
  ipv6Cidr: ::/0
Defensive patterns

Strategy: validation

Validate before calling

func validateRoute(r Route) error {
	if r.CIDR != nil && r.IPv6CIDR != nil {
		return errors.New("cannot set more than one CIDR or IPv6CIDR")
	}
	if r.CIDR == nil && r.IPv6CIDR == nil {
		return errors.New("CIDR/IPv6CIDR required")
	}
	return nil
}

Prevention

When it happens

Trigger: Defining a route in the kOps cluster spec with both `cidr` and `ipv6Cidr` fields populated on the same Route task object.

Common situations: Copy-pasting a route definition and adding an IPv6 field without removing the IPv4 field; template generation tools emitting both fields; merging cluster specs from IPv4 and IPv6 configurations.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/a1c7e31609807f27. Report an issue: GitHub.