From c9db1009197983dbead1bf1a19be56f4e5cc52bf Mon Sep 17 00:00:00 2001 From: Venkata Mutyala Date: Wed, 8 Nov 2023 22:01:47 -0800 Subject: [PATCH] feat: migrating kubernetes auth logic to library (#25) --- main.py | 17 +++-------------- requirements.txt | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/main.py b/main.py index a1abe3c..933289a 100644 --- a/main.py +++ b/main.py @@ -3,7 +3,7 @@ import requests from glueops.setup_logging import configure as go_configure_logging -from kubernetes import client, config +import glueops.setup_kubernetes from src.get_github_api_token import get_github_api_token @@ -14,19 +14,8 @@ ) # setting cluster config -try: - config.load_incluster_config() -except Exception as e: - logger.warning(f'Error loading in-cluster k8s config: {e}') - try: - logger.info('Using local Kubeconfig (not in-cluster)') - config.load_kube_config() - except Exception: - logger.exception('Failed to load Kubeconfig from cluster, local file') - -# configure kubernetes api clients -v1 = client.CoreV1Api() -custom_api = client.CustomObjectsApi() +v1, custom_api = glueops.setup_kubernetes.load_kubernetes_config(logger) + # set app constants NAMESPACE = os.getenv( diff --git a/requirements.txt b/requirements.txt index 7dfb05f..c180c85 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ jwt==1.3.1 kubernetes==27.2.0 requests==2.31.0 -glueops-helpers @ https://github.com/GlueOps/python-glueops-helpers-library/archive/refs/tags/v0.2.0.zip \ No newline at end of file +glueops-helpers @ https://github.com/GlueOps/python-glueops-helpers-library/archive/refs/tags/v0.3.0.zip