From dc41d0af27fa4a680133838e43f863fa1f6e617d Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 27 Aug 2021 19:10:30 +0200 Subject: [PATCH] outposts: add configurable docker_network for outpost Signed-off-by: Jens Langhammer --- authentik/outposts/controllers/docker.py | 2 ++ authentik/outposts/models.py | 5 ++++- website/docs/outposts/outposts.md | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/authentik/outposts/controllers/docker.py b/authentik/outposts/controllers/docker.py index 5b7a9c94e..51c579b28 100644 --- a/authentik/outposts/controllers/docker.py +++ b/authentik/outposts/controllers/docker.py @@ -92,9 +92,11 @@ class DockerController(BaseController): "environment": self._get_env(), "labels": self._get_labels(), "restart_policy": {"Name": "unless-stopped"}, + "network": self.outpost.config.docker_network, } if settings.TEST: del container_args["ports"] + del container_args["network"] container_args["network_mode"] = "host" return ( self.client.containers.create(**container_args), diff --git a/authentik/outposts/models.py b/authentik/outposts/models.py index cb186cd6a..3e294ecdd 100644 --- a/authentik/outposts/models.py +++ b/authentik/outposts/models.py @@ -56,6 +56,7 @@ class ServiceConnectionInvalid(SentryIgnoredException): @dataclass +# pylint: disable=too-many-instance-attributes class OutpostConfig: """Configuration an outpost uses to configure it self""" @@ -67,8 +68,10 @@ class OutpostConfig: log_level: str = CONFIG.y("log_level") error_reporting_enabled: bool = CONFIG.y_bool("error_reporting.enabled") error_reporting_environment: str = CONFIG.y("error_reporting.environment", "customer") - object_naming_template: str = field(default="ak-outpost-%(name)s") + + docker_network: Optional[str] = field(default=None) + kubernetes_replicas: int = field(default=1) kubernetes_namespace: str = field(default_factory=get_namespace) kubernetes_ingress_annotations: dict[str, str] = field(default_factory=dict) diff --git a/website/docs/outposts/outposts.md b/website/docs/outposts/outposts.md index ebdbbb19c..f05dabff7 100644 --- a/website/docs/outposts/outposts.md +++ b/website/docs/outposts/outposts.md @@ -42,6 +42,11 @@ object_naming_template: ak-outpost-%(name)s ######################################## # Kubernetes outpost specific settings ######################################## +# Network the outpost container should be connected to +docker_network: null +######################################## +# Kubernetes outpost specific settings +######################################## # Replica count for the deployment of the outpost kubernetes_replicas: 1 # Namespace to deploy in, defaults to the same namespace authentik is deployed in (if available)