|
| 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 |
0 commit comments