kubernetes/kops · error

missing target for route

Error message

missing target for route

What it means

This is a runtime guard in the Route task's RenderAWS (create path): when building the CreateRouteInput, none of the target fields (EgressOnlyInternetGateway, InternetGateway, NatGateway, TransitGatewayID, VPCPeeringConnectionID) are set, so the request cannot be populated. Normally CheckChanges catches this earlier; reaching it means the task bypassed validation or the field was mutated.

Source

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

	}
	return nil
}

func (_ *Route) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Route) error {
	ctx := context.TODO()
	if a == nil {
		request := &ec2.CreateRouteInput{}
		request.RouteTableId = checkNotNil(e.RouteTable.ID)

		if e.CIDR != nil || e.IPv6CIDR != nil {
			request.DestinationCidrBlock = e.CIDR
			request.DestinationIpv6CidrBlock = e.IPv6CIDR
		} else {
			klog.Fatal("both CIDR and IPv6CIDR were unexpectedly nil")
		}

		if e.EgressOnlyInternetGateway == nil && e.InternetGateway == nil && e.NatGateway == nil && e.TransitGatewayID == nil && e.VPCPeeringConnectionID == nil {
			return fmt.Errorf("missing target for route")
		} else if e.EgressOnlyInternetGateway != nil {
			request.EgressOnlyInternetGatewayId = checkNotNil(e.EgressOnlyInternetGateway.ID)
		} else if e.InternetGateway != nil {
			request.GatewayId = checkNotNil(e.InternetGateway.ID)
		} else if e.NatGateway != nil {
			request.NatGatewayId = checkNotNil(e.NatGateway.ID)
		} else if e.TransitGatewayID != nil {
			request.TransitGatewayId = e.TransitGatewayID
		} else if e.VPCPeeringConnectionID != nil {
			request.VpcPeeringConnectionId = e.VPCPeeringConnectionID
		}

		if e.Instance != nil {
			request.InstanceId = checkNotNil(e.Instance.ID)
		}

		klog.V(2).Infof("Creating Route with RouteTable:%q CIDR:%q IPv6CIDR:%q",
			aws.ToString(e.RouteTable.ID), aws.ToString(e.CIDR), aws.ToString(e.IPv6CIDR))

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure one route target field is populated in the cluster spec
  2. Run kops with current version to guarantee CheckChanges runs before RenderAWS
  3. Check that no newer kops removed/renamed the target field in your manifest, silently dropping it

Example fix

// before
route:
  cidr: 10.0.0.0/8
// after
route:
  cidr: 10.0.0.0/8
  natGateway: nat-0abc123
Defensive patterns

Strategy: validation

Validate before calling

// same target check as CheckChanges, run before constructing the task
if !hasRouteTarget(route) { return errors.New("missing target for route") }

Prevention

When it happens

Trigger: RenderAWS executing with all route targets nil while CIDR or IPv6CIDR is set — e.g. validation skipped or task state changed between check and apply.

Common situations: Programmatic task construction that skips CheckChanges; applying a partially deserialized manifest where target fields were dropped by unknown-field pruning.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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