From 7a1935b4e2b7cd751923b1bf9f09439ef52ac6c0 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 8 May 2021 14:09:21 +0200 Subject: [PATCH] outposts: fix error on k8s when name has spaces closes #846 Signed-off-by: Jens Langhammer --- authentik/outposts/controllers/k8s/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/authentik/outposts/controllers/k8s/base.py b/authentik/outposts/controllers/k8s/base.py index cfc43840d..ab7caac34 100644 --- a/authentik/outposts/controllers/k8s/base.py +++ b/authentik/outposts/controllers/k8s/base.py @@ -1,6 +1,7 @@ """Base Kubernetes Reconciler""" from typing import TYPE_CHECKING, Generic, TypeVar +from django.utils.text import slugify from kubernetes.client import V1ObjectMeta from kubernetes.client.models.v1_deployment import V1Deployment from kubernetes.client.models.v1_pod import V1Pod @@ -48,7 +49,7 @@ class KubernetesObjectReconciler(Generic[T]): def name(self) -> str: """Get the name of the object this reconciler manages""" return self.controller.outpost.config.object_naming_template % { - "name": self.controller.outpost.name, + "name": slugify(self.controller.outpost.name), "uuid": self.controller.outpost.uuid.hex, } @@ -132,7 +133,7 @@ class KubernetesObjectReconciler(Generic[T]): namespace=self.namespace, labels={ "app.kubernetes.io/name": f"authentik-{self.controller.outpost.type.lower()}", - "app.kubernetes.io/instance": self.controller.outpost.name, + "app.kubernetes.io/instance": slugify(self.controller.outpost.name), "app.kubernetes.io/version": __version__, "app.kubernetes.io/managed-by": "goauthentik.io", "goauthentik.io/outpost-uuid": self.controller.outpost.uuid.hex,