github.com/chasestarr/deis@v1.13.5-0.20170519182049-1d9e59fbdbfc/docs/installing_deis/aws.rst (about) 1 :title: Installing Deis on AWS 2 :description: How to provision a multi-node Deis cluster on Amazon AWS 3 4 .. _deis_on_aws: 5 6 Amazon AWS 7 ========== 8 9 In this tutorial, we will show you how to set up your own 3-node cluster on Amazon Web Services. 10 11 Please :ref:`get the source <get_the_source>` and refer to the scripts in `contrib/aws`_ 12 while following this documentation. You will also need to :ref:`install_deisctl` since the 13 ``deisctl`` command-line utility is used by the provisioning script. 14 15 Install the AWS Command Line Interface 16 -------------------------------------- 17 18 In order to start working with Amazon's API, let's install `awscli`_: 19 20 .. code-block:: console 21 22 $ pip install awscli 23 24 We'll also need `PyYAML`_ for the Deis AWS provision script to run: 25 26 .. code-block:: console 27 28 $ pip install pyyaml 29 30 31 Configure aws-cli 32 ----------------- 33 34 Run ``aws configure`` to set your AWS credentials: 35 36 .. code-block:: console 37 38 $ aws configure 39 AWS Access Key ID [None]: *************** 40 AWS Secret Access Key [None]: ************************ 41 Default region name [None]: us-west-1 42 Default output format [None]: 43 44 45 Upload keys 46 ----------- 47 48 Generate and upload a new keypair to AWS, ensuring that the name of the keypair is set to "deis". 49 50 .. code-block:: console 51 52 $ ssh-keygen -q -t rsa -f ~/.ssh/deis -N '' -C deis 53 $ aws ec2 import-key-pair --key-name deis --public-key-material file://~/.ssh/deis.pub 54 55 56 During installation, ``deisctl`` will make an SSH connection to the cluster. 57 It will need to be able to use this key to connect. 58 59 Most users use SSH agent (``ssh-agent``). If this is the case, run 60 ``ssh-add ~/.ssh/deis`` to add the key. Otherwise, you may prefer to 61 modify ``~/.ssh/config`` to add the key to the IPs in AWS. 62 63 Choose Number of Instances 64 -------------------------- 65 66 By default, the script will provision 3 servers. You can override this by setting 67 ``DEIS_NUM_INSTANCES``: 68 69 .. code-block:: console 70 71 $ export DEIS_NUM_INSTANCES=5 72 73 A Deis cluster must have 3 or more nodes. See :ref:`cluster-size` for more details. 74 75 76 Generate a New Discovery URL 77 ---------------------------- 78 79 .. include:: ../_includes/_generate-discovery-url.rst 80 81 82 Customize cloudformation.json 83 ----------------------------- 84 85 The configuration files and templates for AWS are located in the directory 86 ``contrib/aws/`` in the Deis repository. 87 88 Any of the parameter defaults defined in ``deis.template.json`` can be 89 overridden by setting the value in `cloudformation.json`_. For example, to 90 configure all of the options to non-default values: 91 92 .. code-block:: console 93 94 { 95 "ParameterKey": "InstanceType", 96 "ParameterValue": "m3.xlarge" 97 }, 98 { 99 "ParameterKey": "KeyPair", 100 "ParameterValue": "jsmith" 101 }, 102 { 103 "ParameterKey": "EC2VirtualizationType", 104 "ParameterValue": "PV" 105 }, 106 { 107 "ParameterKey": "AssociatePublicIP", 108 "ParameterValue": "false" 109 }, 110 { 111 "ParameterKey": "ELBScheme", 112 "ParameterValue": "internal" 113 }, 114 { 115 "ParameterKey": "RootVolumeSize", 116 "ParameterValue": "100" 117 }, 118 { 119 "ParameterKey": "DockerVolumeSize", 120 "ParameterValue": "1000" 121 }, 122 { 123 "ParameterKey": "EtcdVolumeSize", 124 "ParameterValue": "5" 125 } 126 127 128 The only entry in cloudformation.json required to launch your cluster is `KeyPair`, which is 129 already filled out. The defaults will be applied for the other settings. The default values are 130 defined in ``deis.template.json``. 131 132 If updated with ``update-aws-cluster.sh``, the InstanceType will only impact newly deployed instances 133 (`#1758`_). 134 135 NOTE: The smallest recommended instance size is ``large``. Having not enough CPU or RAM will result 136 in numerous issues when using the cluster. 137 138 139 Launch into an existing VPC 140 --------------------------- 141 142 By default, the provided CloudFormation script will create a new VPC for Deis. However, the script 143 supports provisioning into an existing VPC instead. You'll need to have a VPC configured with an 144 internet gateway and a sane routing table (the default VPC in a region should be ready to go). 145 146 To launch your cluster into an existing VPC, export three additional environment variables: 147 148 - ``VPC_ID`` 149 - ``VPC_SUBNETS`` 150 - ``VPC_ZONES`` 151 152 ``VPC_ZONES`` must list the availability zones of the subnets in order. 153 154 For example, if your VPC has ID ``vpc-a26218bf`` and consists of the subnets ``subnet-04d7f942`` 155 (which is in ``us-east-1b``) and ``subnet-2b03ab7f`` (which is in ``us-east-1c``) you would export: 156 157 .. code-block:: console 158 159 export VPC_ID=vpc-a26218bf 160 export VPC_SUBNETS=subnet-04d7f942,subnet-2b03ab7f 161 export VPC_ZONES=us-east-1b,us-east-1c 162 163 If you have set up private subnets in which you'd like to run your Deis hosts, and public subnets 164 for the ELB, you should export the following environment variables instead: 165 166 - ``VPC_ID`` 167 - ``VPC_SUBNETS`` 168 - ``VPC_PRIVATE_SUBNETS`` 169 - ``VPC_ZONES`` 170 171 For example, if you have a public subnet ``subnet-8cd457b3`` for the ELB and a private subnet 172 ``subnet-8cd457b0`` (both in ``us-east-1a``) you would export: 173 174 .. code-block:: console 175 176 export VPC_ID=vpc-a26218bf 177 export VPC_SUBNETS=subnet-8cd457b3 178 export VPC_PRIVATE_SUBNETS=subnet-8cd457b0 179 export VPC_ZONES=us-east-1a 180 181 182 Run the Provision Script 183 ------------------------ 184 185 Run the cloudformation provision script to spawn a new CoreOS cluster: 186 187 .. code-block:: console 188 189 $ cd contrib/aws 190 $ ./provision-aws-cluster.sh 191 Creating CloudFormation stack deis 192 { 193 "StackId": "arn:aws:cloudformation:us-east-1:69326027886:stack/deis/1e9916b0-d7ea-11e4-a0be-50d2020578e0" 194 } 195 Waiting for instances to be created... 196 Waiting for instances to be created... CREATE_IN_PROGRESS 197 Waiting for instances to pass initial health checks... 198 Waiting for instances to pass initial health checks... 199 Waiting for instances to pass initial health checks... 200 Instances are available: 201 i-5c3c91aa 203.0.113.91 m3.large us-east-1a running 202 i-403c91b6 203.0.113.20 m3.large us-east-1a running 203 i-e36fc6ee 203.0.113.31 m3.large us-east-1b running 204 Using ELB deis-DeisWebE-17PGCR3KPJC54 at deis-DeisWebE-17PGCR3KPJC54-1499385382.us-east-1.elb.amazonaws.com 205 Your Deis cluster has been successfully deployed to AWS CloudFormation and is started. 206 Please continue to follow the instructions in the documentation. 207 208 .. note:: 209 210 The default name of the CloudFormation stack will be ``deis``. You can specify a different name 211 with ``./provision-aws-cluster.sh <name>``. 212 213 Remote IPs behind your ELB 214 -------------------------- 215 216 The ELB you just created is load-balancing raw TCP connections, which is required for custom domain SSL 217 and WebSockets. As remote IPs are by default not visible behind a TCP-Proxy, the ELB and your cluster routers 218 were created with `Proxy Protocol`_ enabled. 219 220 221 Configure DNS 222 ------------- 223 224 You will need a DNS entry that points to the ELB instance created above. Find 225 the ELB name in the AWS web console or by running ``aws elb describe-load-balancers`` 226 and finding the Deis ELB. 227 228 See :ref:`configure-dns` for more information on properly setting up your DNS records with Deis. 229 230 231 Install Deis Platform 232 --------------------- 233 234 Now that you've finished provisioning a cluster, please refer to :ref:`install_deis_platform` to 235 start installing the platform. 236 237 In case of failures 238 ------------------- 239 240 Though it is uncommon, provisioning may fail for a few reasons. In these cases, 241 ``provision-aws-cluster.sh`` will automatically attempt to rollback its changes. 242 243 If it fails to do so, you can clean up the AWS resources manually. Do this by logging into the AWS 244 console, and under CloudFormation, simply delete the ``deis`` stack it created. 245 246 If you wish to retry, you'll need to take note of a few caveats: 247 248 - The ``deis`` CloudFormation stack may be in the process of being deleted. In this case, you can't 249 provision another CloudFormation stack with the same name. You can simply wait for the stack to 250 clean itself up, or provision a stack under a different name by doing ``./provision-aws-cluster.sh 251 <newname>``. 252 253 - In most cases, it's not a good idea to re-use the same discovery URL of a failed provisioning. 254 Generate a new discovery URL before attempting to provision a new stack. 255 256 CloudFormation Updates 257 ---------------------- 258 259 To use CloudFormation to perform update operations to your stack, there is another script: 260 `update-aws-cluster.sh`_. Depending on the parameters that you have changed, CloudFormation 261 may replace the EC2 instances in your stack. 262 263 The following parameters can be changed without replacing all instances in a stack: 264 265 - ``ClusterSize`` - Number of nodes in the cluster. This may launch new instances or terminate 266 existing instances. If you are scaling down, this may interrupt service. If a container 267 was running on an instance that was terminated, it will have to be rebalanced onto another 268 node which will cause some downtime. 269 - ``SSHFrom`` - Locks down SSH access to the Deis hosts. This will update the security 270 group for the Deis hosts. 271 272 Please reference the AWS documentation for `more information about CloudFormation stack updates`_. 273 274 .. _`#1758`: https://github.com/deis/deis/issues/1758 275 .. _`awscli`: https://github.com/aws/aws-cli 276 .. _`contrib/aws`: https://github.com/deis/deis/tree/master/contrib/aws 277 .. _`cloudformation.json`: https://github.com/deis/deis/blob/master/contrib/aws/cloudformation.json 278 .. _`etcd`: https://github.com/coreos/etcd 279 .. _`etcd disaster recovery`: https://github.com/coreos/etcd/blob/master/Documentation/admin_guide.md#disaster-recovery 280 .. _`PyYAML`: http://pyyaml.org/ 281 .. _`update-aws-cluster.sh`: https://github.com/deis/deis/blob/master/contrib/aws/update-aws-cluster.sh 282 .. _`More information about CloudFormation stack updates`: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html 283 .. _`Proxy Protocol`: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/enable-proxy-protocol.html