-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker Flow proxy for hosting multiple micro services under one http …
…endpoint (#32) * Base for gateway or docker flow proxy. * Change default overlay subnet to not conflict with default aws subnet
- Loading branch information
1 parent
44b606d
commit f5f4e77
Showing
4 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
|
||
- hosts: initial-swarm-leader-manager | ||
become: yes | ||
roles: | ||
- { role: flow_proxy, | ||
docker_endpoint: "127.0.0.1:2376", | ||
docker_client_cert: "/opt/ssl/client.crt", | ||
docker_client_cacert: "/opt/ssl/ca.crt", | ||
docker_client_key: "/opt/ssl/client.pem" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
--- | ||
cassandra_node_constraint: "node.labels.cassandra==true" | ||
cassandra_version: 3.9 | ||
cassandra_overlay_subnet: 10.0.1.0/24 | ||
cassandra_overlay_subnet: 10.0.2.0/24 |
2 changes: 2 additions & 0 deletions
2
embedded-execution-layer/platform/flow_proxy/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
flow_proxy_overlay_subnet: 10.0.2.0/24 |
86 changes: 86 additions & 0 deletions
86
embedded-execution-layer/platform/flow_proxy/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
|
||
# We use the external docker API made available to us to provision this | ||
- name: Check parameters | ||
assert: | ||
that: | ||
- docker_client_cert is defined | ||
- docker_client_key is defined | ||
- docker_client_cacert is defined | ||
- docker_endpoint is defined | ||
|
||
- set_fact: | ||
docker_cmd: docker --tlsverify --tlscacert={{ docker_client_cacert }} --tlscert={{ docker_client_cert }} --tlskey={{ docker_client_key }} -H {{ docker_endpoint }} | ||
|
||
- name: Check for Proxy Network | ||
command: | | ||
{{ docker_cmd }} | ||
network inspect proxy | ||
register: tmp_command_result | ||
failed_when: "'Usage' in tmp_command_result.stderr" | ||
|
||
- set_fact: | ||
tmp_network_exists: "{{ tmp_command_result.stderr == ''}}" | ||
|
||
|
||
- name: Deploy Proxy Network | ||
command: | | ||
{{ docker_cmd }} | ||
network create --driver overlay --opt encrypted --subnet {{ flow_proxy_overlay_subnet }} proxy | ||
when: not tmp_network_exists | ||
|
||
|
||
- name: Check for Swarm Listener Service | ||
command: | | ||
{{ docker_cmd }} | ||
service inspect swarm-listener | ||
register: tmp_command_result | ||
failed_when: "'Usage' in tmp_command_result.stderr" | ||
|
||
- set_fact: | ||
tmp_service_exists: "{{ tmp_command_result.stderr == ''}}" | ||
|
||
- name: Deploy Swarm Listener Service | ||
command: | | ||
{{ docker_cmd }} | ||
service create --name swarm-listener | ||
--network proxy | ||
--mount "type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock" | ||
-e DF_NOTIFY_CREATE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/reconfigure | ||
-e DF_NOTIFY_REMOVE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/remove | ||
--constraint 'node.role==manager' | ||
vfarcic/docker-flow-swarm-listener | ||
when: not tmp_service_exists | ||
|
||
- name: Check for Flow Proxy Service | ||
command: | | ||
{{ docker_cmd }} | ||
service inspect proxy | ||
register: tmp_command_result | ||
failed_when: "'Usage' in tmp_command_result.stderr" | ||
|
||
- set_fact: | ||
tmp_service_exists: "{{ tmp_command_result.stderr == ''}}" | ||
|
||
- name: Deploy Flow Proxy Service | ||
command: | | ||
{{ docker_cmd }} | ||
service create --name proxy | ||
--mode global | ||
-p 80:80 | ||
-p 443:443 | ||
--network proxy | ||
-e MODE=swarm | ||
-e LISTENER_ADDRESS=swarm-listener | ||
vfarcic/docker-flow-proxy | ||
when: not tmp_service_exists | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|