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