github.com/rvaralda/deis@v1.4.1/docs/installing_deis/gce.rst (about)

     1  :title: Installing Deis on Google Compute Engine
     2  :description: How to provision a multi-node Deis cluster on Google Compute Engine
     3  
     4  .. _deis_on_gce:
     5  
     6  Google Compute Engine
     7  =====================
     8  
     9  Let's build a Deis cluster in Google's Compute Engine!
    10  
    11  Please :ref:`get the source <get_the_source>` and refer to the scripts in `contrib/gce`_
    12  while following this documentation.
    13  
    14  
    15  Prerequisites
    16  -------------
    17  
    18  Let's get a few Google things squared away so we can provision VM instances.
    19  
    20  
    21  Install Google Cloud SDK
    22  ^^^^^^^^^^^^^^^^^^^^^^^^
    23  
    24  Install the `Google Cloud SDK`_. You will then need to login with your Google Account:
    25  
    26  .. code-block:: console
    27  
    28      $ gcloud auth login
    29  
    30  
    31  Create New Project
    32  ^^^^^^^^^^^^^^^^^^
    33  
    34  Create a new project in the `Google Developer Console`_. You should get a project ID like
    35  ``orbital-gantry-285`` back. We'll set it as the default for the SDK tools:
    36  
    37  .. code-block:: console
    38  
    39      $ gcloud config set project orbital-gantry-285
    40  
    41  
    42  Enable Billing
    43  ^^^^^^^^^^^^^^
    44  
    45  .. important::
    46  
    47      You will begin to accrue charges once you create resources such as disks and instances.
    48  
    49  Navigate to the project console and then the *Billing & Settings* section in the browser. Click the
    50  *Enable billing* button and fill out the form. This is needed to create resources in Google's
    51  Compute Engine.
    52  
    53  
    54  Initialize Compute Engine
    55  ^^^^^^^^^^^^^^^^^^^^^^^^^
    56  
    57  Google Computer Engine won't be available via the command line tools until it is initialized in the
    58  web console. Navigate to *COMPUTE* -> *COMPUTE ENGINE* -> *VM Instances* in the project console.
    59  The Compute Engine will take a moment to initialize and then be ready to create resources via
    60  ``gcutil``.
    61  
    62  
    63  Cloud Init
    64  ----------
    65  
    66  Create your cloud init file using Deis' ``contrib/gce/create-gce-user-data`` script and a new etcd
    67  discovery URL. First, install PyYAML:
    68  
    69  .. code-block:: console
    70  
    71      $ sudo pip install pyyaml
    72  
    73  Then navigate to the ``contrib/gce`` directory:
    74  
    75  .. code-block:: console
    76  
    77      $ cd contrib/gce
    78  
    79  Finally, create the ``gce-user-data`` file:
    80  
    81  .. code-block:: console
    82  
    83      $ ./create-gce-user-data $(curl -s https://discovery.etcd.io/new)
    84  
    85  We should have a ``gce-user-data`` file ready to launch CoreOS nodes with.
    86  
    87  Launch Instances
    88  ----------------
    89  
    90  Create a SSH key that we will use for Deis host communication:
    91  
    92  .. code-block:: console
    93  
    94      $ ssh-keygen -q -t rsa -f ~/.ssh/deis -N '' -C deis
    95  
    96  Create some persistent disks to use for ``/var/lib/docker``. The default root partition of CoreOS
    97  is only around 4 GB and not enough for storing Docker images and instances. The following creates 3
    98  disks sized at 32 GB:
    99  
   100  .. code-block:: console
   101  
   102      $ gcutil adddisk --zone us-central1-a --size_gb 32 cored1 cored2 cored3
   103  
   104      Table of resources:
   105  
   106      +--------+---------------+--------+---------+
   107      | name   | zone          | status | size-gb |
   108      +--------+---------------+--------+---------+
   109      | cored1 | us-central1-a | READY  |      32 |
   110      +--------+---------------+--------+---------+
   111      | cored2 | us-central1-a | READY  |      32 |
   112      +--------+---------------+--------+---------+
   113      | cored3 | us-central1-a | READY  |      32 |
   114      +--------+---------------+--------+---------+
   115  
   116  
   117  Launch 3 instances. You can choose another starting CoreOS image from the listing output of
   118  ``gcloud compute images list``:
   119  
   120  .. code-block:: console
   121  
   122      $ for num in 1 2 3; do gcutil addinstance --use_compute_key --image projects/coreos-cloud/global/images/coreos-stable-557-2-0-v20150210 --persistent_boot_disk --zone us-central1-a --machine_type n1-standard-2 --tags deis --metadata_from_file user-data:gce-user-data --disk cored${num},deviceName=coredocker --authorized_ssh_keys=core:~/.ssh/deis.pub,core:~/.ssh/google_compute_engine.pub core${num}; done
   123  
   124      Table of resources:
   125  
   126      +-------+---------------+--------------+---------------+---------+
   127      | name  | network-ip    | external-ip  | zone          | status  |
   128      +-------+---------------+--------------+---------------+---------+
   129      | core1 | 10.240.33.107 | 23.236.59.66 | us-central1-a | RUNNING |
   130      +-------+---------------+--------------+---------------+---------+
   131      | core2 | 10.240.94.33  | 108.59.80.17 | us-central1-a | RUNNING |
   132      +-------+---------------+--------------+---------------+---------+
   133      | core3 | 10.240.28.163 | 108.59.85.85 | us-central1-a | RUNNING |
   134      +-------+---------------+--------------+---------------+---------+
   135  
   136  .. note::
   137  
   138      The provision script will by default provision ``n1-standard-2`` instances. Choosing a smaller
   139      instance size is not recommended. Please refer to :ref:`system-requirements` for resource
   140      considerations when choosing an instance size to run Deis.
   141  
   142  Load Balancing
   143  --------------
   144  
   145  We will need to load balance the Deis routers so we can get to Deis services (controller and builder) and our applications.
   146  
   147  .. code-block:: console
   148  
   149      $ gcutil addhttphealthcheck basic-check --request_path /health-check
   150      $ gcutil addtargetpool deis --health_checks basic-check --region us-central1 --instances core1,core2,core3
   151      $ gcutil addforwardingrule deisapp --region us-central1 --target_pool deis
   152  
   153      Table of resources:
   154  
   155      +---------+-------------+--------------+
   156      | name    | region      | ip           |
   157      +---------+-------------+--------------+
   158      | deisapp | us-central1 | 23.251.153.6 |
   159      +---------+-------------+--------------+
   160  
   161  Note the forwarding rule external IP address. We will use it as the Deis login endpoint in a future step. Now allow the ports on the CoreOS nodes:
   162  
   163  .. code-block:: console
   164  
   165      $ gcutil addfirewall deis-router --target_tags deis --allowed "tcp:80,tcp:2222"
   166  
   167  
   168  Configure DNS
   169  -------------
   170  
   171  We can create DNS records in Google Cloud DNS using the ``gcloud`` utility. In our example we will
   172  be using the domain name `deisdemo.io`. Create the zone:
   173  
   174  .. code-block:: console
   175  
   176      $ gcloud dns managed-zone create --dns_name deisdemo.io. --description "Example Deis cluster domain name" deisdemoio
   177      Creating {'dnsName': 'deisdemo.io.', 'name': 'deisdemoio', 'description':
   178      'Example Deis cluster domain name'} in eco-theater-654
   179  
   180      Do you want to continue (Y/n)?  Y
   181  
   182      {
   183          "creationTime": "2014-07-28T00:01:45.835Z",
   184          "description": "Example Deis cluster domain name",
   185          "dnsName": "deisdemo.io.",
   186          "id": "1374035518570040348",
   187          "kind": "dns#managedZone",
   188          "name": "deisdemoio",
   189          "nameServers": [
   190              "ns-cloud-d1.googledomains.com.",
   191              "ns-cloud-d2.googledomains.com.",
   192              "ns-cloud-d3.googledomains.com.",
   193              "ns-cloud-d4.googledomains.com."
   194          ]
   195      }
   196  
   197  Note the `nameServers` array from the JSON output. We will need to setup our upstream domain name
   198  servers to these.
   199  
   200  Now edit the zone to add the Deis endpoint and wildcard DNS:
   201  
   202  .. code-block:: console
   203  
   204      $ gcloud dns records --zone deisdemoio edit
   205      {
   206          "additions": [
   207              {
   208                  "kind": "dns#resourceRecordSet",
   209                  "name": "deisdemo.io.",
   210                  "rrdatas": [
   211                      "ns-cloud-d1.googledomains.com. dns-admin.google.com. 2 21600 3600 1209600 300"
   212                  ],
   213                  "ttl": 21600,
   214                  "type": "SOA"
   215              }
   216          ],
   217          "deletions": [
   218              {
   219                  "kind": "dns#resourceRecordSet",
   220                  "name": "deisdemo.io.",
   221                  "rrdatas": [
   222                      "ns-cloud-d1.googledomains.com. dns-admin.google.com. 1 21600 3600 1209600 300"
   223                  ],
   224                  "ttl": 21600,
   225                  "type": "SOA"
   226              }
   227          ]
   228      }
   229  
   230  You will want to add two records as JSON objects. Here is an example edit for the two A record additions:
   231  
   232  .. code-block:: console
   233  
   234      {
   235          "additions": [
   236              {
   237                  "kind": "dns#resourceRecordSet",
   238                  "name": "deisdemo.io.",
   239                  "rrdatas": [
   240                      "ns-cloud-d1.googledomains.com. dns-admin.google.com. 2 21600 3600 1209600 300"
   241                  ],
   242                  "ttl": 21600,
   243                  "type": "SOA"
   244              },
   245              {
   246                  "kind": "dns#resourceRecordSet",
   247                  "name": "deis.deisdemo.io.",
   248                  "rrdatas": [
   249                      "23.251.153.6"
   250                  ],
   251                  "ttl": 21600,
   252                  "type": "A"
   253              },
   254              {
   255                  "kind": "dns#resourceRecordSet",
   256                  "name": "*.dev.deisdemo.io.",
   257                  "rrdatas": [
   258                      "23.251.153.6"
   259                  ],
   260                  "ttl": 21600,
   261                  "type": "A"
   262              }
   263          ],
   264          "deletions": [
   265              {
   266                  "kind": "dns#resourceRecordSet",
   267                  "name": "deisdemo.io.",
   268                  "rrdatas": [
   269                      "ns-cloud-d1.googledomains.com. dns-admin.google.com. 1 21600 3600 1209600 300"
   270                  ],
   271                  "ttl": 21600,
   272                  "type": "SOA"
   273              }
   274          ]
   275      }
   276  
   277  
   278  Install Deis Platform
   279  ---------------------
   280  
   281  Now that you've finished provisioning a cluster, please refer to :ref:`install_deis_platform` to
   282  start installing the platform.
   283  
   284  It works! Enjoy your Deis cluster in Google Compute Engine!
   285  
   286  .. _`contrib/gce`: https://github.com/deis/deis/tree/master/contrib/gce
   287  .. _`Google Cloud SDK`: https://developers.google.com/compute/docs/gcutil/#install
   288  .. _`Google Developer Console`: https://console.developers.google.com/project