github.com/blystad/deis@v0.11.0/README.md (about)

     1  # Deis
     2  
     3  Deis (pronounced DAY-iss) is an open source PaaS that makes it easy to deploy and manage applications on your own servers. Deis builds upon [Docker](http://docker.io/) and [CoreOS](http://coreos.com) to provide a lightweight PaaS with a [Heroku-inspired](http://heroku.com) workflow.
     4  
     5  [![Build Status](https://travis-ci.org/deis/deis.png?branch=master)](https://travis-ci.org/deis/deis)
     6  [![Current Release](http://img.shields.io/badge/release-v0.11.0-blue.svg)](https://github.com/deis/deis/releases/tag/v0.11.0)
     7  
     8  ![Deis Graphic](https://s3-us-west-2.amazonaws.com/deis-images/deis-graphic.png)
     9  
    10  # Deploying Deis
    11  
    12  Deis is a set of Docker containers that can be deployed anywhere including public cloud, private cloud, bare metal or your workstation. Decide where you'd like to deploy Deis, then follow the deployment-specific documentation for [Rackspace](contrib/rackspace/README.md), [EC2](contrib/ec2/README.md), [DigitalOcean](contrib/digitalocean/README.md), [Google Compute Engine](contrib/gce/README.md) or [bare-metal](contrib/bare-metal/README.md) provisioning. Documentation for other platforms is forthcoming. Want to see a particular platform supported? Open an [issue](https://github.com/deis/deis/issues/new) and we'll investigate.
    13  
    14  Trying out Deis? Continue following these instructions for a local cluster setup. This is also a great Deis testing/development environment.
    15  
    16  # Upgrading Deis
    17  
    18  Upgrading from a previous Deis release? See [Upgrading Deis](http://docs.deis.io/en/latest/installing_deis/upgrading-deis/) for additional information.
    19  
    20  Deis is pre-release software. The current release is [v0.11.0](https://github.com/deis/deis/tree/v0.11.0).
    21  Until there is a stable release, we recommend you check out the latest
    22  ["master" branch](https://github.com/deis/deis) code and refer
    23  to the [latest documentation](http://docs.deis.io/en/latest/).
    24  
    25  ## Install prerequisites
    26  On your workstation:
    27  * Install [Vagrant v1.6+](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
    28  * Install the fleetctl client: Install v0.6.2 from the [fleet GitHub page](https://github.com/coreos/fleet/releases/tag/v0.6.2).
    29  
    30  A single-node cluster launched with Vagrant will consume about 5 GB of RAM on
    31  the host machine. Please be sure you have sufficient free memory before
    32  proceeding.
    33  
    34  Note for Ubuntu users: the VirtualBox package in Ubuntu (as of the last known
    35  release for 14.04) has some issues when running in RAM-constrained
    36  environments. Please install the lastest version of VirtualBox from Oracle's
    37  website.
    38  
    39  ## Additional setup for a multi-node cluster
    40  If you'd like to spin up more than one VM to test an entire cluster, there are a few additional prerequisites:
    41  * Edit [contrib/coreos/user-data](contrib/coreos/user-data) and add a unique discovery URL generated from `https://discovery.etcd.io/new`
    42  * Set `DEIS_NUM_INSTANCES` to the desired size of your cluster (typically 3 or 5): ```$ export DEIS_NUM_INSTANCES=3```
    43  * If you'd like to spin up more than one router, set `DEIS_NUM_ROUTERS`: ```$ export DEIS_NUM_ROUTERS=2```
    44  * Instead of `local.deisapp.com`, use either `local3.deisapp.com` or `local5.deisapp.com` as your cluster domain
    45  
    46  Note that for scheduling to work properly, clusters must consist of at least 3 nodes and always have an odd number of members.
    47  For more information, see [optimal etcd cluster size](https://github.com/coreos/etcd/blob/master/Documentation/optimal-cluster-size.md).
    48  
    49  Deis clusters of less than 3 nodes are unsupported for anything other than local development.
    50  
    51  ## Boot CoreOS
    52  
    53  First, start the CoreOS cluster on VirtualBox. From a command prompt, `cd` to the root of the Deis project code and type:
    54  
    55  ```console
    56  $ vagrant up
    57  ```
    58  
    59  This instructs Vagrant to spin up each VM. To be able to connect to the VMs, you must add your Vagrant-generated SSH key to the ssh-agent (fleetctl tunnel requires the agent to have this key):
    60  ```console
    61  $ ssh-add ~/.vagrant.d/insecure_private_key
    62  ```
    63  
    64  Export `FLEETCTL_TUNNEL` so you can connect to the VM using the `fleetctl` client on your workstation.
    65  
    66  ```console
    67  $ export FLEETCTL_TUNNEL=172.17.8.100
    68  ```
    69  
    70  ## Optional: Build Deis
    71  
    72  If you'd like to build Deis from source instead of using the pre-built public Dockerfiles, use `make build` to build each component from its Dockerfile.  Grab some coffee while it builds the images on each VM (it can take a while).
    73  If you're not testing code changes for Deis, it's faster just to skip to the next step.
    74  
    75  ```console
    76  $ make build
    77  ```
    78  
    79  ## Run Deis
    80  
    81  Use `make run` to start all Deis components. This can take some time - the registry service will pull and prepare a large Docker image. Grab some more coffee!
    82  
    83  ```console
    84  $ make run
    85  ```
    86  
    87  Your Vagrant VM is accessible at `local.deisapp.com` (or `local3.deisapp.com`/`local5.deisapp.com`). For clusters on other platforms (EC2, Rackspace, DigitalOcean, bare metal, etc.), see our guide to [Configuring DNS](http://docs.deis.io/en/latest/installing_deis/configure-dns/).
    88  
    89  ## Testing the cluster
    90  Integration tests and corresponding documentation can be found under the `test/` folder.
    91  
    92  ## Install the Deis Client
    93  If you're using the latest Deis release, use `pip install --upgrade deis` to install the latest [Deis Client](https://pypi.python.org/pypi/deis/) or download [pre-compiled binaries](https://github.com/deis/deis/tree/master/client#get-started).
    94  
    95  If you're working off master, precompiled binaries are likely out of date. You should either symlink the python file directly or build a local copy of the client:
    96  
    97  ```console
    98  $ ln -fs $(pwd)/client/deis.py /usr/local/bin/deis
    99  ```
   100  or
   101  ```console
   102  $ cd client && python setup.py install
   103  ```
   104  
   105  ## Register a User
   106  
   107  Use the Deis Client to register a new user.
   108  
   109  ```console
   110  $ deis register http://deis.local.deisapp.com
   111  $ deis keys:add
   112  ```
   113  
   114  Use `deis keys:add` to add your SSH public key for `git push` access.
   115  
   116  ## Initialize a Cluster
   117  
   118  Initialize a `dev` cluster with a list of CoreOS hosts and your CoreOS private key.
   119  
   120  ```console
   121  $ deis clusters:create dev local.deisapp.com --hosts=172.17.8.100 --auth=~/.vagrant.d/insecure_private_key
   122  ```
   123  
   124  The parameters to `deis clusters:create` are:
   125  * cluster name (`dev`) - the name used by Deis to reference the cluster
   126  * cluster hostname (`local.deisapp.com`) - the hostname under which apps are created, like `balancing-giraffe.local.deisapp.com`
   127  * cluster members (`--hosts`) - a comma-separated list of cluster members -- not necessarily all members, but at least one (for cloud providers, this is a list of the IPs like `--hosts=10.21.12.1,10.21.12.2,10.21.12.3`)
   128  * auth SSH key (`--auth`) - the SSH private key used to provision servers -- cannot have a password (for cloud providers, this key is likely `~/.ssh/deis`)
   129  
   130  The `dev` cluster will be used as the default cluster for future `deis` commands.
   131  
   132  # Usage
   133  
   134  ## Clone an example application or use an existing one
   135  Example applications can be cloned from the Deis GitHub [organization](https://github.com/deis).
   136  Commonly-used example applications include [Helloworld (Dockerfile)](https://github.com/deis/helloworld), [Go](https://github.com/deis/example-go), and [Ruby](https://github.com/deis/example-ruby-sinatra).
   137  
   138  ## Create an Application
   139  From within the application directory, create an application on the default `dev` cluster:
   140  
   141  ```console
   142  $ cd example-ruby-sinatra
   143  $ deis create
   144  ```
   145  
   146  Use `deis create --cluster=prod` to place the app on a different cluster.  Don't like our name-generator?  Use `deis create myappname`.
   147  
   148  ## Push
   149  Push builds of your application from your local git repository or from a Docker Registry.  Each build creates a new release, which can be rolled back.
   150  
   151  #### From a Git Repository
   152  When you created the application, a git remote for Deis was added automatically.
   153  
   154  ```console
   155  $ git push deis master
   156  ```
   157  This will use the Deis builder to package your application as a Docker Image and deploy it on your application's cluster.
   158  
   159  ## Configure
   160  Configure your application with environment variables.  Each config change also creates a new release.
   161  
   162  ```console
   163  $ deis config:set DATABASE_URL=postgres://
   164  ```
   165  
   166  ## Test
   167  ### Run tests
   168  Test your application by running commands inside an ephemeral Docker container.
   169  
   170  ```console
   171  $ deis run make test
   172  ```
   173  
   174  To integrate with your CI system, check the return code.
   175  
   176  ## Scale
   177  Scale containers horizontally with ease.
   178  
   179  ```console
   180  $ deis scale web=8
   181  ```
   182  
   183  ## Debug
   184  Access to aggregated logs makes it easy to troubleshoot problems with your application.
   185  
   186  ```console
   187  $ deis logs
   188  ```
   189  
   190  Use `deis run` to execute one-off commands and explore the deployed container.  Coming soon: `deis attach` to jump into a live container.
   191  
   192  ## Troubleshooting
   193  
   194  Common issues that users have run into when provisioning Deis are detailed below.
   195  
   196  #### When running a `make` action - 'Failed initializing SSH client: ssh: handshake failed: ssh: unable to authenticate'
   197  Did you remember to add your SSH key to the ssh-agent? `ssh-agent -L` should list the key you used to provision the servers. If it's not there, `ssh-add -K /path/to/your/key`.
   198  
   199  #### When running a `make` action - 'All the given peers are not reachable (Tried to connect to each peer twice and failed)'
   200  The most common cause of this issue is that a [new discovery URL](https://discovery.etcd.io/new) wasn't generated and updated in [contrib/coreos/user-data](contrib/coreos/user-data) before the cluster was launched. Each Deis cluster must have a unique discovery URL, else there will be entries for old hosts that etcd will try and fail to connect to. Destroy and relaunch the cluster, ensuring to use a fresh discovery URL.
   201  
   202  #### Scaling an app doesn't work, and/or the app shows 'Welcome to nginx!'
   203  This means the controller failed to submit jobs for the app to fleet. `fleetctl status deis-controller` will show detailed error information, but the most common cause of this is that the cluster was created with the wrong SSH key for the `--auth` parameter. The key supplied with the `--auth` parameter must be the same key that was used to provision the Deis servers. If you suspect this to be the issue, you'll need to `clusters:destroy` the cluster and recreate it, along with the app.
   204  
   205  #### A Deis component fails to start
   206  Use `fleetctl status deis-<component>.service` to get the output of the service. The most common cause of services failing to start are sporadic issues with the Docker index. The telltale sign of this is:
   207  
   208  ```console
   209  May 12 18:24:37 deis-3 systemd[1]: Starting deis-controller...
   210  May 12 18:24:37 deis-3 sh[6176]: 2014/05/12 18:24:37 Error: No such id: deis/controller
   211  May 12 18:24:37 deis-3 sh[6176]: Pulling repository deis/controller
   212  May 12 18:29:47 deis-3 sh[6176]: 2014/05/12 18:29:47 Could not find repository on any of the indexed registries.
   213  May 12 18:29:47 deis-3 systemd[1]: deis-controller.service: control process exited, code=exited status=1
   214  May 12 18:29:47 deis-3 systemd[1]: Failed to start deis-controller.
   215  May 12 18:29:47 deis-3 systemd[1]: Unit deis-controller.service entered failed state.
   216  ```
   217  
   218  We are exploring workarounds and are working with the Docker team to improve their index. In the meantime, try starting the service again with `fleetctl start deis-<component>.service`.
   219  
   220  ### Any other issues
   221  Running into something not detailed here? Please [open an issue](https://github.com/deis/deis/issues/new) or hop into #deis and we'll help!
   222  
   223  ## License
   224  
   225  Copyright 2014, OpDemand LLC
   226  
   227  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
   228  
   229  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.