|
1 | | -export KUBE_AWS_ZONE=us-west-2a |
| 1 | +# Booting Kubernetes on Amazon Elastic Compute |
| 2 | + |
| 3 | +Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides compute capacity in the cloud. This quickstart |
| 4 | +guide uses AWS EC2 to boot a Kubernetes cluster using the open source provisioning scripts. |
| 5 | + |
| 6 | +## Pre-requisites |
| 7 | + |
| 8 | +1. You need an active AWS account. Visit [](http://aws.amazon.com) to sign up |
| 9 | +2. You need AWS API keys with full access |
| 10 | +3. Install the AWS cli tools, you can find instructions for your platform at [](https://aws.amazon.com/cli/) |
| 11 | + |
| 12 | +To verify that your CLI is configured properly, run `aws ec2 describe-regions`: |
| 13 | + |
| 14 | +``` |
| 15 | +$ aws ec2 describe-regions |
| 16 | +REGIONS ec2.eu-west-1.amazonaws.com eu-west-1 |
| 17 | +REGIONS ec2.ap-southeast-1.amazonaws.com ap-southeast-1 |
| 18 | +REGIONS ec2.ap-southeast-2.amazonaws.com ap-southeast-2 |
| 19 | +REGIONS ec2.eu-central-1.amazonaws.com eu-central-1 |
| 20 | +REGIONS ec2.ap-northeast-2.amazonaws.com ap-northeast-2 |
| 21 | +REGIONS ec2.ap-northeast-1.amazonaws.com ap-northeast-1 |
| 22 | +REGIONS ec2.us-east-1.amazonaws.com us-east-1 |
| 23 | +REGIONS ec2.sa-east-1.amazonaws.com sa-east-1 |
| 24 | +REGIONS ec2.us-west-1.amazonaws.com us-west-1 |
| 25 | +REGIONS ec2.us-west-2.amazonaws.com us-west-2 |
| 26 | +``` |
| 27 | + |
| 28 | +## Configure the Kubernetes Environment |
| 29 | + |
| 30 | +Before calling the Kubernetes setup scripts, we need to change a few defaults so that Deis Workflow works best. Type |
| 31 | +each of these commands into your terminal application before calling `curl -sS https://get.k8s.io | bash`. |
| 32 | + |
| 33 | +First, enable insecure registry support for Docker: |
| 34 | +``` |
| 35 | +$ export KUBE_ENABLE_INSECURE_REGISTRY=true |
| 36 | +``` |
| 37 | + |
| 38 | +Next, pick the AWS Availability Zone you would like to use. The boot script will create a new VPC in that region. |
| 39 | + |
| 40 | +``` |
| 41 | +export KUBE_AWS_ZONE=us-west-1c |
2 | 42 | export KUBERNETES_PROVIDER=aws |
3 | | -export KUBE_ENABLE_INSECURE_REGISTRY=true |
| 43 | +``` |
| 44 | + |
| 45 | +For evaluation, we find that the t2 instance classes are a reasonable bang for the buck. Do note that the t2 class does |
| 46 | +track CPU credits. Performance of your evaluation cluster may be impacted when you exhaust the CPU credit limit. Select |
| 47 | +your instance sizes and worker count. |
| 48 | + |
| 49 | +``` |
4 | 50 | export MASTER_SIZE=t2.medium |
5 | 51 | export NODE_SIZE=t2.large |
6 | 52 | export NUM_NODES=2 |
7 | 53 | export MINION_ROOT_DISK_SIZE=100 |
| 54 | +``` |
| 55 | + |
| 56 | +Last, so you can easily identify instances in the AWS Console, specify an instance prefix: |
| 57 | +``` |
| 58 | +export INSTANCE_PREFIX=first-k8s |
| 59 | +``` |
| 60 | + |
| 61 | +## Boot Your First Cluster |
| 62 | + |
| 63 | +We are now ready to boot our first Kubernetes cluster on AWS! |
| 64 | + |
| 65 | +Since this script does a **lot** of stuff, we'll break it into sections. |
| 66 | + |
| 67 | +``` |
| 68 | +$ curl -sS https://get.k8s.io | bash |
| 69 | +Downloading kubernetes release v1.2.4 to /Users/jhansen/p/docs/kubernetes.tar.gz |
| 70 | +--2016-05-11 15:31:14-- https://storage.googleapis.com/kubernetes-release/release/v1.2.4/kubernetes.tar.gz |
| 71 | +Resolving storage.googleapis.com... 216.58.194.208, 2607:f8b0:4005:805::2010 |
| 72 | +Connecting to storage.googleapis.com|216.58.194.208|:443... connected. |
| 73 | +HTTP request sent, awaiting response... 200 OK |
| 74 | +Length: 496696744 (474M) [application/x-tar] |
| 75 | +Saving to: 'kubernetes.tar.gz' |
| 76 | +
|
| 77 | +kubernetes.tar.gz 100%[============================================================================>] 473.69M 2.16MB/s in 4m 37s |
| 78 | +
|
| 79 | +2016-05-11 15:35:50 (1.71 MB/s) - 'kubernetes.tar.gz' saved [496696744/496696744] |
| 80 | +
|
| 81 | +Unpacking kubernetes release v1.2.4 |
| 82 | +
|
| 83 | +Creating a kubernetes on aws... |
| 84 | +... Starting cluster in us-west-1c using provider aws |
| 85 | +... calling verify-prereqs |
| 86 | +... calling kube-up |
| 87 | +Starting cluster using os distro: jessie |
| 88 | +Uploading to Amazon S3 |
| 89 | ++++ Staging server tars to S3 Storage: kubernetes-staging-52e3410afddda7a4600f10ee5b1e43fb/devel |
| 90 | +upload: |
| 91 | +Uploaded server tars: |
| 92 | + SERVER_BINARY_TAR_URL: ... |
| 93 | + SALT_TAR_URL: ... |
| 94 | + BOOTSTRAP_SCRIPT_URL: ... |
| 95 | +``` |
| 96 | + |
| 97 | +Here, we have downloaded the Kubernetes release archive and started the process of cluster provisioning. Release |
| 98 | +artifacts are automatically pushed to S3 for use by machines as they are provisioned. |
| 99 | + |
| 100 | +``` |
| 101 | +Using SSH key with (AWS) fingerprint: 32:5b:38:76:e6:e8:6e:ae:98:5d:8c:1f:3b:4e:8d:6c |
| 102 | +Creating vpc. |
| 103 | +Using VPC vpc-11672d74 |
| 104 | +Using DHCP option set dopt-d78907b2 |
| 105 | +Creating subnet. |
| 106 | +Using subnet subnet-2b632072 |
| 107 | +Creating Internet Gateway. |
| 108 | +Using Internet Gateway igw-2943f94c |
| 109 | +Associating route table. |
| 110 | +Creating route table |
| 111 | +Associating route table rtb-0cc5eb69 to subnet subnet-2b632072 |
| 112 | +Adding route to route table rtb-0cc5eb69 |
| 113 | +Using Route Table rtb-0cc5eb69 |
| 114 | +Creating master security group. |
| 115 | +Creating security group kubernetes-master-kubernetes. |
| 116 | +Creating minion security group. |
| 117 | +Creating security group kubernetes-minion-kubernetes. |
| 118 | +Using master security group: kubernetes-master-kubernetes sg-a3bf1cc7 |
| 119 | +Using minion security group: kubernetes-minion-kubernetes sg-acbf1cc8 |
| 120 | +Creating master disk: size 20GB, type gp2 |
| 121 | +Allocated Elastic IP for master: 52.9.206.49 |
| 122 | +Generating certs for alternate-names: IP:52.9.206.49,IP:172.20.0.9,IP:10.0.0.1,DNS:kubernetes,DNS:kubernetes.default,DNS:kubernetes.default.svc,DNS:kubernetes.default.svc.cluster.local,DNS:kubernetes-master |
| 123 | +``` |
| 124 | + |
| 125 | +Next, the VPC is provisioned with all of the necessary bits including security groups, route tables, subnets and |
| 126 | +internet gateways. |
| 127 | + |
| 128 | +``` |
| 129 | +Starting Master |
| 130 | +Waiting for master to be ready |
| 131 | +Attempt 1 to check for master nodeWaiting for instance i-629517d7 to be running (currently pending) |
| 132 | +Sleeping for 3 seconds... |
| 133 | +Waiting for instance i-629517d7 to be running (currently pending) |
| 134 | +Sleeping for 3 seconds... |
| 135 | + [master running] |
| 136 | +Attaching IP 52.9.206.49 to instance i-629517d7 |
| 137 | +Attaching persistent data volume (vol-1e605fa3) to master |
| 138 | +2016-05-11T23:15:38.845Z /dev/sdb i-629517d7 attaching vol-1e605fa3 |
| 139 | +``` |
| 140 | + |
| 141 | +Now that the master instance has booted, the script automatically configures your `kubectl` tool with appropriate |
| 142 | +authentication and endpoint information. |
| 143 | + |
| 144 | +``` |
| 145 | +cluster "aws_kubernetes" set. |
| 146 | +user "aws_kubernetes" set. |
| 147 | +context "aws_kubernetes" set. |
| 148 | +switched to context "aws_kubernetes". |
| 149 | +user "aws_kubernetes-basic-auth" set. |
| 150 | +Wrote config for aws_kubernetes to /Users/jhansen/.kube/config |
| 151 | +``` |
| 152 | + |
| 153 | +Up next, worker nodes are provisioned by an auto-scaling group, and we wait for those nodes to come up. |
| 154 | + |
| 155 | +``` |
| 156 | +Creating minion configuration |
| 157 | +Creating autoscaling group |
| 158 | + 0 minions started; waiting |
| 159 | + 0 minions started; waiting |
| 160 | + 0 minions started; waiting |
| 161 | + 0 minions started; waiting |
| 162 | + 1 minions started; waiting |
| 163 | + 1 minions started; waiting |
| 164 | + 1 minions started; waiting |
| 165 | + 2 minions started; ready |
| 166 | +Waiting for cluster initialization. |
| 167 | +
|
| 168 | + This will continually check to see if the API for kubernetes is reachable. |
| 169 | + This might loop forever if there was some uncaught error during start |
| 170 | + up. |
| 171 | +Waiting for cluster initialization. |
| 172 | +
|
| 173 | + This will continually check to see if the API for kubernetes is reachable. |
| 174 | + This might loop forever if there was some uncaught error during start |
| 175 | + up. |
| 176 | +
|
| 177 | +.................................................................................................................Kubernetes cluster created. |
| 178 | +Sanity checking cluster... |
| 179 | +Attempt 1 to check Docker on node @ 52.53.207.230 ...working |
| 180 | +Attempt 1 to check Docker on node @ 52.53.172.73 ...working |
| 181 | +``` |
| 182 | + |
| 183 | +After these nodes come up, you are almost ready to go! |
| 184 | + |
| 185 | +``` |
| 186 | +Kubernetes cluster is running. The master is running at: |
| 187 | +
|
| 188 | + https://52.9.206.49 |
| 189 | +
|
| 190 | +The user name and password to use is located in /Users/jhansen/.kube/config. |
| 191 | +
|
| 192 | +... calling validate-cluster |
| 193 | +Waiting for 2 ready nodes. 0 ready nodes, 1 registered. Retrying. |
| 194 | +Waiting for 2 ready nodes. 0 ready nodes, 1 registered. Retrying. |
| 195 | +Waiting for 2 ready nodes. 0 ready nodes, 1 registered. Retrying. |
| 196 | +Waiting for 2 ready nodes. 1 ready nodes, 1 registered. Retrying. |
| 197 | +Waiting for 2 ready nodes. 1 ready nodes, 2 registered. Retrying. |
| 198 | +Waiting for 2 ready nodes. 1 ready nodes, 2 registered. Retrying. |
| 199 | +Found 2 node(s). |
| 200 | +NAME STATUS AGE |
| 201 | +ip-172-20-0-192.us-west-1.compute.internal Ready 36s |
| 202 | +ip-172-20-0-193.us-west-1.compute.internal Ready 1m |
| 203 | +Flag --api-version has been deprecated, flag is no longer respected and will be deleted in the next release |
| 204 | +Validate output: |
| 205 | +NAME STATUS MESSAGE ERROR |
| 206 | +scheduler Healthy ok |
| 207 | +controller-manager Healthy ok |
| 208 | +etcd-0 Healthy {"health": "true"} |
| 209 | +etcd-1 Healthy {"health": "true"} |
| 210 | +Cluster validation succeeded |
| 211 | +Done, listing cluster services: |
| 212 | +
|
| 213 | +Kubernetes master is running at https://52.9.206.49 |
| 214 | +Elasticsearch is running at https://52.9.206.49/api/v1/proxy/namespaces/kube-system/services/elasticsearch-logging |
| 215 | +Heapster is running at https://52.9.206.49/api/v1/proxy/namespaces/kube-system/services/heapster |
| 216 | +Kibana is running at https://52.9.206.49/api/v1/proxy/namespaces/kube-system/services/kibana-logging |
| 217 | +KubeDNS is running at https://52.9.206.49/api/v1/proxy/namespaces/kube-system/services/kube-dns |
| 218 | +kubernetes-dashboard is running at https://52.9.206.49/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard |
| 219 | +Grafana is running at https://52.9.206.49/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana |
| 220 | +InfluxDB is running at https://52.9.206.49/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb |
| 221 | +
|
| 222 | +Kubernetes binaries at /Users/jhansen/p/docs/kubernetes/cluster/ |
| 223 | +You may want to add this directory to your PATH in $HOME/.profile |
| 224 | +Installation successful! |
| 225 | +``` |
| 226 | + |
| 227 | +## Items of note! |
| 228 | + |
| 229 | +A few things to note! Your Kubernetes master is now up and running and we are ready to install Deis Workflow. If you |
| 230 | +need to access the Kubernetes master the default username is `admin` and the ssh key lives at `~/.ssh/kube_aws_rsa`. |
| 231 | + |
| 232 | + |
| 233 | +``` |
| 234 | +$ ssh -i ~/.ssh/kube_aws_rsa admin@52.9.206.49 |
| 235 | +
|
| 236 | +Welcome to Kubernetes v1.2.4! |
| 237 | +
|
| 238 | +You can find documentation for Kubernetes at: |
| 239 | + http://docs.kubernetes.io/ |
| 240 | +
|
| 241 | +You can download the build image for this release at: |
| 242 | + https://storage.googleapis.com/kubernetes-release/release/v1.2.4/kubernetes-src.tar.gz |
| 243 | +
|
| 244 | +It is based on the Kubernetes source at: |
| 245 | + https://github.com/kubernetes/kubernetes/tree/v1.2.4 |
8 | 246 |
|
9 | | -kube-up.sh |
| 247 | +For Kubernetes copyright and licensing information, see: |
| 248 | + /usr/local/share/doc/kubernetes/LICENSES |
10 | 249 |
|
11 | | -exit criteria, kubectl should be working and pointed at the cluster |
| 250 | +admin@ip-172-20-0-9:~$ |
| 251 | +``` |
12 | 252 |
|
13 | | -[next install workflow](install-aws.md) |
| 253 | +You are now ready to [install Deis Workflow](install-aws.md) |
0 commit comments