github.com/rvaralda/deis@v1.4.1/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/ec2`_
    12  while following this documentation.
    13  
    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 EC2 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  
    37  .. code-block:: console
    38  
    39      $ aws configure
    40      AWS Access Key ID [None]: ***************
    41      AWS Secret Access Key [None]: ************************
    42      Default region name [None]: us-west-1
    43      Default output format [None]:
    44  
    45  
    46  Upload keys
    47  -----------
    48  
    49  Generate and upload a new keypair to AWS, ensuring that the name of the keypair is set to "deis".
    50  
    51  .. code-block:: console
    52  
    53      $ ssh-keygen -q -t rsa -f ~/.ssh/deis -N '' -C deis
    54      $ aws ec2 import-key-pair --key-name deis --public-key-material file://~/.ssh/deis.pub
    55  
    56  
    57  Choose Number of Instances
    58  --------------------------
    59  
    60  By default, the script will provision 3 servers. You can override this by setting
    61  ``DEIS_NUM_INSTANCES``:
    62  
    63  .. code-block:: console
    64  
    65      $ export DEIS_NUM_INSTANCES=5
    66  
    67  Note that for scheduling to work properly, clusters must consist of at least 3 nodes and always
    68  have an odd number of members. For more information, see `etcd disaster recovery`_.
    69  
    70  Deis clusters of less than 3 nodes are unsupported.
    71  
    72  
    73  Generate a New Discovery URL
    74  ----------------------------
    75  
    76  .. include:: ../_includes/_generate-discovery-url.rst
    77  
    78  
    79  Customize cloudformation.json
    80  -----------------------------
    81  
    82  Any of the parameter defaults defined in deis.template.json can be overridden by setting the value
    83  in `cloudformation.json`_. For example, to configure all of the optional settings:
    84  
    85  .. code-block:: console
    86  
    87      {
    88          "ParameterKey":     "InstanceType",
    89          "ParameterValue":   "m3.xlarge"
    90      },
    91      {
    92          "ParameterKey":     "KeyPair",
    93          "ParameterValue":   "jsmith"
    94      },
    95      {
    96          "ParameterKey":     "EC2VirtualizationType",
    97          "ParameterValue":   "PV"
    98      },
    99      {
   100          "ParameterKey":     "AssociatePublicIP",
   101          "ParameterValue":   "false"
   102      },
   103      {
   104          "ParameterKey":     "ELBScheme",
   105          "ParameterValue":   "internal"
   106      }
   107  
   108  
   109  The only entry in cloudformation.json required to launch your cluster is `KeyPair`, which is
   110  already filled out. The defaults will be applied for the other settings.
   111  
   112  If updated with update-ec2-cluster.sh, the InstanceType will only impact newly deployed instances
   113  (`#1758`_).
   114  
   115  NOTE: The smallest recommended instance size is `large`. Having not enough CPU or RAM will result
   116  in numerous issues when using the cluster.
   117  
   118  
   119  Launch into an existing VPC
   120  ---------------------------
   121  
   122  By default, the provided CloudFormation script will create a new VPC for Deis. However, the script
   123  supports provisioning into an existing VPC instead. You'll need to have a VPC configured with an
   124  internet gateway and a sane routing table (the default VPC in a region should be ready to go).
   125  
   126  To launch your cluster into an existing VPC, export three additional environment variables:
   127  
   128   - ``VPC_ID``
   129   - ``VPC_SUBNETS``
   130   - ``VPC_ZONES``
   131  
   132  ``VPC_ZONES`` must list the availability zones of the subnets in order.
   133  
   134  For example, if your VPC has ID ``vpc-a26218bf`` and consists of the subnets ``subnet-04d7f942``
   135  (which is in ``us-east-1b``) and ``subnet-2b03ab7f`` (which is in ``us-east-1c``) you would export:
   136  
   137  .. code-block:: console
   138  
   139      export VPC_ID=vpc-a26218bf
   140      export VPC_SUBNETS=subnet-04d7f942,subnet-2b03ab7f
   141      export VPC_ZONES=us-east-1b,us-east-1c
   142  
   143  
   144  Run the Provision Script
   145  ------------------------
   146  
   147  Run the cloudformation provision script to spawn a new CoreOS cluster:
   148  
   149  .. code-block:: console
   150  
   151      $ cd contrib/ec2
   152      $ ./provision-ec2-cluster.sh
   153      {
   154          "StackId": "arn:aws:cloudformation:us-west-1:413516094235:stack/deis/9699ec20-c257-11e3-99eb-50fa01cd4496"
   155      }
   156      Your Deis cluster has successfully deployed.
   157      Please wait for all instances to come up as "running" before continuing.
   158  
   159  .. note::
   160  
   161      The default name of the CloudFormation stack will be ``deis``. You can specify a different name
   162      with ``./provision-ec2-cluster.sh <name>``.
   163  
   164  Check the AWS EC2 web control panel and wait until "Status Checks" for all instances have passed.
   165  This will take several minutes.
   166  
   167  
   168  Configure DNS
   169  -------------
   170  
   171  See :ref:`configure-dns` for more information on properly setting up your DNS records with Deis.
   172  
   173  
   174  Install Deis Platform
   175  ---------------------
   176  
   177  Now that you've finished provisioning a cluster, please refer to :ref:`install_deis_platform` to
   178  start installing the platform.
   179  
   180  CloudFormation Updates
   181  ----------------------
   182  
   183  To use CloudFormation to perform update operations to your stack, there is another script:
   184  `update_ec2_cluster.sh`_. Depending on the parameters that you have changed, CloudFormation
   185  may replace the EC2 instances in your stack.
   186  
   187  The following parameters can be changed without replacing all instances in a stack:
   188  
   189  - ``ClusterSize`` - Number of nodes in the cluster. This may launch new instances or terminate
   190    existing instances. If you are scaling down, this may interrupt service. If a container
   191    was running on an instance that was terminated, it will have to be rebalanced onto another
   192    node which will cause some downtime.
   193  - ``SSHFrom`` - Locks down SSH access to the Deis hosts. This will update the security
   194    group for the Deis hosts.
   195  
   196  Please reference the AWS documentation for `more information about CloudFormation stack updates`_.
   197  
   198  .. _`#1758`: https://github.com/deis/deis/issues/1758
   199  .. _`awscli`: https://github.com/aws/aws-cli
   200  .. _`contrib/ec2`: https://github.com/deis/deis/tree/master/contrib/ec2
   201  .. _`cloudformation.json`: https://github.com/deis/deis/blob/master/contrib/ec2/cloudformation.json
   202  .. _`etcd`: https://github.com/coreos/etcd
   203  .. _`etcd disaster recovery`: https://github.com/coreos/etcd/blob/master/Documentation/admin_guide.md#disaster-recovery
   204  .. _`PyYAML`: http://pyyaml.org/
   205  .. _`update_ec2_cluster.sh`: https://github.com/deis/deis/blob/master/contrib/ec2/update-ec2-cluster.sh
   206  .. _`More information about CloudFormation stack updates`: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html
   207