outposts: default to currently running namespace if possible
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
11
authentik/outposts/controllers/k8s/utils.py
Normal file
11
authentik/outposts/controllers/k8s/utils.py
Normal file
@ -0,0 +1,11 @@
|
||||
"""k8s utils"""
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def get_namespace() -> str:
|
||||
"""Get the namespace if we're running in a pod, otherwise default to default"""
|
||||
path = Path("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
||||
if path.exists():
|
||||
with open(path, "r") as _namespace_file:
|
||||
return _namespace_file.read()
|
||||
return "default"
|
||||
Reference in New Issue
Block a user