|
1 | | -Local development workflow for Deis |
2 | | -================================================================ |
3 | | - |
4 | | -This document suggests some ways that might make developing Deis easier and cheaper. You don't have to follow |
5 | | -them all. |
6 | | - |
7 | | -1. You'll need VirtualBox >= `4.2.18`. We recommend installing Vagrant with their binary installer from http://downloads.vagrantup.com |
8 | | -Vagrant 1.3.5 has support for VirtualBox 4.3 |
9 | | - |
10 | | -2. Firstly you need to decide whether to use your own Chef Server or the free tier of the hosted enterprise |
11 | | -service from Opscode. The free tier has a limit of 5 nodes which is more then enough for development. Also |
12 | | -bear in mind that a local Chef Server VM will take up at least 1GB of RAM. |
13 | | - |
14 | | - **Local Chef Server** |
15 | | - * `cd [DEIS_DIR] && ln -s contrib/vagrant/knife-config .chef` |
16 | | - * `vagrant up` the chef server Vagrantfile. |
17 | | - * copy the admin.pem and validation.pem files for your own knife client |
18 | | - `scp -r root@chefserver.local:/etc/chef-server/admin.pem [DEIS_DIR]/contrib/vagrant/knife-config/` |
19 | | - `scp -r root@chefserver.local:/etc/chef-server/chef-validator.pem [DEIS_DIR]/contrib/vagrant/knife-config/` |
20 | | - |
21 | | - **Hosted Chef Server** |
22 | | - * Goto https://getchef.opscode.com/signup and fill in your details. |
23 | | - * Goto https://manage.opscode.com/login and sign in to your Chef Server. |
24 | | - * Click on the 'Administration' tab and choose your organisation. There should be a tab in the sidebar that says |
25 | | - 'Starter Kit'. Click it and it will start a small download. |
26 | | - * Inside the Starter Kit there is a '.chef' folder. Copy it to the root of your Deis codebase. |
27 | | - |
28 | | -3. Now you can follow the standard deis setup: |
29 | | - * If you're running a local chef server, you should adjust the `Gemfile` and make sure the version of berkshelf is 3.0.x. This is needed for the `--ssl-verify` option to work correctly. |
30 | | - ```bash |
31 | | - bundle install # Installs gem files like the knife tool |
32 | | - berks install # Downloads the relevant cookbooks |
33 | | - # '--ssl-verify' is only needed when using a local Chef Server |
34 | | - berks upload [--ssl-verify=false] # Upload the cookbooks to the Chef Server |
35 | | - ``` |
36 | | - |
37 | | -4. The Controller needs to be able to run Vagrant commands on your host machine. It does this via SSH. Therefore |
38 | | -you will need a running SSH server open on port 22 and a means to broadcast your hostname to local DNS. |
39 | | - * On Debian-flavoured Linux you just need to; |
40 | | - `sudo apt-get install openssh-server` |
41 | | - * On Mac OSX you just need to go to **System Preferences -> Sharing** and enable 'Remote Login'. |
42 | | - * [Mac OSX user's should already be broadcasting their hostname](http://support.apple.com/kb/ht3473). |
43 | | - * Linux user's will need to install avahi-daemon, so that their machine is accessible via |
44 | | - [hostname].local. Eg; `sudo apt-get install avahi-daemon`. |
45 | | - |
46 | | -5. Creating the Deis Controller. |
47 | | - * Run `./contrib/vagrant/provision-vagrant-controller.sh` |
48 | | - * You may need to prepend the command with `bundle exec` depending on your Ruby setup. |
49 | | - * When running for the first time you will be asked to add the Controller's SSH key to your local SSH server. |
50 | | - This will allow the Controller to run vagrant commands on your machine to bootstrap new nodes. |
51 | | - * You need to tell the Chef Server that your new Controller has permission to create |
52 | | - and delete nodes. Use: |
53 | | - * For a local Chef Server just type `knife client edit deis-controller` and your default text |
54 | | - editor will launch, you need to set 'admin' to 'true'. |
55 | | - * For Hosted Chef, log in to https://manage.opscode.com/. Go to the |
56 | | - Administration tab, click on the "Groups" entry to the left, then the "admins" entry |
57 | | - under "All Groups". Choose the "Permissions" tab and click the "+ Add" button, then |
58 | | - type in "deis-controller" and add it. Assign all permissions to the "deis-controller" |
59 | | - client object. |
60 | | - |
61 | | -6. If you want to hack on the command line client (`client/deis.py`), install your local dev version rather than |
62 | | -the one from Pip. |
63 | | - * `cd deis && make install` This installs the client into your executables path. |
64 | | - * `sudo rm /usr/local/bin/deis && sudo ln ./deis.py /usr/local/bin/deis` This will symlink the dev version to your executables path. |
65 | | - * Your deis controller is available at http://deis-controller.local:8000 so you can register with; |
66 | | - `deis register http://deis-controller.local:8000` |
67 | | - |
68 | | -7. Right, time to boot up some nodes! |
69 | | - * Create a formation with a vagrant flavour, 512MB, 1024MB and 2048MB are available. |
70 | | - `deis formations:create dev --flavor=vagrant-512 --domain=deisapp.local` |
71 | | - * Scale a node with `deis nodes:scale dev runtime=1` Be patient, this is the command that runs vagrant commands. Scaling a single node |
72 | | - can take over 15 mins. |
73 | | - * Then create and push your app as per the usual documentation. |
74 | | - |
75 | | -## Useful development commands |
76 | | -* To get a shell session to a running container use the `dsh` command on the VM. Usage: |
77 | | - * `dsh deis-builder` |
78 | | - * `dsh deis-builder /bin/ls` Note the absolute path |
79 | | - * `echo 'ls' | dsh deis-builder` Note no need for path when piping |
80 | | - |
81 | | -* To use Django's manage.py: |
82 | | - * SSH in to the VM with `vagrant ssh` |
83 | | - * Use `dsh deis-controller` |
84 | | - * Get into the Django server's path `cd /app/deis/controller` |
85 | | - * Get a list of commands with; `./manage.py help` |
86 | | - |
87 | | -* Django's native web admin interface is available at http://deis-controller.local:8000/admin/ |
88 | | -You can add and update all of the models from there. |
89 | | - |
90 | | -* To reset the DB: |
91 | | - * There is a script at contrib/vagrant/util/reset-db.sh that resets the DB and installs some basic fixtures. |
92 | | - It should be run from your host machine. |
93 | | - * It installs a formation named 'dev' and a super user with username 'devuser' and password 'devpass'. |
94 | | - |
95 | | -* This is useful for uploading your own local version of the cookbooks, rather than the Github versions: |
96 | | - * `knife cookbook upload deis --cookbook-path [deis-cookbook path] --force` |
97 | | - * You need to change directory structure though as knife gets the cookbook name from the folder name. So, for example I use; |
98 | | - |
99 | | - ```bash |
100 | | - deis |
101 | | - |__ code |
102 | | - |__ api |
103 | | - |__ bin |
104 | | - |__ client |
105 | | - |__ cm |
106 | | - |__ ... and so on |
107 | | - |__ cookbooks |
108 | | - |__ deis |
109 | | - |__ attributes |
110 | | - |__ definitions |
111 | | - |__ recipes |
112 | | - |__ ... and so on |
113 | | - ``` |
114 | | - |
115 | | -* Resolving submodule conflicts when merging master into your dev branch can be troublesome. |
116 | | -You might have luck with `git submodule foreach git checkout master && git submodule foreach git pull --rebase` |
117 | | - |
118 | | -* There is a sample `Vagrantfile.local.example` that can be useful if you want any personal customisations |
119 | | -to your vagrant setup, like using less RAM for post-installation boots. |
120 | | - |
121 | | -Notes |
122 | | ------ |
123 | | - |
124 | | -Mac OS X: if you see an error such as |
125 | | -'failed to open /dev/vboxnetctl', try restarting VirtualBox: |
126 | | -sudo /Library/StartupItems/VirtualBox/VirtualBox restart |
| 1 | +# Deis cluster local test environment |
| 2 | + |
| 3 | +The Vagrantfile and Makefile provided in this directory will launch a multi-host Deis CoreOS cluster that runs locally. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | +On your workstation: |
| 7 | +* Install [Vagrant](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads) |
| 8 | +* Install [Go](http://golang.org/doc/install) and configure your GOPATH, if necessary |
| 9 | +* Install the fleetctl client: `go get github.com/coreos/fleetctl` |
| 10 | +* Set the `DEIS_NUM_INSTANCES` environment variable if you'd like more (or less) than the default of 3 machines to test: |
| 11 | + * `export DEIS_NUM_INSTANCES=5` |
| 12 | +* Configure the fleetctl client to tunnel through one of the VMs: |
| 13 | + * `export FLEETCTL_TUNNEL=172.17.8.100` |
| 14 | + * (Note that IP addressing for the VMs starts at .100, but you can connect to any VM in the cluster) |
| 15 | + |
| 16 | +## Launching Deis |
| 17 | +Follow the normal instructions in the [README](../../README.md) for launching and using Deis, with the caveat that |
| 18 | +commands should be run in this directory to ensure that the proper Vagrantfile and Makefile is used. In this directory |
| 19 | +pull/build commands are run in each VM, and service starting/stopping are run with `fleetctl` and affect the entire cluster. |
| 20 | + |
| 21 | +## Testing ideas |
| 22 | +### Stop a container service |
| 23 | +Logging into one of the CoreOS machines and stopping a container service should cause the same component on another CoreOS |
| 24 | +host to take over as master |
| 25 | + |
| 26 | +### Stop a VM |
| 27 | +Similarly, bringing down a VM should enable the services on another VM to take over as master |
| 28 | + |
| 29 | +## Useful references |
| 30 | +### systemd services |
| 31 | +These systemd services run the various containers which compose Deis, and can be stopped on a machine with `sudo systemctl stop servicename`. |
| 32 | +* deis-builder.service |
| 33 | +* deis-cache.service |
| 34 | +* deis-controller.service |
| 35 | +* deis-database.service |
| 36 | +* deis-discovery.service |
| 37 | +* deis-logger.service |
| 38 | +* deis-registry.service |
| 39 | +* deis-router.service |
0 commit comments