From 55ab5c00b1937645c69726aea4c3fbc2084f8f7a Mon Sep 17 00:00:00 2001 From: JeremiahUy Date: Wed, 7 Oct 2020 12:39:02 +0200 Subject: [PATCH 1/2] TEST: kubernetes code --- collector/kube_api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/collector/kube_api.py b/collector/kube_api.py index cea905c..5da4356 100644 --- a/collector/kube_api.py +++ b/collector/kube_api.py @@ -8,8 +8,7 @@ def watch_nais_apps(callback_function): v1 = CustomObjectsApi() - #data = v1.list_cluster_custom_object(group="nais.io", version="v1alpha1", plural="applications") - #print(data) + v1.list_cluster_custom_object(group="nais.io", version="v1alpha1", plural="applications") w = Watch() From bf51e86a0e2706a97ce8d9088ead8adf30e17d2c Mon Sep 17 00:00:00 2001 From: JeremiahUy Date: Wed, 7 Oct 2020 12:47:17 +0200 Subject: [PATCH 2/2] TEST: code placement --- main.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index f9fd076..3a987b6 100644 --- a/main.py +++ b/main.py @@ -40,19 +40,6 @@ def watch_nais_task() -> None: watch_nais_apps(watch_nais_callback) -@app.on_event('startup') -def application_startup(): - logger.info('application_startup') - if os.getenv('KUBERNETES_SERVICE_HOST'): - logger.info("KUBERNETES_SERVICE_HOST: " + os.getenv('KUBERNETES_SERVICE_HOST')) - else: - logger.warning("No KUBERNETES_SERVICE_HOST set in env.") - - # Loading kubernetes config - init_kube_client() - threading.Thread(target=watch_nais_task, daemon=True).start() - - @app.get("/") def root(): return {"message": "Hello World"} @@ -66,3 +53,16 @@ def is_healthy(): @app.get('/is-ready') def is_ready(): return 'OK' + + +@app.on_event('startup') +def application_startup(): + logger.info('application_startup') + if os.getenv('KUBERNETES_SERVICE_HOST'): + logger.info("KUBERNETES_SERVICE_HOST: " + os.getenv('KUBERNETES_SERVICE_HOST')) + else: + logger.warning("No KUBERNETES_SERVICE_HOST set in env.") + + # Loading kubernetes config + init_kube_client() + threading.Thread(target=watch_nais_task, daemon=True).start()