Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Deltachaos authored Aug 31, 2024
1 parent a27e6b5 commit 55448fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import logging
from kubernetes import client, config

def get_current_namespace():
with open("/var/run/secrets/kubernetes.io/serviceaccount/namespace", "r") as file:
namespace = file.read().strip()
return namespace

def generate_random_suffix(length=6):
return ''.join(random.choices(string.ascii_lowercase + string.digits, k=length))

Expand Down Expand Up @@ -71,7 +76,7 @@ def main():
logging.info("Starting the job sequence script.")

config.load_incluster_config()
namespace = os.getenv('NAMESPACE', 'default')
namespace = get_current_namespace()
configmap_name = os.getenv('JOB_CONFIGMAP')
job_name_env = os.getenv('JOB_NAME')

Expand Down

0 comments on commit 55448fd

Please sign in to comment.