Browse code

Merge pull request #135 from amesserl/raxcloud-support

Added support to use docker with Rackspace Cloud Servers

Solomon Hykes authored on 2013/03/27 08:55:01
Showing 3 changed files
... ...
@@ -8,8 +8,11 @@ Docker is a great building block for automating distributed systems: large-scale
8 8
 <img src="http://bricks.argz.com/bricksfiles/lego/07000/7823/012.jpg"/>
9 9
 
10 10
 * *Heterogeneous payloads*: any combination of binaries, libraries, configuration files, scripts, virtualenvs, jars, gems, tarballs, you name it. No more juggling between domain-specific tools. Docker can deploy and run them all.
11
+
11 12
 * *Any server*: docker can run on any x64 machine with a modern linux kernel - whether it's a laptop, a bare metal server or a VM. This makes it perfect for multi-cloud deployments.
13
+
12 14
 * *Isolation*: docker isolates processes from each other and from the underlying host, using lightweight containers.
15
+
13 16
 * *Repeatability*: because containers are isolated in their own filesystem, they behave the same regardless of where, when, and alongside what they run.
14 17
 
15 18
 
... ...
@@ -17,14 +20,21 @@ Notable features
17 17
 -----------------
18 18
 
19 19
 * Filesystem isolation: each process container runs in a completely separate root filesystem.
20
+
20 21
 * Resource isolation: system resources like cpu and memory can be allocated differently to each process container, using cgroups.
22
+
21 23
 * Network isolation: each process container runs in its own network namespace, with a virtual interface and IP address of its own.
24
+
22 25
 * Copy-on-write: root filesystems are created using copy-on-write, which makes deployment extremeley fast, memory-cheap and disk-cheap.
26
+
23 27
 * Logging: the standard streams (stdout/stderr/stdin) of each process container are collected and logged for real-time or batch retrieval.
28
+
24 29
 * Change management: changes to a container's filesystem can be committed into a new image and re-used to create more containers. No templating or manual configuration required.
30
+
25 31
 * Interactive shell: docker can allocate a pseudo-tty and attach to the standard input of any container, for example to run a throwaway interactive shell.
26 32
 
27 33
 
34
+
28 35
 Under the hood
29 36
 --------------
30 37
 
... ...
@@ -32,8 +42,11 @@ Under the hood, Docker is built on the following components:
32 32
 
33 33
 
34 34
 * The [cgroup](http://blog.dotcloud.com/kernel-secrets-from-the-paas-garage-part-24-c) and [namespacing](http://blog.dotcloud.com/under-the-hood-linux-kernels-on-dotcloud-part) capabilities of the Linux kernel;
35
+
35 36
 * [AUFS](http://aufs.sourceforge.net/aufs.html), a powerful union filesystem with copy-on-write capabilities;
37
+
36 38
 * The [Go](http://golang.org) programming language;
39
+
37 40
 * [lxc](http://lxc.sourceforge.net/), a set of convenience scripts to simplify the creation of linux containers.
38 41
 
39 42
 
... ...
@@ -159,6 +172,7 @@ Want to hack on Docker? Awesome! There are instructions to get you started on th
159 159
 
160 160
 They are probably not perfect, please let us know if anything feels wrong or incomplete.
161 161
 
162
+### Pull requests are always welcome
162 163
 
163 164
 Note
164 165
 ----
... ...
@@ -168,5 +182,140 @@ Please find it under docs/sources/ and read more about it https://github.com/dot
168 168
 
169 169
 Please feel free to fix / update the documentation and send us pull requests. More tutorials are also welcome.
170 170
 
171
+### Discuss your design on the mailing list
172
+
173
+We recommend discussing your plans [on the mailing list](https://groups.google.com/forum/?fromgroups#!forum/docker-club) before starting to code - especially for more ambitious contributions. This gives other contributors a chance to point
174
+you in the right direction, give feedback on your design, and maybe point out if someone else is working on the same thing.
175
+
176
+### Create issues...
177
+
178
+Any significant improvement should be documented as [a github issue](https://github.com/dotcloud/docker/issues) before anybody starts working on it.
179
+
180
+### ...but check for existing issues first!
181
+
182
+Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal.
183
+If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common problems and requests.
184
+
185
+
186
+### Write tests
187
+
188
+Golang has a great testing suite built in: use it! Take a look at existing tests for inspiration.
189
+
190
+
191
+
192
+Setting up a dev environment
193
+----------------------------
194
+
195
+Instructions that have been verified to work on Ubuntu 12.10,
196
+
197
+```bash
198
+sudo apt-get -y install lxc wget bsdtar curl golang git
199
+
200
+export GOPATH=~/go/
201
+export PATH=$GOPATH/bin:$PATH
202
+
203
+mkdir -p $GOPATH/src/github.com/dotcloud
204
+cd $GOPATH/src/github.com/dotcloud
205
+git clone git@github.com:dotcloud/docker.git
206
+cd docker
207
+
208
+go get -v github.com/dotcloud/docker/...
209
+go install -v github.com/dotcloud/docker/...
210
+```
211
+
212
+Then run the docker daemon,
213
+
214
+```bash
215
+sudo $GOPATH/bin/docker -d
216
+```
217
+
218
+Run the `go install` command (above) to recompile docker.
219
+
220
+
221
+What is a Standard Container?
222
+=============================
223
+
224
+Docker defines a unit of software delivery called a Standard Container. The goal of a Standard Container is to encapsulate a software component and all its dependencies in
225
+a format that is self-describing and portable, so that any compliant runtime can run it without extra dependencies, regardless of the underlying machine and the contents of the container.
226
+
227
+The spec for Standard Containers is currently a work in progress, but it is very straightforward. It mostly defines 1) an image format, 2) a set of standard operations, and 3) an execution environment.
228
+
229
+A great analogy for this is the shipping container. Just like Standard Containers are a fundamental unit of software delivery, shipping containers (http://bricks.argz.com/ins/7823-1/12) are a fundamental unit of physical delivery.
230
+
231
+### 1. STANDARD OPERATIONS
232
+
233
+Just like shipping containers, Standard Containers define a set of STANDARD OPERATIONS. Shipping containers can be lifted, stacked, locked, loaded, unloaded and labelled. Similarly, standard containers can be started, stopped, copied, snapshotted, downloaded, uploaded and tagged.
234
+
235
+
236
+### 2. CONTENT-AGNOSTIC
237
+
238
+Just like shipping containers, Standard Containers are CONTENT-AGNOSTIC: all standard operations have the same effect regardless of the contents. A shipping container will be stacked in exactly the same way whether it contains Vietnamese powder coffee or spare Maserati parts. Similarly, Standard Containers are started or uploaded in the same way whether they contain a postgres database, a php application with its dependencies and application server, or Java build artifacts.
239
+
240
+
241
+### 3. INFRASTRUCTURE-AGNOSTIC
242
+
243
+Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be transported to thousands of facilities around the world, and manipulated by a wide variety of equipment. A shipping container can be packed in a factory in Ukraine, transported by truck to the nearest routing center, stacked onto a train, loaded into a German boat by an Australian-built crane, stored in a warehouse at a US facility, etc. Similarly, a standard container can be bundled on my laptop, uploaded to S3, downloaded, run and snapshotted by a build server at Equinix in Virginia, uploaded to 10 staging servers in a home-made Openstack cluster, then sent to 30 production instances across 3 EC2 regions.
244
+
245
+
246
+### 4. DESIGNED FOR AUTOMATION
247
+
248
+Because they offer the same standard operations regardless of content and infrastructure, Standard Containers, just like their physical counterpart, are extremely well-suited for automation. In fact, you could say automation is their secret weapon.
249
+
250
+Many things that once required time-consuming and error-prone human effort can now be programmed. Before shipping containers, a bag of powder coffee was hauled, dragged, dropped, rolled and stacked by 10 different people in 10 different locations by the time it reached its destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The process was slow, inefficient and cost a fortune - and was entirely different depending on the facility and the type of goods.
251
+
252
+Similarly, before Standard Containers, by the time a software component ran in production, it had been individually built, configured, bundled, documented, patched, vendored, templated, tweaked and instrumented by 10 different people on 10 different computers. Builds failed, libraries conflicted, mirrors crashed, post-it notes were lost, logs were misplaced, cluster updates were half-broken. The process was slow, inefficient and cost a fortune - and was entirely different depending on the language and infrastructure provider.
253
+
254
+
255
+### 5. INDUSTRIAL-GRADE DELIVERY
256
+
257
+There are 17 million shipping containers in existence, packed with every physical good imaginable. Every single one of them can be loaded on the same boats, by the same cranes, in the same facilities, and sent anywhere in the World with incredible efficiency. It is embarrassing to think that a 30 ton shipment of coffee can safely travel half-way across the World in *less time* than it takes a software team to deliver its code from one datacenter to another sitting 10 miles away.
258
+
259
+With Standard Containers we can put an end to that embarrassment, by making INDUSTRIAL-GRADE DELIVERY of software a reality.
260
+
261
+
262
+
263
+
264
+Standard Container Specification
265
+--------------------------------
266
+
267
+(TODO)
268
+
269
+### Image format
270
+
271
+
272
+### Standard operations
273
+
274
+* Copy
275
+* Run
276
+* Stop
277
+* Wait
278
+* Commit
279
+* Attach standard streams
280
+* List filesystem changes
281
+* ...
282
+
283
+### Execution environment
284
+
285
+#### Root filesystem
286
+
287
+#### Environment variables
288
+
289
+#### Process arguments
290
+
291
+#### Networking
292
+
293
+#### Process namespacing
294
+
295
+#### Resource limits
296
+
297
+#### Process monitoring
298
+
299
+#### Logging
300
+
301
+#### Signals
302
+
303
+#### Pseudo-terminal allocation
304
+
305
+#### Security
171 306
 
172 307
 
... ...
@@ -31,12 +31,12 @@ def v10(config)
31 31
   # computers to access the VM, whereas host only networking does not.
32 32
   # config.vm.forward_port 80, 8080
33 33
 
34
+  # Ensure puppet is installed on the instance
35
+  config.vm.provision :shell, :inline => "apt-get -qq update; apt-get install -y puppet"
36
+
34 37
   # Share an additional folder to the guest VM. The first argument is
35 38
   # an identifier, the second is the path on the guest to mount the
36 39
   # folder, and the third is the path on the host to the actual folder.
37
-  if not File.exist? File.expand_path '~/docker'
38
-    Dir.mkdir(File.expand_path '~/docker')
39
-  end
40 40
   config.vm.share_folder "v-data", "~/docker", "~/docker"
41 41
 
42 42
   # Enable provisioning with Puppet stand alone.  Puppet manifests
... ...
@@ -123,6 +123,16 @@ end
123 123
     aws.ssh_username = "vagrant"
124 124
     aws.instance_type = "t1.micro"
125 125
   end
126
+  config.vm.provider :rackspace do |rs|
127
+    config.vm.box = "dummy"
128
+    config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box"
129
+    config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"]
130
+    rs.username = ENV["RS_USERNAME"]
131
+    rs.api_key  = ENV["RS_API_KEY"]
132
+    rs.public_key_path = ENV["RS_PUBLIC_KEY"] 
133
+    rs.flavor   = /512MB/
134
+    rs.image    = /Ubuntu/
135
+  end   
126 136
   config.vm.provider :virtualbox do |vb|
127 137
     config.vm.box = "quantal64_3.5.0-25"
128 138
     config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box"
... ...
@@ -25,6 +25,9 @@ class virtualbox {
25 25
 class ec2 {
26 26
 }
27 27
 
28
+class rax {
29
+}
30
+
28 31
 class docker {
29 32
 
30 33
     # update this with latest docker binary distro
... ...
@@ -42,21 +45,47 @@ class docker {
42 42
 
43 43
     notify { "docker_url = $docker_url": withpath => true }
44 44
 
45
-	$ec2_version = file("/etc/ec2_version", "/dev/null")
46
-	if ($ec2_version) {
47
-		include ec2
48
-	} else {
49
-		# virtualbox is the vagrant default, so it should be safe to assume
50
-		include virtualbox
51
-	}
45
+    $ec2_version = file("/etc/ec2_version", "/dev/null")
46
+    $rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>")
47
+
48
+    if ($ec2_version) {
49
+	include ec2
50
+    } elsif ($rax_version) {
51
+        include rax
52
+    } else {
53
+    # virtualbox is the vagrant default, so it should be safe to assume
54
+        include virtualbox
55
+    }
52 56
 
53 57
     user { "vagrant":
54 58
         ensure => present,
55 59
         comment => "Vagrant User",
56 60
         shell => "/bin/bash",
57 61
         home => "/home/vagrant",
62
+        groups => [
63
+            "sudo",
64
+            "vagrant",
65
+            "ubuntu",
66
+        ],
67
+        require => [
68
+            Group["sudo"],
69
+            Group["vagrant"],
70
+            Group["ubuntu"],
71
+        ],
58 72
     }
59 73
 
74
+	group { "ubuntu":
75
+		ensure => present,
76
+	}
77
+
78
+	group { "vagrant":
79
+		ensure => present,
80
+	}
81
+
82
+	group { "sudo":
83
+		ensure => present,
84
+	}
85
+
60 86
 	file { "/usr/local/bin":
61 87
 		ensure => directory,
62 88
 		owner => root,
... ...
@@ -84,6 +113,7 @@ class docker {
84 84
     }
85 85
 
86 86
     file { "/home/vagrant":
87
+        ensure => directory,
87 88
         mode => 644,
88 89
         require => User["vagrant"],
89 90
     }
... ...
@@ -91,7 +121,7 @@ class docker {
91 91
     file { "/home/vagrant/.profile":
92 92
         mode => 644,
93 93
         owner => "vagrant",
94
-        group => "ubuntu",
94
+        group => "vagrant",
95 95
         content => template("docker/profile"),
96 96
         require => File["/home/vagrant"],
97 97
     }