Skip to content

Commit d4e13a4

Browse files
Gabriel MonroyMatthew Fisher
authored andcommitted
refactor(scheduler): coreos scheduler implementation
Note an SSH wrapper is used to get around fleetctl ssh-agent requirement. We will ultimately want to transition to an HTTP API for talking to fleet. Until then, we should explore modifying fleetctl to remove the ssh-agent requirement for tunneling. add cluster setup and teardown announce to /deis/services/{container_name} with a sidekick container - add pull before start - add stop and remove in ExecStop - use hardcoded expose port 5000 for deis/slugrunner parallelize scheduler tasks, add appropriate blocking exclude scheduler from max-line-length add sidekick container for logging, unit cleanup add unit name regex, use it when templating units add domain and options to SchedulerClient fix destroy bug update readme to reflect new scheduler workflow, with placeholders for not-yet-implemented features first pass at systemd units for components coreos contrib scripts, units and user-data helpers
1 parent 30f1651 commit d4e13a4

26 files changed

Lines changed: 782 additions & 82 deletions

README.md

Lines changed: 104 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,138 @@
11
# Deis
22

3-
Deis is a Django/Celery API server, Python CLI and set of [Chef cookbooks](https://github.com/opdemand/deis-cookbook) that combine to provide a Heroku-inspired application platform for public and private clouds. Your PaaS. Your Rules.
3+
Deis is an open source PaaS that makes it easy to deploy, scale and manage Docker containers used to host applications and services. Deis builds upon Docker and CoreOS to provide a private PaaS that is lightweight and flexible.
44

55
[![Build Status](https://travis-ci.org/opdemand/deis.png?branch=master)](https://travis-ci.org/opdemand/deis)
66
[![Coverage Status](https://coveralls.io/repos/opdemand/deis/badge.png?branch=master)](https://coveralls.io/r/opdemand/deis?branch=master)
77

88
![Deis Graphic](https://s3-us-west-2.amazonaws.com/deis-images/deis-graphic.png)
99

10-
## What is Deis?
10+
# Installation
1111

12-
Deis is an open source PaaS that makes it easy to deploy and scale LXC containers and Chef nodes used to host applications, databases, middleware and other services. Deis leverages Chef, Docker and Heroku Buildpacks to provide a private PaaS that is lightweight and flexible.
12+
Deis is a set of Docker containers that can be deployed anywhere including public cloud, private cloud, bare metal or your workstation. You will need Docker and a CoreOS cluster to get started.
1313

14-
Deis comes with out-of-the-box support for Ruby, Python, Node.js, Java, Clojure, Scala, Play, PHP, Perl, Dart and Go. However, Deis can deploy *anything* using Heroku Buildpacks, Docker images or Chef recipes. Deis can be deployed on any system including every public cloud, private cloud or bare metal.
14+
## Run Deis
1515

16-
## Why Deis?
16+
Build Deis and run the `deis/deis` Docker image.
1717

18-
##### Deploy anything
18+
```
19+
make build
20+
make run
21+
```
1922

20-
Deploy a wide range of languages and frameworks with a simple `git push` using [Heroku Buildpacks](https://devcenter.heroku.com/articles/buildpacks) or [Dockerfiles](http://docs.docker.io/en/latest/use/builder/). Use custom Chef layers to deploy databases, middleware and other add-on services.
23+
## Install the Deis Client
24+
Use `pip` to install the latest Deis Client, or download pre-compiled binares.
2125

22-
##### Control everything
26+
```
27+
pip install deis
28+
```
2329

24-
Choose your hosting provider configuration. Define a [formation](http://docs.deis.io/en/latest/gettingstarted/concepts) with your own proxy and runtime layers. Retain full root access to every node. Manage your platform with a private Deis controller.
30+
## Register a User
31+
Use the Deis Client to register a new user.
2532

26-
##### Scale effortlessly
33+
```
34+
deis register http://localhost:8000
35+
```
2736

28-
Scale nodes and containers with a single command. Node provisioning, container balancing and proxy reconfiguration are completely automated.
37+
## Initalize a Cluster
2938

30-
##### 100% Open Source
39+
Initalize a `dev` cluster with a list of CoreOS hosts and your CoreOS private key.
3140

32-
Free, transparent and easily customized. Join the open-source PaaS and DevOps community by using Deis and complimentary projects like Docker, Chef and Heroku Buildpacks.
41+
```
42+
deis clusters:create dev deisapp.com --hosts=coreos-host1,coreos-host2,coreos-host3 --auth=~/.ssh/coreos
43+
```
3344

34-
## Getting Started
45+
The `dev` cluster will be used as the default cluster for future `deis` commands.
3546

36-
First read about Deis core [concepts](http://docs.deis.io/en/latest/gettingstarted/concepts/) so you can answer:
47+
# Usage
3748

38-
* What is a [Formation](http://docs.deis.io/en/latest/gettingstarted/concepts/#formations) and how does it relate to an application?
39-
* What are [Layers and Nodes](http://docs.deis.io/en/latest/gettingstarted/concepts/#layers), and how do they work with Chef?
40-
* How does the [Build, Release, Run](http://docs.deis.io/en/latest/gettingstarted/concepts/#build-release-run) process work?
41-
* How do I connect an application to [backing services](http://docs.deis.io/en/latest/gettingstarted/concepts/#backing-services)?
49+
## Create an Application
50+
Create an application on the default `dev` cluster.
4251

43-
Next, choose which cloud provider should host your Deis controller.
44-
Regardless of whether your controller is hosted with
45-
[Amazon EC2](http://docs.deis.io/en/latest/installation/ec2/),
46-
[Rackspace](http://docs.deis.io/en/latest/installation/rackspace/), or
47-
[DigitalOcean](http://docs.deis.io/en/latest/installation/digitalocean/),
48-
it can create and manage nodes on any of those cloud providers.
52+
```
53+
deis create
54+
```
4955

50-
Proceed to the [Operations Guide](http://docs.deis.io/en/latest/operations/)
51-
documentation to start building your own private PaaS.
56+
Use `deis create --cluster=prod` to place the app on a different cluster. Don't like our name-generator? Use `deis create myappname`.
5257

53-
## Credits
58+
## Push
59+
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.
5460

55-
Deis stands on the shoulders of leading open source technologies:
61+
#### From a Git Repository
62+
When you created the application, a git remote for Deis was added automatically.
5663

57-
* [Chef](http://www.opscode.com/)
58-
* [Docker](http://www.docker.io/)
59-
* [Django](https://www.djangoproject.com/)
60-
* [Celery](http://www.celeryproject.org/)
61-
* [Heroku Buildpacks](https://devcenter.heroku.com/articles/buildpacks)
62-
* [Slugbuilder](https://github.com/flynn/slugbuilder) and [slugrunner](https://github.com/flynn/slugrunner)
64+
```
65+
git push deis master
66+
```
67+
This will use the Deis builder to package your application as a Docker Image and deploy it on your application's cluster.
68+
69+
#### From a Docker Registry
70+
71+
You can also push builds directly from the Docker Index or a private Docker registry. First, build and push the Docker images as you normally do:
72+
73+
```
74+
docker build -t gabrtv/example
75+
docker push gabrtv/example
76+
```
77+
78+
Then use `deis push` to deploy.
79+
80+
```
81+
deis push gabrtv/example
82+
```
83+
84+
Use the fully qualfied image path to push from a private registry: `deis push registry.local:5000/gabrtv/example`
85+
86+
## Configure
87+
Configure your application with environment variables. Each config change also creates a new release.
88+
89+
```
90+
deis config:set DATABASE_URL=postgres://
91+
```
92+
93+
Coming soon: Use the integrated ETCD namespace for service discovery between applications on the same cluster.
94+
95+
## Test
96+
Test your application by running commands inside an ephemeral Docker container.
97+
98+
```
99+
deis run make test
100+
```
101+
102+
To integrate with your CI system, check the return code.
103+
104+
## Scale
105+
Scale containers horizontally with ease.
106+
107+
```
108+
deis scale 8
109+
```
110+
111+
To scale by process type, use `deis scale web=8 worker=2` . Just make sure the process types can be run via `/start web`.
112+
113+
## Publish
114+
Publish your application via each cluster's integrated router.
115+
116+
```
117+
deis publish 8080/http
118+
deis domain myapp.example.com
119+
```
120+
121+
Use `deis open` to pop into a browser pointed at your application. Use `--sslCert=cert.pem --sslKey=key.pem` to secure the connection with SSL/TLS.
122+
123+
## Debug
124+
Access to aggregated logs makes it easy to troubleshoot problems with your application.
125+
126+
```
127+
deis logs
128+
```
129+
130+
Use `deis run` to execute one-off commands and explore the deployed container. Coming soon: `deis attach` to jump into a live container.
63131

64132
## License
65133

66-
Copyright 2013, OpDemand LLC
134+
Copyright 2014, OpDemand LLC
67135

68136
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>
69137

70138
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.
71-
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=deis-builder
3+
After=docker.service
4+
Requires=docker.service
5+
Requires=docker-tcp.socket
6+
7+
[Service]
8+
ExecStart=/bin/bash -c '/usr/bin/docker start -a deis-builder || /usr/bin/docker run --name deis-builder -P -e HOST=10.1.42.1 -e ETCD=10.1.42.1:4001--privileged deis/builder'
9+
ExecStop=/usr/bin/docker stop deis-builder
10+
11+
[Install]
12+
WantedBy=multi-user.target

cache/systemd/deis-cache.service

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=deis-cache
3+
After=docker.service
4+
Requires=docker.service
5+
Requires=docker-tcp.socket
6+
7+
[Service]
8+
ExecStart=/bin/bash -c '/usr/bin/docker start -a deis-cache || /usr/bin/docker run --name deis-cache -P -e HOST=10.1.42.1 -e ETCD=10.1.42.1:4001 deis/cache'
9+
ExecStop=/usr/bin/docker stop deis-cache
10+
11+
[Install]
12+
WantedBy=multi-user.target
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#cloud-config
2+
coreos:
3+
etcd:
4+
addr: 172.17.8.100:4001
5+
peer-addr: 172.17.8.100:7001
6+
units: []

contrib/coreos/gen-user-data.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/ruby
2+
# encoding: utf-8
3+
4+
# NOTE: proper serialization of yaml literal blocks seems to require ruby 2.0
5+
require 'yaml'
6+
7+
def prepare_units
8+
units = []
9+
source_dirs = [
10+
File.join('contrib/coreos/systemd'),
11+
#File.join('controller/systemd'),
12+
#File.join('cache/systemd'),
13+
#File.join('database/systemd'),
14+
#File.join('logger/systemd'),
15+
#File.join('registry/systemd'),
16+
#File.join('router/systemd'),
17+
]
18+
source_dirs.each do |dir|
19+
Dir.glob(File.join(dir, '*')) do |path|
20+
name = File.basename(path)
21+
unit = {'name' => name, 'command' => 'start',
22+
'content' => IO.read(path)}
23+
units.push(unit)
24+
end
25+
end
26+
return units
27+
end
28+
29+
# join generated/default user-data and write to stdout
30+
user_data = YAML.load_file('contrib/coreos/default-user-data.yml')
31+
user_data['coreos']['units'].concat(prepare_units())
32+
puts "#cloud-config\n"
33+
puts user_data.to_yaml

contrib/coreos/override-plugin.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# -*- mode: ruby -*-
2+
# # vi: set ft=ruby :
3+
4+
# <hack>
5+
6+
# NOTE: This monkey-patching of the coreos guest plugin is a terrible
7+
# hack that needs to be removed once the upstream plugin works with the
8+
# new CoreOS images.
9+
10+
require Vagrant.source_root.join("plugins/guests/coreos/cap/configure_networks.rb")
11+
12+
module VagrantPlugins
13+
module GuestCoreOS
14+
module Cap
15+
class ConfigureNetworks
16+
include Vagrant::Util
17+
18+
def self.configure_networks(machine, networks)
19+
machine.communicate.tap do |comm|
20+
# Read network interface names
21+
interfaces = []
22+
comm.sudo("ifconfig | grep enp0 | cut -f1 -d:") do |_, result|
23+
interfaces = result.split("\n")
24+
end
25+
26+
# Configure interfaces
27+
# FIXME: fix matching of interfaces with IP adresses
28+
networks.each do |network|
29+
comm.sudo("ifconfig #{interfaces[network[:interface].to_i]} #{network[:ip]} netmask #{network[:netmask]}")
30+
end
31+
32+
end
33+
end
34+
end
35+
36+
class ChangeHostName
37+
def self.change_host_name(machine, name)
38+
# do nothing!
39+
end
40+
end
41+
end
42+
end
43+
end
44+
45+
# </hack>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=Docker Socket for Remote API
3+
4+
[Socket]
5+
ListenStream=4243
6+
Service=docker.service
7+
BindIPv6Only=both
8+
9+
[Install]
10+
WantedBy=sockets.target
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=etcd
3+
4+
[Service]
5+
User=etcd
6+
PermissionsStartOnly=true
7+
Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default
8+
ExecStart=/usr/bin/etcd
9+
Restart=always
10+
RestartSec=10s
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=fleet
3+
4+
[Service]
5+
ExecStart=/usr/bin/fleet
6+
7+
[Install]
8+
WantedBy=multi-user.target
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=stop update-engine-reboot-manager
3+
4+
[Service]
5+
Type=oneshot
6+
ExecStart=/usr/bin/systemctl stop update-engine-reboot-manager.service
7+
ExecStartPost=/usr/bin/systemctl mask update-engine-reboot-manager.service
8+
9+
[Install]
10+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)