Skip to content

Commit

Permalink
Traefik uses first available port with TCP_PORT
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed Sep 21, 2023
1 parent 3c0b8da commit 641b099
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions imageroot/actions/configure-module/30Traefik
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,13 @@ default_traefik_id = agent.resolve_agent_id('traefik@node')
if default_traefik_id is None:
sys.exit(2)

# first port is for traefik
port=os.environ["TCP_PORTS"].split(',')
agent.set_env("TRAEFIK_TCP_PORT", port[0])

# Configure Traefik to route "/mattermost" path requests to the mattermost service
response = agent.tasks.run(
agent_id=agent.resolve_agent_id('traefik@node'),
action='set-route',
data={
'instance': os.environ['MODULE_ID'],
'url': 'http://127.0.0.1:' + os.environ["TRAEFIK_TCP_PORT"],
'url': 'http://127.0.0.1:' + os.environ["TCP_PORT"],
'host': host,
'http2https': h2hs,
'lets_encrypt': le
Expand Down
2 changes: 1 addition & 1 deletion imageroot/actions/create-module/10set-ports
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import agent

# split port and set in env
port = os.environ["TCP_PORTS"].split(',')
agent.set_env("TRAEFIK_TCP_PORT", port[0])
# we use TCP_PORT for env var for traefik eg port[0]
agent.set_env("CALLS_TCP_PORT", port[1])
agent.set_env("CALLS_UDP_PORT", os.environ["UDP_PORT"])

Expand Down
2 changes: 1 addition & 1 deletion imageroot/actions/restore-module/50traefik
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ response = agent.tasks.run(
action='set-route',
data={
'instance': os.environ['MODULE_ID'],
'url': f'http://127.0.0.1:{os.environ["TRAEFIK_TCP_PORT"]}',
'url': f'http://127.0.0.1:{os.environ["TCP_PORT"]}',
'host': os.environ["TRAEFIK_HOST"],
'lets_encrypt': os.environ["TRAEFIK_LETS_ENCRYPT"] == True,
'http2https': os.environ["TRAEFIK_HTTP2HTTPS"] == True
Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/mattermost.service
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ExecStartPre=/bin/rm -f %t/mattermost.pid %t/mattermost.pod-id
ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/mattermost.pid \
--pod-id-file %t/mattermost.pod-id \
--name mattermost \
--publish 127.0.0.1:${TRAEFIK_TCP_PORT}:8065/tcp \
--publish 127.0.0.1:${TCP_PORT}:8065/tcp \
--publish 0.0.0.0:${CALLS_UDP_PORT}:${CALLS_UDP_PORT}/udp \
--publish 0.0.0.0:${CALLS_TCP_PORT}:${CALLS_TCP_PORT}/tcp \
--replace
Expand Down

0 comments on commit 641b099

Please sign in to comment.