Use MacVLAN and obtain domain automatically
This commit is contained in:
@@ -22,6 +22,9 @@ services:
|
||||
networks:
|
||||
- traefik
|
||||
- docker
|
||||
- macvlan
|
||||
environment:
|
||||
- NAS_COMPOSE_DOMAIN=${NAS_COMPOSE_DOMAIN?}
|
||||
# TODO: Move to configs?
|
||||
volumes:
|
||||
- traefik_dynamic_config:/etc/traefik/dynamic/:ro
|
||||
@@ -69,6 +72,8 @@ networks:
|
||||
name: traefik
|
||||
labels:
|
||||
nas-compose.boostrap: true
|
||||
macvlan:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
portainer_data:
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
# Bootstrap
|
||||
|
||||
Set up a MacVLAN network
|
||||
|
||||
As an example, with the following network setup:
|
||||
- interface to LAN: `bond0`
|
||||
- Complete LAN subnet: `192.168.0.0/23`
|
||||
- LAN gateway: `192.168.0.1`
|
||||
- DHCP range: `192.168.0.0/24` (excluding gateway)
|
||||
- MacVLAN interface name: `macvlan0` (user defined)
|
||||
- MacVLAN range: `192.168.1.0/24` (should be outside of DHCP range)
|
||||
- MacVLAN host IP: `192.168.1.1` (should be in the MacVLAN range)
|
||||
|
||||
```
|
||||
docker network create -d macvlan -o parent=bond0 --subnet=192.168.0.0/23 --gateway=192.168.0.1 --ip-range=192.168.1.0/24 --aux-address "nas=192.168.1.1" macvlan
|
||||
ip link add macvlan0 link bond0 type macvlan mode bridge
|
||||
ip addr add 192.168.1.1/32 dev macvlan0
|
||||
ip link set macvlan0 up
|
||||
```
|
||||
|
||||
Run portainer once
|
||||
```
|
||||
docker run --rm -p 9443:9443 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce:latest
|
||||
```
|
||||
|
||||
### Environment variables
|
||||
- `SERVICES_DIR`: Absolute path to the `services` folder
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ providers:
|
||||
endpoint: tcp://docker:2375
|
||||
exposedByDefault: false
|
||||
network: traefik
|
||||
defaultRule: Host(`{{ index .Labels "com.docker.compose.service" }}.dev.dedicated.contact`)
|
||||
defaultRule: Host(`{{ index .Labels "com.docker.compose.service" }}.{{ env `NAS_COMPOSE_DOMAIN` }}`)
|
||||
file:
|
||||
directory: /etc/traefik/dynamic/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
http:
|
||||
routers:
|
||||
traefik:
|
||||
rule: Host(`traefik.dev.dedicated.contact`)
|
||||
rule: Host(`traefik.{{ env `NAS_COMPOSE_DOMAIN` }}`)
|
||||
service: api@internal
|
||||
middlewares:
|
||||
- traefik-auth
|
||||
|
||||
Reference in New Issue
Block a user