Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
27ff50c
Create router with new application
dtan4 Sep 3, 2015
e6c2082
Create initial route correctly
dtan4 Sep 3, 2015
d929d47
Create domain with new application
dtan4 Sep 3, 2015
242baf3
Register routing information for Vulcand
dtan4 Sep 3, 2015
7701449
Create DomainController
dtan4 Sep 4, 2015
d8742fc
Do not track iruka artifacts
dtan4 Sep 4, 2015
0d55ca9
Implement `iruka domain list`
dtan4 Sep 4, 2015
1f9c381
Implement `iruka domain add`
dtan4 Sep 4, 2015
4f100bf
Flatten domain CLI commands
dtan4 Sep 4, 2015
1d0078f
Fetch domain whichever ID or hostname
dtan4 Sep 4, 2015
efc99f7
Use domainIdentity
dtan4 Sep 4, 2015
c8150fa
Implement `iruka domain-remove`
dtan4 Sep 4, 2015
e1b67c7
Write JSON Schema and doc about domain
dtan4 Sep 4, 2015
0030d71
Remove update domain API
dtan4 Sep 4, 2015
c11560b
Merge pull request #3 from wantedly/dtan4/domain-cli
dtan4 Sep 4, 2015
64822f0
Reconstruct registry of domain
dtan4 Sep 4, 2015
d2eae67
Add domain.app_id in JSON Schema
dtan4 Sep 4, 2015
c099ac1
Merge pull request #4 from wantedly/dtan4/flatten-domain-reg
dtan4 Sep 4, 2015
011d9be
Reconstruct registry of route
dtan4 Sep 4, 2015
655fd29
Merge pull request #5 from wantedly/dtan4/flatten-route-reg
dtan4 Sep 4, 2015
b837a0a
Add new route to Vulcand after adding new domain
dtan4 Sep 4, 2015
58ff9a5
Merge pull request #6 from wantedly/dtan4/update-vulcand-domain
dtan4 Sep 4, 2015
155b445
Use the latest Vulcand
dtan4 Sep 4, 2015
18a40d3
Tell new container to Vulcand
dtan4 Sep 4, 2015
5bfd856
Pass router object to new agent
dtan4 Sep 8, 2015
688ff65
Modify etcd path of servers
dtan4 Sep 8, 2015
b67cc31
Inverse condition
dtan4 Sep 8, 2015
08e5379
Do not escape '&' in JSON value
dtan4 Sep 8, 2015
c62fa12
Remove unused methods
dtan4 Sep 8, 2015
f632db3
Modify frontend naming rules
dtan4 Sep 8, 2015
d0767de
Access to one app via multiple domains
dtan4 Sep 8, 2015
2178a06
Skip if errors are raised in agent
dtan4 Sep 8, 2015
ed446bb
Show register container message
dtan4 Sep 8, 2015
4c94ab9
Remove etcd directory with route
dtan4 Sep 8, 2015
a7159b1
Add TODO comments
dtan4 Sep 8, 2015
fdeeddc
Suppress skip messages about irukad and vulcand
dtan4 Sep 8, 2015
4a7d94a
Start vulcand service at launch
dtan4 Sep 8, 2015
58afcc9
Merge pull request #7 from wantedly/dtan4/update-vulcand-domain
dtan4 Sep 8, 2015
54c8718
Disable timeout not to prevent docker pull
dtan4 Sep 8, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ gin-bin
# iruka artifacts
#
artifacts
iruka
iruka/iruka
irukad/irukad
iruka.yml
28 changes: 25 additions & 3 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package agent
import (
"fmt"
"os"
"strconv"
"strings"
"time"

"code.google.com/p/go-uuid/uuid"
"github.com/fsouza/go-dockerclient"

"github.com/spesnova/iruka/registry"
"github.com/spesnova/iruka/router"
"github.com/spesnova/iruka/schema"
)

Expand All @@ -25,10 +27,11 @@ type Agent interface {
type IrukaAgent struct {
docker *docker.Client
reg *registry.Registry
rou *router.Router
Machine string
}

func NewAgent(host, machine string, reg *registry.Registry) Agent {
func NewAgent(host, machine string, reg *registry.Registry, rou *router.Router) Agent {
if os.Getenv("IRUKA_DOCKER_HOST") != "" {
host = os.Getenv("IRUKA_DOCKER_HOST")
}
Expand All @@ -44,6 +47,7 @@ func NewAgent(host, machine string, reg *registry.Registry) Agent {
return &IrukaAgent{
docker: client,
reg: reg,
rou: rou,
Machine: machine,
}
}
Expand All @@ -61,7 +65,11 @@ func (a *IrukaAgent) Pulse() {
// Regist only containers that managed by iruka
s := strings.Split(name, ".")
if uuid.Parse((s[len(s)-1])) == nil {
fmt.Println("Skipped to register:", name)
// Vulcand is always running with iruka
if name != "irukad" && name != "vulcand" {
fmt.Println("Skipped to register:", name)
}

continue
}

Expand All @@ -76,9 +84,23 @@ func (a *IrukaAgent) Pulse() {
PublishedPort: container.Ports[0].PublicPort,
}

_, err := a.reg.UpdateContainerState(name, opts)
c, err := a.reg.UpdateContainerState(name, opts)
if err != nil {
fmt.Println(err.Error())
continue
}

url := "http://" + c.Machine + ":" + strconv.FormatInt(c.PublishedPort, 10)

if !a.rou.IsServerExists(c.AppID.String(), name) {
err = a.rou.AddServer(c.AppID.String(), name, url)

if err != nil {
fmt.Println(err.Error())
continue
}

fmt.Printf("Registered new container to %s: %s\n", c.AppID.String(), name)
}
}

Expand Down
19 changes: 19 additions & 0 deletions client/domain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package iruka

import (
"github.com/spesnova/iruka/schema"
)

func (c *Client) DomainCreate(appIdentity string, opts schema.DomainCreateOpts) (schema.Domain, error) {
var domainRes schema.Domain
return domainRes, c.Post(&domainRes, "/apps/"+appIdentity+"/domains", opts)
}

func (c *Client) DomainDelete(appIdentity, domainIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/domains/" + domainIdentity)
}

func (c *Client) DomainList(appIdentity string) ([]schema.Domain, error) {
var domainsRes []schema.Domain
return domainsRes, c.Get(&domainsRes, "/apps/"+appIdentity+"/domains")
}
20 changes: 20 additions & 0 deletions coreos/user-data.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ coreos:

[Install]
WantedBy=sockets.target
- name: vulcand.service
command: start
enable: true
content: |
[Unit]
Description=Vulcand
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
User=core
ExecStartPre=-/usr/bin/docker kill vulcand
ExecStartPre=-/usr/bin/docker rm vulcand
ExecStartPre=/usr/bin/docker pull mailgun/vulcand:v0.8.0-beta.2
ExecStart=/usr/bin/docker run --name vulcand -p 80:80 -p 443:443 -p 8182:8182 -p 8181:8181 mailgun/vulcand:v0.8.0-beta.2 /go/bin/vulcand -apiInterface=0.0.0.0 -interface=0.0.0.0 -etcd=http://10.1.42.1:4001 -port=80 -apiPort=8182
ExecStop=/usr/bin/docker stop vulcand

[Install]
WantedBy=multi-user.target
write_files:
- path: /etc/ssh/sshd_config
permissions: 0600
Expand Down
152 changes: 152 additions & 0 deletions docs/api-v1-alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,156 @@ HTTP/1.1 200 OK
```


## Domain

Domain attached to an app on iruka.

### Attributes

| Name | Type | Description | Example |
| ------- | ------- | ------- | ------- |
| **created_at** | *date-time* | when domain was created | `"2012-01-01T12:00:00Z"` |
| **id** | *uuid* | unique identifier of domain | `"01234567-89ab-cdef-0123-456789abcdef"` |
| **hostname** | *string* | domain hostname | `"example.com"` |
| **updated_at** | *date-time* | when domain was updated | `"2012-01-01T12:00:00Z"` |

### Domain Create

Create a new domain.

```
POST /apps/{app_id_or_name}/domains
```

#### Optional Parameters

| Name | Type | Description | Example |
| ------- | ------- | ------- | ------- |
| **hostname** | *string* | domain hostname | `"example.com"` |


#### Curl Example

```bash
$ curl -n -X POST https://<your-iruka-server>.com/api/v1-alpha/apps/$APP_ID_OR_NAME/domains \
-H "Content-Type: application/json" \
\
-d '{
"hostname": "example.com"
}'
```


#### Response Example

```
HTTP/1.1 201 Created
```

```json
{
"created_at": "2012-01-01T12:00:00Z",
"id": "01234567-89ab-cdef-0123-456789abcdef",
"hostname": "example.com",
"updated_at": "2012-01-01T12:00:00Z"
}
```

### Domain Delete

Delete an existing domain.

```
DELETE /apps/{app_id_or_name}/domains/{domain_id_or_hostname}
```


#### Curl Example

```bash
$ curl -n -X DELETE https://<your-iruka-server>.com/api/v1-alpha/apps/$APP_ID_OR_NAME/domains/$DOMAIN_ID_OR_HOSTNAME \
-H "Content-Type: application/json" \
```


#### Response Example

```
HTTP/1.1 200 OK
```

```json
{
"created_at": "2012-01-01T12:00:00Z",
"id": "01234567-89ab-cdef-0123-456789abcdef",
"hostname": "example.com",
"updated_at": "2012-01-01T12:00:00Z"
}
```

### Domain Info

Info for existing domain.

```
GET /apps/{app_id_or_name}/domains/{domain_id_or_hostname}
```


#### Curl Example

```bash
$ curl -n https://<your-iruka-server>.com/api/v1-alpha/apps/$APP_ID_OR_NAME/domains/$DOMAIN_ID_OR_HOSTNAME
```


#### Response Example

```
HTTP/1.1 200 OK
```

```json
{
"created_at": "2012-01-01T12:00:00Z",
"id": "01234567-89ab-cdef-0123-456789abcdef",
"hostname": "example.com",
"updated_at": "2012-01-01T12:00:00Z"
}
```

### Domain List

List existing domains.

```
GET /apps/{app_id_or_name}/domains
```


#### Curl Example

```bash
$ curl -n https://<your-iruka-server>.com/api/v1-alpha/apps/$APP_ID_OR_NAME/domains
```


#### Response Example

```
HTTP/1.1 200 OK
```

```json
[
{
"created_at": "2012-01-01T12:00:00Z",
"id": "01234567-89ab-cdef-0123-456789abcdef",
"hostname": "example.com",
"updated_at": "2012-01-01T12:00:00Z"
}
]
```



3 changes: 3 additions & 0 deletions iruka/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var Commands = []cli.Command{
cmdCreate,
cmdConfig,
cmdDestroy,
cmdDomains,
cmdDomainAdd,
cmdDomainRemove,
cmdPs,
cmdDeploy,
cmdOpen,
Expand Down
47 changes: 47 additions & 0 deletions iruka/domain-add.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"fmt"
"os"

"github.com/codegangsta/cli"

"github.com/spesnova/iruka/schema"
)

var cmdDomainAdd = cli.Command{
Name: "domain-add",
Usage: "Add a custom domain to the app",
Description: `
$ iruka domain- add <DOMAIN>

EXAMPLE:

$ iruka domain-add example.com
Adding example.com to example... done
`,
Action: runDomainAdd,
}

func runDomainAdd(c *cli.Context) {
if len(c.Args()) < 1 {
cli.ShowCommandHelp(c, "add")
os.Exit(1)
}

appIdentity := getAppIdentity(c)
hostname := c.Args().First()
opts := schema.DomainCreateOpts{
Hostname: hostname,
}

fmt.Printf("Adding %s to %s...", hostname, appIdentity)
_, err := client.DomainCreate(appIdentity, opts)

if err != nil {
fmt.Println(err)
os.Exit(1)
}

fmt.Println("done")
}
37 changes: 37 additions & 0 deletions iruka/domain-remove.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"fmt"
"os"

"github.com/codegangsta/cli"
)

var cmdDomainRemove = cli.Command{
Name: "domain-remove",
Usage: "Remove a custom domain from the app",
Description: `
$ iruka domain-remove <Domain>

EXAMPLE:

$ iruka domain-remove example.com
Removing example.com from example... done
`,
Action: runDomainRemove,
}

func runDomainRemove(c *cli.Context) {
appIdentity := getAppIdentity(c)
hostname := c.Args().First()

fmt.Printf("Removing %s from %s...", hostname, appIdentity)
err := client.DomainDelete(appIdentity, hostname)

if err != nil {
fmt.Println(err)
os.Exit(1)
}

fmt.Println("done")
}
Loading