Skip to content

Commit

Permalink
outposts: disable deployment and secret reconciler for embedded outpo…
Browse files Browse the repository at this point in the history
…st in code instead of in config

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Dec 30, 2023
1 parent 1c3cce1 commit a396089
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion authentik/outposts/api/outposts.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def validate_name(self, name: str) -> str:
"""Validate name (especially for embedded outpost)"""
if not self.instance:
return name
if self.instance.managed == MANAGED_OUTPOST:
if self.instance.managed == MANAGED_OUTPOST and name != MANAGED_OUTPOST_NAME:
raise ValidationError("Embedded outpost's name cannot be changed")
if self.instance.name == MANAGED_OUTPOST_NAME:
self.instance.managed = MANAGED_OUTPOST
Expand Down
7 changes: 0 additions & 7 deletions authentik/outposts/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def reconcile_embedded_outpost(self):
DockerServiceConnection,
KubernetesServiceConnection,
Outpost,
OutpostConfig,
OutpostType,
)

Expand All @@ -56,10 +55,4 @@ def reconcile_embedded_outpost(self):
outpost.service_connection = KubernetesServiceConnection.objects.first()
elif DockerServiceConnection.objects.exists():
outpost.service_connection = DockerServiceConnection.objects.first()
outpost.config = OutpostConfig(
kubernetes_disabled_components=[
"deployment",
"secret",
]
)
outpost.save()
4 changes: 4 additions & 0 deletions authentik/outposts/controllers/k8s/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def __init__(self, controller: "KubernetesController") -> None:
self.api = AppsV1Api(controller.client)
self.outpost = self.controller.outpost

@property
def noop(self) -> bool:
return self.is_embedded

@staticmethod
def reconciler_name() -> str:
return "deployment"
Expand Down
4 changes: 4 additions & 0 deletions authentik/outposts/controllers/k8s/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def __init__(self, controller: "KubernetesController") -> None:
super().__init__(controller)
self.api = CoreV1Api(controller.client)

@property
def noop(self) -> bool:
return self.is_embedded

@staticmethod
def reconciler_name() -> str:
return "secret"
Expand Down
5 changes: 4 additions & 1 deletion authentik/outposts/controllers/k8s/service_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def reconciler_name() -> str:

@property
def noop(self) -> bool:
return (not self._crd_exists()) or (self.is_embedded)
if not self._crd_exists():
self.logger.debug("CRD doesn't exist")
return True
return self.is_embedded

Check warning on line 83 in authentik/outposts/controllers/k8s/service_monitor.py

View check run for this annotation

Codecov / codecov/patch

authentik/outposts/controllers/k8s/service_monitor.py#L83

Added line #L83 was not covered by tests

def _crd_exists(self) -> bool:
"""Check if the Prometheus ServiceMonitor exists"""
Expand Down

0 comments on commit a396089

Please sign in to comment.