44
55Local Development
66=================
7- We try to make it simple to hack on Deis, but as an open PaaS, there are
8- necessarily several moving pieces and some setup required. We welcome
9- any suggestions for automating or simplifying this process.
107
11- If you're just getting into the Deis codebase, look for GitHub issues
12- with the label `easy-fix `_. These are more straightforward or low-risk
13- issues for which we need pull requests. Issues tagged `easy-fix `_ are a
14- great way to become more familiar with Deis.
8+ We try to make it simple to hack on Deis. However, there are necessarily several moving
9+ pieces and some setup required. We welcome any suggestions for automating or simplifying
10+ this process.
11+
12+ If you're just getting into the Deis codebase, look for GitHub issues with the label
13+ `easy-fix `_. These are more straightforward or low-risk issues for which we need pull
14+ requests. Issues tagged `easy-fix `_ are a great way to become more familiar with Deis.
1515
1616Prerequisites
1717-------------
18- We strongly recommend using `Vagrant `_ with `VirtualBox `_ so you can
19- develop inside a set of isolated virtual machines. You will need:
18+
19+ We strongly recommend using `Vagrant `_ with `VirtualBox `_ so you can develop inside a set
20+ of isolated virtual machines. You will need:
2021
2122 * Vagrant 1.6+
2223 * VirtualBox 4.2+
2324
2425Fork the Repository
2526-------------------
26- To get Deis running locally, first `fork the Deis repository `_, then
27- clone your fork of the repository for local development:
27+
28+ To get Deis running locally, first `fork the Deis repository `_, then clone your fork of
29+ the repository for local development:
2830
2931.. code-block :: console
3032
3133 $ git clone git@github.com:<username>/deis.git
3234 $ cd deis
3335 $ export DEIS_DIR=`pwd` # to use in future commands
3436
35- Provision the Controller
36- ------------------------
37- First bring up a virtual machine to host Deis. To share your local
38- codebase into the CoreOS VM, Deis uses NFS mounts, so you will be
39- prompted for an administrative password .
37+ Provision the Cluster
38+ ---------------------
39+
40+ First bring up a virtual machine to host Deis. To share your local codebase into the
41+ CoreOS VM, Deis uses rsync .
4042
4143.. code-block :: console
4244
4345 $ vagrant up
44- Bringing machine 'deis' up with 'virtualbox' provider...
45- ==> deis: Importing base box 'coreos-alpha'...
46- ...
47- ==> deis: Exporting NFS shared folders...
48- ==> deis: Preparing to edit /etc/exports. Administrator privileges will be required...
49- Password:
50- ==> deis: Mounting NFS shared folders...
51- ...
52- ==> deis: Running provisioner: shell...
53- deis: Running: inline script
46+ Bringing machine 'deis-1' up with 'virtualbox' provider...
47+ ==> deis-1: Importing base box 'coreos-402.2.0'...
48+ ==> deis-1: Matching MAC address for NAT networking...
49+ ==> deis-1: Setting the name of the VM: deis_deis-1_1408039741706_8568
50+ ==> deis-1: Clearing any previously set network interfaces...
51+ ==> deis-1: Preparing network interfaces based on configuration...
52+ deis-1: Adapter 1: nat
53+ deis-1: Adapter 2: hostonly
54+ ==> deis-1: Forwarding ports...
55+ deis-1: 22 => 2222 (adapter 1)
56+ ==> deis-1: Running 'pre-boot' VM customizations...
57+ ==> deis-1: Booting VM...
58+ ==> deis-1: Waiting for machine to boot. This may take a few minutes...
5459 $
5560
5661 Set ``FLEETCTL_TUNNEL `` so the ``fleetctl `` client on your workstation can connect to the VM:
@@ -59,15 +64,16 @@ Set ``FLEETCTL_TUNNEL`` so the ``fleetctl`` client on your workstation can conne
5964
6065 export FLEETCTL_TUNNEL=172.17.8.100
6166
62- Next, run ``make pull && make build `` to SSH into the VM, pull Deis'
63- images from the Docker Index, then update those images with any local
64- changes.
67+ Next, run ``make pull && make build `` to SSH into the VM, pull Deis' images from the
68+ Docker Index, then update those images with any local changes.
6569
6670.. code-block :: console
6771
6872 $ make pull
69- vagrant ssh -c 'for c in registry logger database cache controller \
70- builder router; do docker pull deis/$c:latest; done'
73+ for host in 172.17.8.100 ; do ssh -o LogLevel=FATAL -o Compression=yes \
74+ -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
75+ -o PasswordAuthentication=no core@$host \
76+ -t 'for c in builder cache controller database logger registry router; do docker pull deis/$c:latest; done'; done
7177 Pulling repository deis/registry
7278 d2c347aa26dd: Pulling dependent layers
7379 511136ea3c5a: Download complete
@@ -77,9 +83,10 @@ changes.
7783 e5efa1477310: Download complete
7884 Connection to 127.0.0.1 closed.
7985 $ make build
80- vagrant ssh -c 'cd share && for c in registry logger database \
81- cache controller builder router; \
82- do cd $c && docker build -t deis/$c . && cd ..; done'
86+ for host in 172.17.8.100 ; do ssh -o LogLevel=FATAL -o Compression=yes \
87+ -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
88+ -o PasswordAuthentication=no core@$host \
89+ -t 'for c in builder cache controller database logger registry router; do cd $c && docker build -t deis/$c . && cd ..; done'; done
8390 Uploading context 22.53 kB
8491 Uploading context
8592 Step 0 : FROM deis/base:latest
@@ -93,24 +100,32 @@ changes.
93100 Successfully built cf4b7a398500
94101 Connection to 127.0.0.1 closed.
95102
96- Finally, do ``make run `` to start all Deis containers and displays their
97- collected log output:
103+ Finally, do ``make run `` to start all Deis containers:
98104
99105.. code-block :: console
100106
101107 $ make run
102- vagrant ssh -c 'cd share && for c in registry logger database \
103- cache controller builder router; \
104- do cd $c && sudo systemctl enable $(pwd)/systemd/* && cd ..; done'
105- ln -s '/home/core/share/registry/systemd/deis-registry.service' \
106- '/etc/systemd/system/multi-user.target.wants/deis-registry.service'
107- ...
108- Apr 15 18:53:23 deis sh[9101]: 2014-04-15 12:53:23 [149] [INFO] Booting worker with pid: 149
109- Apr 15 18:53:24 deis sh[9101]: [2014-04-15 12:53:24,842: INFO/MainProcess] mingle: all alone
110- Apr 15 18:53:24 deis sh[9101]: [2014-04-15 12:53:24,852: WARNING/MainProcess] celery@121f56ff9ae5 ready.
108+ Job deis-router@1.service loaded on ff3442c2.../172.17.8.100
109+ Job deis-builder-data.service loaded on ff3442c2.../172.17.8.100
110+ Job deis-database-data.service loaded on ff3442c2.../172.17.8.100
111+ Job deis-logger-data.service loaded on ff3442c2.../172.17.8.100
112+ Job deis-registry-data.service loaded on ff3442c2.../172.17.8.100
113+ fleetctl --strict-host-key-checking=false load logger/systemd/deis-logger.service cache/systemd/deis-cache.service database/systemd/deis-database.service
114+ Job deis-cache.service loaded on ff3442c2.../172.17.8.100
115+ Job deis-database.service loaded on ff3442c2.../172.17.8.100
116+ Job deis-logger.service loaded on ff3442c2.../172.17.8.100
117+ fleetctl --strict-host-key-checking=false load registry/systemd/*.service
118+ Job deis-registry.service loaded on ff3442c2.../172.17.8.100
119+ fleetctl --strict-host-key-checking=false load controller/systemd/*.service
120+ Job deis-controller.service loaded on ff3442c2.../172.17.8.100
121+ fleetctl --strict-host-key-checking=false load builder/systemd/*.service
122+ Job deis-builder.service loaded on ff3442c2.../172.17.8.100
123+ Deis components may take a long time to start the first time they are initialized.
124+ Waiting for 1 of 1 deis-routers to start...
111125
112126 Install the Client
113127------------------
128+
114129In a development environment you'll want to use the latest version of the client. Install
115130its dependencies by using the Makefile and symlinking ``client/deis.py `` to ``deis `` on
116131your local workstation.
@@ -125,6 +140,7 @@ your local workstation.
125140
126141 Register an Admin User
127142----------------------
143+
128144Use the Deis client to register a new user on the controller. As the first user, you will
129145receive full admin permissions.
130146
@@ -138,31 +154,29 @@ receive full admin permissions.
138154 Registered myuser
139155 Logged in as myuser
140156
141- Once the user is registered, add your SSH key for ``git push ``
142- access using:
157+ Once the user is registered, add your SSH key for ``git push `` access using:
143158
144159.. code-block :: console
145160
146161 $ deis keys:add
147162 Found the following SSH public keys:
148163 1) id_rsa.pub
149164 Which would you like to use with Deis? 1
150- Uploading /Users/myuser/.ssh/id_rsa.pub to Deis... done
151-
165+ Uploading /home/myuser/.ssh/id_rsa.pub to Deis... done
152166
153- Your local development environment is running! Follow the
154- rest of the ` _using_deis ` guide to deploy your first application.
167+ Your local development environment is running! Follow the rest of the ` _using_deis ` guide
168+ to deploy your first application.
155169
156170Test Your Changes
157171-----------------
158- In the single-node Vagrant environment, testing your changes to Deis itself
159- is easy:
160172
161- - Make changes to the code in one of the component subdirectories, such
162- as ``controller/ ``
163- - run ``make -C controller/ build run ``
164- - Test your changes with ``make -C controller/ test `` and interactively
165- with the Deis client
173+ In the single-node Vagrant environment, testing your changes to Deis itself is easy!
174+
175+ - Make changes to the code in one of the component subdirectories, such as
176+ ``controller/ ``
177+ - run ``make -C controller/ build run ``
178+ - Test your changes with ``make -C controller/ test-unit `` and interactively with the
179+ Deis client
166180
167181Useful Commands
168182---------------
@@ -174,24 +188,28 @@ Tail Logs
174188
175189.. code-block :: console
176190
177- $ vagrant ssh -c 'sudo docker logs --follow=true deis-controller'
191+ $ vagrant ssh -c 'docker logs -f deis-controller'
192+
193+ Rebuild Services from Source
194+ ````````````````````````````
195+
196+ $ make -C controller build
178197
179198Restart Services
180199````````````````
181200
182201.. code-block :: console
183202
184- $ vagrant ssh -c 'sudo restart deis-controller'
203+ $ make -C controller restart
185204
186205 Django Admin
187206````````````
188207
189208.. code-block :: console
190209
191210 $ vagrant ssh # SSH into the controller
192- $ sudo su deis -l # change to deis user
193- $ cd controller # change into the django project root
194- $ source venv/bin/activate # activate python virtualenv
211+ $ nse deis-controller # inject yourself into the container
212+ $ cd /app # change into the django project root
195213 $ ./manage.py shell # get a django shell
196214
197215 Have commands other Deis developers might find useful? Send us a PR!
@@ -200,9 +218,9 @@ Standards & Test Coverage
200218-------------------------
201219
202220When changing Python code in the Deis project, keep in mind our :ref: `standards `.
203- Specifically, when you change local code, you must run
204- `` make flake8 && make coverage ``, then check the HTML report to see
205- that test coverage has improved as a result of your changes and new unit tests.
221+ Specifically, when you change local code, you must run `` make flake8 && make coverage ``,
222+ then check the HTML report to see that test coverage has improved as a result of your
223+ changes and new unit tests.
206224
207225.. code-block :: console
208226
@@ -232,8 +250,9 @@ Pull Requests
232250Please create a GitHub `pull request `_ for any code changes that will benefit Deis users
233251in general. This workflow helps changesets map well to discrete features.
234252
235- Creating a pull request on the Deis repository also runs a Travis CI build to
236- ensure the pull request doesn't break any tests or reduce code coverage.
253+ Creating a pull request on the Deis repository also runs an integration test on
254+ http://ci.deis.io to ensure the pull request doesn't break any tests or reduce code
255+ coverage.
237256
238257
239258.. _`easy-fix` : https://github.com/deis/deis/issues?labels=easy-fix&state=open
0 commit comments