From 4cb8ae760a61069ece8390e4cd33606935de3dca Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 29 Sep 2021 23:55:22 +0200 Subject: [PATCH] outposts: allow disabling of docker controller port mapping closes #1474 Signed-off-by: Jens Langhammer --- authentik/outposts/controllers/docker.py | 9 +++++---- authentik/outposts/models.py | 1 + website/docs/outposts/outposts.md | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/authentik/outposts/controllers/docker.py b/authentik/outposts/controllers/docker.py index 03eca20f4..4714750c3 100644 --- a/authentik/outposts/controllers/docker.py +++ b/authentik/outposts/controllers/docker.py @@ -99,15 +99,16 @@ class DockerController(BaseController): "image": image_name, "name": container_name, "detach": True, - "ports": { - f"{port.inner_port or port.port}/{port.protocol.lower()}": port.port - for port in self.deployment_ports - }, "environment": self._get_env(), "labels": self._get_labels(), "restart_policy": {"Name": "unless-stopped"}, "network": self.outpost.config.docker_network, } + if self.outpost.config.docker_map_ports: + container_args["ports"] = { + f"{port.inner_port or port.port}/{port.protocol.lower()}": str(port.port) + for port in self.deployment_ports + } if settings.TEST: del container_args["ports"] del container_args["network"] diff --git a/authentik/outposts/models.py b/authentik/outposts/models.py index ff8116a71..a4a822964 100644 --- a/authentik/outposts/models.py +++ b/authentik/outposts/models.py @@ -72,6 +72,7 @@ class OutpostConfig: object_naming_template: str = field(default="ak-outpost-%(name)s") docker_network: Optional[str] = field(default=None) + docker_map_ports: bool = field(default=True) kubernetes_replicas: int = field(default=1) kubernetes_namespace: str = field(default_factory=get_namespace) diff --git a/website/docs/outposts/outposts.md b/website/docs/outposts/outposts.md index dda6f76a6..4da49af88 100644 --- a/website/docs/outposts/outposts.md +++ b/website/docs/outposts/outposts.md @@ -46,6 +46,9 @@ object_naming_template: ak-outpost-%(name)s ######################################## # Network the outpost container should be connected to docker_network: null +# Optionally disable mapping of ports to outpost container, may be useful when using docker networks +# (Available with 2021.9.4+) +docker_map_ports: true ######################################## # Kubernetes outpost specific settings ########################################