kops icon indicating copy to clipboard operation
kops copied to clipboard

FailedToCreateRoute when using shared subnets on a shared VPC

Open vellichor opened this issue 7 years ago • 6 comments

1. What kops version are you running? The command kops version, will display this information. kops 1.11.1

2. What Kubernetes version are you running? kubectl version will print the version if a cluster is running or provide the Kubernetes version specified as a kops flag. kubernetes v1.11.7

3. What cloud provider are you using? AWS

4. What commands did you run? What is the simplest way to reproduce this issue?

  • Build a gossip-based kops cluster configuration into a shared VPC with multiple existing subnets kops create cluster --node-count=1 --node-size=t2.medium --zones=us-west-2c --name=${KOPS_CLUSTER_NAME} --vpc vpc-xxxxxxxx

  • Before creating the cluster, edit the newly created config to set an existing shared subnet for the nodes to use.

    subnets:
    - cidr: 172.31.0.0/20
      id: subnet-xxxxxxxx
      name: us-west-2c
      type: Public
      zone: us-west-2c
    
  • Create the cluster. kops update cluster <cluster-name> --yes

  • The cluster is created but pod DNS doesn't work, and on investigation we find that kube-controller-manager-ip has failed to come up: E0318 07:39:41.092486 1 route_controller.go:120] Couldn't reconcile node routes: error listing routes: unable to find route table for AWS cluster: <cluster-tag>.k8s.local

  • Relating to https://github.com/kubernetes/kops/issues/5236 and https://github.com/kubernetes/kops/issues/4691, we are now in a situation where we must manually tag the route table. However, since we are using kubernetes 1.11.7 and we intend to have multiple clusters share this subnet, we use new-style tags per this document: https://github.com/kubernetes/kops/blob/master/docs/run_in_existing_vpc.md

    Specifically,

    Prior to kops 1.8 KubernetesCluster tag was used instead of kubernetes.io/cluster/<cluster-name>. This lead to several problems if there were more than one Kubernetes Cluster in a subnet. After you upgraded to kops 1.8 ensure the KubernetesCluster Tag is removed from subnets otherwise kubernetes.io/cluster/<clustername> won't have any effect!

5. What happened after the commands executed?

After the commands executed, we received a new error from kube-controller-manager-ip:

I0318 08:00:21.888129 1 event.go:221] Event(v1.ObjectReference{Kind:"Node", Namespace:"", Name:"ip-172-31-2-134.us-west-2.compute.internal", UID:"ip-172-31-2-134.us-west-2.compute.internal", APIVersion:"", ResourceVersion:"", FieldPath:""}): type: 'Warning' reason: 'FailedToCreateRoute' Could not create route d8078138-494f-11e9-a259-0a23b366f3cc 100.96.1.0/24 for node ip-172-31-2-134.us-west-2.compute.internal after 574.319137ms: error creating AWS route (100.96.1.0/24): "UnauthorizedOperation: You are not authorized to perform this operation. Encoded authorization failure message: v_GaAf0dEFnzGB7jPls_rdUy0Q85xcJ2mn6Uxnh8gkGGx3w5awaI6xfg2zvEZt-JgcOG3RfJw8QiPsXgVnbquuKHsTbRh6BZZIp22liIl_J4nSUKgcduf6PQ6KBqGWHo9cAbpWrrf2isvt4ivE8zFo2RVHTwdnH8FrReUXuRUHOMF2TDMjfolq9il7XuimjOwsYLseI2sLo7mmWYLvgDb0l013NBYJsOgaUHTm5TL7v0I5n3JgqzAABdNGRdSOLYy6mFiNWAhEsLjkAQOKt8zbCVk7s60Jpu72lOWHgR2BqDBAXvwKP7Op_PV3mM1_Cr4HpsmnI0P3XGD-vTa3xqEdNrF1ZYbKHLjtAbRK-r1MWcB3Pe8ouu043sT1iMuHrMjZ4MMzn0eXJ3p5_IdGrsPzcG5RB09RToKObgnwDiP85R_VsA7ujzvALce8giq-o_NYAbQJGAdtbYi2Fyd4epZJqK3iMMe0kI44x-b_t_5m85rMPoky3E5E9NsrIZvjg9jNC2JnUxwhBhsdXcLo7CJJBm4FvW_JYixdRNwF4xvxUNIH5seeY8REeB6J1k8CSDHUqZqam6TwIpSs96GNIsgyTcOwd654mfEh6xniOfdv2vFUa5rX2t6ZCtCzxf5kbJSvEDkb5-kEw73FvXlM3AxHaTzA\n\tstatus code: 403, request id: 5edb2882-19c2-4efa-b75c-30caa0fc73c6"

6. What did you expect to happen?

We expected kube-controller-manager-ip to finish creating routes and become healthy.

7. Please provide your cluster manifest. Execute kops get --name my.example.com -o yaml to display your cluster manifest. You may want to remove your cluster name and other sensitive information.

kind: Cluster
metadata:
  creationTimestamp: 2019-03-18T07:23:32Z
  name: <cluster-name>
spec:
  api:
    loadBalancer:
      type: Public
  authorization:
    rbac: {}
  channel: stable
  cloudProvider: aws
  configBase: s3://<state-store>/<cluster-name>
  etcdClusters:
  - etcdMembers:
    - instanceGroup: master-us-west-2c
      name: c
    name: main
  - etcdMembers:
    - instanceGroup: master-us-west-2c
      name: c
    name: events
  iam:
    allowContainerRegistry: true
    legacy: false
  kubelet:
    anonymousAuth: false
  kubernetesApiAccess:
  - 0.0.0.0/0
  kubernetesVersion: 1.11.7
  masterInternalName: api.internal.<cluster-name>
  masterPublicName: api.<cluster-name>
  networkCIDR: 172.31.0.0/16
  networkID: vpc-xxxxxxxx
  networking:
    kubenet: {}
  nonMasqueradeCIDR: 100.64.0.0/10
  sshAccess:
  - 0.0.0.0/0
  subnets:
  - cidr: 172.31.0.0/20
    id: subnet-xxxxxxxx
    name: us-west-2c
    type: Public
    zone: us-west-2c
  topology:
    dns:
      type: Public
    masters: public
    nodes: public

---

apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
  creationTimestamp: 2019-03-18T07:23:34Z
  labels:
    kops.k8s.io/cluster: <cluster-name>
  name: master-us-west-2c
spec:
  image: kope.io/k8s-1.11-debian-stretch-amd64-hvm-ebs-2018-08-17
  machineType: m3.medium
  maxSize: 1
  minSize: 1
  nodeLabels:
    kops.k8s.io/instancegroup: master-us-west-2c
  role: Master
  subnets:
  - us-west-2c

---

apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
  creationTimestamp: 2019-03-18T07:23:35Z
  labels:
    kops.k8s.io/cluster: <cluster-name>
  name: nodes
spec:
  image: kope.io/k8s-1.11-debian-stretch-amd64-hvm-ebs-2018-08-17
  machineType: t2.medium
  maxSize: 1
  minSize: 1
  nodeLabels:
    kops.k8s.io/instancegroup: nodes
  role: Node
  subnets:
  - us-west-2c

8. Please run the commands with most verbose logging by adding the -v 10 flag. Paste the logs into this report, or in a gist and provide the gist link here.

9. Anything else do we need to know?

We found that the role policy for the cluster's AssumedRole was created with ec2:CreateRoute and ec2:DeleteRoute privileges pinned to resources with the legacy tag KubernetesCluster: <cluster-name> . We were able to cure the cluster issues by manually adjusting the role policy to look for the new-style tag kubernetes.io/cluster/<cluster-name> when selecting resources for these actions. We expect kops to do this itself.

I'm reporting this as a separate issue from https://github.com/kubernetes/kops/issues/4691 or https://github.com/kubernetes/kops/issues/5236 since it pertains specifically to the role policy/permissions and not to the route table tagging itself.

vellichor avatar Mar 18 '19 13:03 vellichor

@vellichor I injected the subnet info with the following fields privates

  - egress: nat-nattyBoomBoom
    id: subnet-xxxxxxxxxxxxxxxxx
    cidr: 10.22.32.0/20
    name: us-east-1c
    type: Private
    zone: us-east-1c

and for publics

  - id: subnet-zzzzzzzzzzzzzzzzz
    cidr: 10.22.255.0/26
    name: utility-us-east-1a
    type: Utility
    zone: us-east-1a

when i didn't have the CIDRs in there, the cluster came up without tagging the respective subnets. Perhaps without all fields specified, kops goes awry.

camilosantana avatar Jun 12 '19 23:06 camilosantana

also edited masterPublicName to reflect the LB public DNS as kops set it to the local gossip name

camilosantana avatar Jun 12 '19 23:06 camilosantana

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Sep 10 '19 23:09 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar Oct 11 '19 03:10 fejta-bot

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

fejta-bot avatar Nov 10 '19 03:11 fejta-bot

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Nov 10 '19 04:11 k8s-ci-robot