From 4108fda4a852ae7297d09c6397d717fbf5be4772 Mon Sep 17 00:00:00 2001 From: Kelsey Hightower Date: Sun, 11 Sep 2016 04:08:38 -0700 Subject: [PATCH] add support for aws --- docs/07-network.md | 65 ++++++++++++++++++++++++++++++++++++---------- docs/10-cleanup.md | 2 +- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/docs/07-network.md b/docs/07-network.md index 9f5b18b..c71b762 100644 --- a/docs/07-network.md +++ b/docs/07-network.md @@ -2,18 +2,6 @@ Now that each worker node is online we need to add routes to make sure that Pods running on different machines can talk to each other. In this lab we are not going to provision any overlay networks and instead rely on Layer 3 networking. That means we need to add routes to our router. In GCP each network has a router that can be configured. If this was an on-prem datacenter then ideally you would need to add the routes to your local router. -After completing this lab you will have the following router entries: - -``` -$ gcloud compute routes list --filter "network=kubernetes" -``` -``` -NAME NETWORK DEST_RANGE NEXT_HOP PRIORITY -kubernetes-route-10-200-0-0-24 kubernetes 10.200.0.0/24 10.240.0.30 1000 -kubernetes-route-10-200-1-0-24 kubernetes 10.200.1.0/24 10.240.0.31 1000 -kubernetes-route-10-200-2-0-24 kubernetes 10.200.2.0/24 10.240.0.32 1000 -``` - ## Get the Routing Table The first thing we need to do is gather the information required to populate the router table. We need the Internal IP address and Pod Subnet for each of the worker nodes. @@ -33,7 +21,9 @@ Output: 10.240.0.32 10.200.2.0/24 ``` -Use `gcloud` to add the routes to GCP: +## Create Routes + +### GCP ``` gcloud compute routes create kubernetes-route-10-200-0-0-24 \ @@ -54,4 +44,51 @@ gcloud compute routes create kubernetes-route-10-200-2-0-24 \ --network kubernetes \ --next-hop-address 10.240.0.32 \ --destination-range 10.200.2.0/24 -``` \ No newline at end of file +``` + +### AWS + +``` +ROUTE_TABLE_ID=$(aws ec2 describe-route-tables \ + --filters "Name=tag:Name,Values=kubernetes" | \ + jq -r '.RouteTables[].RouteTableId') +``` + +``` +WORKER_0_INSTANCE_ID=$(aws ec2 describe-instances \ + --filters "Name=tag:Name,Values=worker0" | \ + jq -j '.Reservations[].Instances[].InstanceId') +``` + +``` +aws ec2 create-route \ + --route-table-id ${ROUTE_TABLE_ID} \ + --destination-cidr-block 10.200.0.0/24 \ + --instance-id ${WORKER_0_INSTANCE_ID} +``` + +``` +WORKER_1_INSTANCE_ID=$(aws ec2 describe-instances \ + --filters "Name=tag:Name,Values=worker1" | \ + jq -j '.Reservations[].Instances[].InstanceId') +``` + +``` +aws ec2 create-route \ + --route-table-id ${ROUTE_TABLE_ID} \ + --destination-cidr-block 10.200.1.0/24 \ + --instance-id ${WORKER_1_INSTANCE_ID} +``` + +``` +WORKER_2_INSTANCE_ID=$(aws ec2 describe-instances \ + --filters "Name=tag:Name,Values=worker2" | \ + jq -j '.Reservations[].Instances[].InstanceId') +``` + +``` +aws ec2 create-route \ + --route-table-id ${ROUTE_TABLE_ID} \ + --destination-cidr-block 10.200.2.0/24 \ + --instance-id ${WORKER_2_INSTANCE_ID} +``` diff --git a/docs/10-cleanup.md b/docs/10-cleanup.md index 0b3b421..c17d5ab 100644 --- a/docs/10-cleanup.md +++ b/docs/10-cleanup.md @@ -59,7 +59,7 @@ gcloud compute networks delete kubernetes ## AWS -### VMs +### Virtual Machines ``` KUBERNETES_HOSTS=(controller0 controller1 controller2 etcd0 etcd1 etcd2 worker0 worker1 worker2)