Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit fc0646f

Browse files
author
David Chung
authored
docs for ingress; refactor for scope plugin lookups (#752)
Signed-off-by: David Chung <[email protected]>
1 parent 6eeda29 commit fc0646f

File tree

24 files changed

+682
-113
lines changed

24 files changed

+682
-113
lines changed

docs/controller/ingress/README.md

Lines changed: 432 additions & 0 deletions
Large diffs are not rendered by default.

docs/controller/ingress/example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ metadata:
4343
# options block map to pkg/controller/ingress/types/Options
4444
options:
4545
# SyncInterval is how often to sync changes between the services and the LB
46-
SyncInterval: 1s # syntax is a string form of Go time.Duration
46+
SyncInterval: 10s # syntax is a string form of Go time.Duration
4747

4848
# properties block map to pkg/controller/ingress/types/Properties
4949
properties:

docs/controller/ingress/example2.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#
2+
# Example Ingress YML that will sync services in Docker Swarm to the backend.
3+
# The backend is specified by the L4Plugin property.
4+
#
5+
# To run this:
6+
#
7+
# INFRAKIT_MANAGER_BACKEND=swarm infrakit plugin start manager simulator ingress
8+
#
9+
# In another console:
10+
# infrakit ingress controller commit -y path/to/this/file
11+
#
12+
# Creating Docker services
13+
# docker network create --driver overlay --ingress ingress
14+
# docker service create --network ingress --name t2 --publish 7777:80 nginx
15+
#
16+
# Verify that the route has been added in the simulator/lb1:
17+
# infrakit simulator/lb1 routes ls
18+
#
19+
# FRONTEND PORT PROTOCOL BACKEND PORT CERT
20+
# 7777 TCP 7777 <-- from the swarm service
21+
# 80 http 8080 <-- from the static route in the config
22+
#
23+
# In Docker:
24+
# docker service ls
25+
#ID NAME MODE REPLICAS IMAGE PORTS
26+
#m4fghruao79i t2 replicated 1/1 nginx:latest *:7777->80/tcp
27+
#
28+
# Remove the service
29+
# docker service rm t2
30+
#
31+
# infrakit simulator/lb1 routes ls # should be empty
32+
#
33+
# FRONTEND PORT PROTOCOL BACKEND PORT CERT
34+
# 80 http 8080 <-- from the static route
35+
#
36+
# Note that there are two loadbalancers configured in this example. When you scale up / down the
37+
# shared group/workers, the backends of simulator/lb1 and simulator/lb2 should have the same backend nodes,
38+
# but the routes are different -- simulator/lb1 routes are driven by Docker swarm services, while the routes
39+
# for simulator/lb2 is static.
40+
#
41+
kind: ingress
42+
metadata:
43+
name: test.com
44+
tags:
45+
project: testing
46+
user: chungers
47+
48+
# options block map to pkg/controller/ingress/types/Options
49+
options:
50+
# SyncInterval is how often to sync changes between the services and the LB
51+
SyncInterval: 10s # syntax is a string form of Go time.Duration
52+
53+
# properties block map to pkg/controller/ingress/types/Properties
54+
properties:
55+
# Note that this section is missing a Vhost (so Vhost is ''). An empty Vhost entry will match all docker swarm
56+
# services (since we have not defined the labeling convention for indicating the vhost of a service -- so all
57+
# services match to ''. This is in contrast to the Vhost of the next section, where we use a different vhost
58+
# so that the routes for the L4 will not pick up those from Swarm services.
59+
- Backends:
60+
Groups:
61+
- group/workers # This is a group at socket(group), groupID(workers).
62+
63+
# This is the plugin name of the L4 plugin. When you run `infrakit plugin start ... simulator`
64+
# the default socket file name is 'simulator' and there's a default lb2 in the RPC object.
65+
L4Plugin: simulator/lb1
66+
67+
# Plus all the services in Swarm that have --publish <frontend-port>:<container_port>
68+
RouteSources:
69+
swarm:
70+
Host: unix:///var/run/docker.sock
71+
- Vhost: system
72+
Backends:
73+
Groups:
74+
- group/workers # This is a group at socket(group), groupID(workers).
75+
76+
L4Plugin: simulator/lb2
77+
78+
# Here we have a static route that is always present.
79+
Routes:
80+
- LoadBalancerPort: 80
81+
LoadBalancerProtocol: https
82+
Port: 8080
83+
Protocol: http

docs/controller/ingress/group.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# A group of workers
3+
#
4+
# Start up -- plugin start should include manager, vanilla, simulator, and group
5+
# Then commit
6+
#
7+
# infrakit group controller commit -y docs/controller/enrollment/group.yml
8+
#
9+
kind: group
10+
metadata:
11+
name: workers
12+
properties:
13+
Allocation:
14+
Size: 5
15+
Flavor:
16+
Plugin: vanilla
17+
Properties:
18+
Attachments:
19+
- ID: attachid
20+
Type: attachtype
21+
Init:
22+
- docker pull nginx:alpine
23+
- docker run -d -p 80:80 nginx-alpine
24+
Tags:
25+
project: infrakit
26+
tier: web
27+
Instance:
28+
Plugin: simulator/compute
29+
Properties:
30+
Note: custom field

pkg/cli/v0/controller/cmd.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ package controller
33
import (
44
"github.com/docker/infrakit/pkg/cli"
55
"github.com/docker/infrakit/pkg/controller"
6-
"github.com/docker/infrakit/pkg/discovery"
76
logutil "github.com/docker/infrakit/pkg/log"
8-
"github.com/docker/infrakit/pkg/plugin"
9-
controller_rpc "github.com/docker/infrakit/pkg/rpc/controller"
107
"github.com/spf13/cobra"
118
)
129

@@ -35,13 +32,3 @@ func Controller(name string, services *cli.Services) *cobra.Command {
3532

3633
return controller
3734
}
38-
39-
// Load loads the typed object
40-
func Load(plugins discovery.Plugins, name string) (controller.Controller, error) {
41-
pn := plugin.Name(name)
42-
endpoint, err := plugins.Find(pn)
43-
if err != nil {
44-
return nil, err
45-
}
46-
return controller_rpc.NewClient(pn, endpoint.Address)
47-
}

pkg/cli/v0/controller/commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Commit(name string, services *cli.Services) *cobra.Command {
2727
os.Exit(1)
2828
}
2929

30-
c, err := Load(services.Scope.Plugins(), name)
30+
c, err := services.Scope.Controller(name)
3131
if err != nil {
3232
return nil
3333
}

pkg/cli/v0/controller/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func Describe(name string, services *cli.Services) *cobra.Command {
3636
}
3737
}
3838

39-
controller, err := Load(services.Scope.Plugins(), name)
39+
controller, err := services.Scope.Controller(name)
4040
if err != nil {
4141
return nil
4242
}

pkg/cli/v0/loadbalancer/backends.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Backends(name string, services *cli.Services) *cobra.Command {
3030
os.Exit(1)
3131
}
3232

33-
l4, err := Load(services.Scope.Plugins(), name)
33+
l4, err := services.Scope.L4(name)
3434
if err != nil {
3535
return nil
3636
}
@@ -56,7 +56,7 @@ func Backends(name string, services *cli.Services) *cobra.Command {
5656
os.Exit(1)
5757
}
5858

59-
l4, err := Load(services.Scope.Plugins(), name)
59+
l4, err := services.Scope.L4(name)
6060
if err != nil {
6161
return nil
6262
}
@@ -81,7 +81,7 @@ func Backends(name string, services *cli.Services) *cobra.Command {
8181
os.Exit(1)
8282
}
8383

84-
l4, err := Load(services.Scope.Plugins(), name)
84+
l4, err := services.Scope.L4(name)
8585
if err != nil {
8686
return nil
8787
}

pkg/cli/v0/loadbalancer/cmd.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ package loadbalancer
22

33
import (
44
"github.com/docker/infrakit/pkg/cli"
5-
"github.com/docker/infrakit/pkg/discovery"
65
logutil "github.com/docker/infrakit/pkg/log"
7-
"github.com/docker/infrakit/pkg/plugin"
8-
loadbalancer_rpc "github.com/docker/infrakit/pkg/rpc/loadbalancer"
96
"github.com/docker/infrakit/pkg/spi/loadbalancer"
107
)
118

@@ -18,13 +15,3 @@ func init() {
1815
Backends,
1916
})
2017
}
21-
22-
// Load loads the typed object
23-
func Load(plugins discovery.Plugins, name string) (loadbalancer.L4, error) {
24-
pn := plugin.Name(name)
25-
endpoint, err := plugins.Find(pn)
26-
if err != nil {
27-
return nil, err
28-
}
29-
return loadbalancer_rpc.NewClient(pn, endpoint.Address)
30-
}

pkg/cli/v0/loadbalancer/routes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func Routes(name string, services *cli.Services) *cobra.Command {
5656
return err
5757
}
5858

59-
l4, err := Load(services.Scope.Plugins(), name)
59+
l4, err := services.Scope.L4(name)
6060
if err != nil {
6161
return nil
6262
}
@@ -84,7 +84,7 @@ func Routes(name string, services *cli.Services) *cobra.Command {
8484
os.Exit(1)
8585
}
8686

87-
l4, err := Load(services.Scope.Plugins(), name)
87+
l4, err := services.Scope.L4(name)
8888
if err != nil {
8989
return nil
9090
}
@@ -116,7 +116,7 @@ func Routes(name string, services *cli.Services) *cobra.Command {
116116
os.Exit(1)
117117
}
118118

119-
l4, err := Load(services.Scope.Plugins(), name)
119+
l4, err := services.Scope.L4(name)
120120
if err != nil {
121121
return nil
122122
}

0 commit comments

Comments
 (0)