diff --git a/authentik/outposts/controllers/k8s/base.py b/authentik/outposts/controllers/k8s/base.py index f996e622f..73faa1862 100644 --- a/authentik/outposts/controllers/k8s/base.py +++ b/authentik/outposts/controllers/k8s/base.py @@ -42,7 +42,10 @@ class KubernetesObjectReconciler(Generic[T]): @property def name(self) -> str: """Get the name of the object this reconciler manages""" - raise NotImplementedError + return self.controller.outpost.config.object_naming_template % { + "name": self.controller.outpost.name, + "uuid": self.controller.outpost.uuid.hex, + } def up(self): """Create object if it doesn't exist, update if needed or recreate if needed.""" diff --git a/authentik/outposts/controllers/k8s/deployment.py b/authentik/outposts/controllers/k8s/deployment.py index d82d56026..1bab82ec2 100644 --- a/authentik/outposts/controllers/k8s/deployment.py +++ b/authentik/outposts/controllers/k8s/deployment.py @@ -37,10 +37,6 @@ class DeploymentReconciler(KubernetesObjectReconciler[V1Deployment]): self.api = AppsV1Api(controller.client) self.outpost = self.controller.outpost - @property - def name(self) -> str: - return f"authentik-outpost-{self.controller.outpost.uuid.hex}" - def reconcile(self, current: V1Deployment, reference: V1Deployment): super().reconcile(current, reference) if current.spec.replicas != reference.spec.replicas: diff --git a/authentik/outposts/controllers/k8s/secret.py b/authentik/outposts/controllers/k8s/secret.py index b9abd3df8..99ec34fea 100644 --- a/authentik/outposts/controllers/k8s/secret.py +++ b/authentik/outposts/controllers/k8s/secret.py @@ -26,10 +26,6 @@ class SecretReconciler(KubernetesObjectReconciler[V1Secret]): super().__init__(controller) self.api = CoreV1Api(controller.client) - @property - def name(self) -> str: - return f"authentik-outpost-{self.controller.outpost.uuid.hex}-api" - def reconcile(self, current: V1Secret, reference: V1Secret): super().reconcile(current, reference) for key in reference.data.keys(): diff --git a/authentik/outposts/controllers/k8s/service.py b/authentik/outposts/controllers/k8s/service.py index 2d6de3fcb..93fcd4bdd 100644 --- a/authentik/outposts/controllers/k8s/service.py +++ b/authentik/outposts/controllers/k8s/service.py @@ -21,10 +21,6 @@ class ServiceReconciler(KubernetesObjectReconciler[V1Service]): super().__init__(controller) self.api = CoreV1Api(controller.client) - @property - def name(self) -> str: - return f"authentik-outpost-{self.controller.outpost.uuid.hex}" - def reconcile(self, current: V1Service, reference: V1Service): super().reconcile(current, reference) if len(current.spec.ports) != len(reference.spec.ports): diff --git a/authentik/outposts/models.py b/authentik/outposts/models.py index 2cf24c6a1..d8f0fbd95 100644 --- a/authentik/outposts/models.py +++ b/authentik/outposts/models.py @@ -56,6 +56,7 @@ class OutpostConfig: "error_reporting.environment", "customer" ) + object_naming_template: str = field(default="ak-outpost-%(name)s") kubernetes_replicas: int = field(default=1) kubernetes_namespace: str = field(default="default") kubernetes_ingress_annotations: dict[str, str] = field(default_factory=dict) diff --git a/authentik/providers/proxy/controllers/k8s/ingress.py b/authentik/providers/proxy/controllers/k8s/ingress.py index d7c69268a..92d2d9fd6 100644 --- a/authentik/providers/proxy/controllers/k8s/ingress.py +++ b/authentik/providers/proxy/controllers/k8s/ingress.py @@ -33,10 +33,6 @@ class IngressReconciler(KubernetesObjectReconciler[NetworkingV1beta1Ingress]): super().__init__(controller) self.api = NetworkingV1beta1Api(controller.client) - @property - def name(self) -> str: - return f"authentik-outpost-{self.controller.outpost.uuid.hex}" - def _check_annotations(self, reference: NetworkingV1beta1Ingress): """Check that all annotations *we* set are correct""" for key, value in self.get_ingress_annotations().items():