Swarm network segregation

Hi everyone!

I’m experimenting swarm, in order to port Tomcat services in production.

I’d like to have three environments (production, quality, development), segregated between each other.

For now, I’ve set up a virtual swarm server with 3 NIC and 3 routing tables, one for each network environment.

  • production: 172.16.0.0/16, gw 172.16.1.1

Quality and development are on the same nework:

  • 172.21.0.0/16, gw 172.21.1.1

We only change the 3rd byte:

  • quality: 172.21.2.x
  • development: 172.21.1.x

I tried to fire up a sample NGINX service but Is not reachable from outside, that’s what I did:

docker service create --publish published=80,target=80,protocol=tcp --name hostname --hostname hostname --detach nginxdemos/nginx-hello

In any case, for the moment I’ve not configured any docker network, because I don’t know exactly what kind is needed for my needs.

Here’s my netplan config:

 network:
  version: 2
  ethernets:
    ens160:
      dhcp4: no
      addresses:
      - 172.16.1.114/16
      match:
          macaddress: 00:50:56:aa:00:1d
      nameservers:
        addresses:
        - 172.16.1.11
        - 172.16.1.20
        search:
        - domain.com
      set-name: production
      routes:
          - to: 0.0.0.0/0
            via: 172.16.1.1
            table: 60
      routing-policy:
          - from: 172.16.1.114
            table: 60
          - to: 0.0.0.0/0
            table: 60
    ens192:
      dhcp4: no
      addresses:
      - 172.21.2.114/16
      match:
          macaddress: 00:50:56:aa:6f:ed
      nameservers:
        addresses:
        - 172.16.1.11
        - 172.16.1.20
        search:
        - domain.com
      set-name: quality
      routes:
          - to: 0.0.0.0/0
            via: 172.21.1.1
            table: 61
      routing-policy:
          - from: 172.21.2.114
            table: 61
          - to: 0.0.0.0/0
            table: 61
    ens224:
      dhcp4: no
      addresses:
      - 172.21.1.114/16
      match:
          macaddress: 00:50:56:aa:16:92
      nameservers:
        addresses:
        - 172.16.1.11
        - 172.16.1.20
        search:
        - domain.com
      set-name: development
      routes:
          - to: 0.0.0.0/0
            via: 172.21.1.1
            table: 62
      routing-policy:
          - from: 172.21.1.114
            table: 62
          - to: 0.0.0.0/0
            table: 62

Thank you, any help is much appreciated.