From 5274bc78dac2f2368456b4ad6338523d27b625ff Mon Sep 17 00:00:00 2001 From: othman touijer Date: Mon, 15 Nov 2021 11:19:33 +0100 Subject: [READINESS] Update readiness python script Apply changes on ready.py file to replace some parts config parts with a cleaner alternative. It now uses the "config" method from python k8s package. This is supposed to fix permission errors that arise when using a service mesh. (suggested by Sylvain) Issue-ID: OOM-2878 Signed-off-by: othman touijer Change-Id: Ife2635111f3267c0920f0a2631c7102b7eedcd3a --- ready.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/ready.py b/ready.py index 85c7f8a..85d5989 100755 --- a/ready.py +++ b/ready.py @@ -30,17 +30,11 @@ import sys import time import random -from kubernetes import client +from kubernetes import client, config from kubernetes.client.rest import ApiException -# extract env variables. +# extract ns from env variable namespace = os.environ['NAMESPACE'] -cert = os.environ['CERT'] -host = os.environ['KUBERNETES_SERVICE_HOST'] -token_path = os.environ['TOKEN'] - -with open(token_path, 'r') as token_file: - token = token_file.read().replace('\n', '') # setup logging log = logging.getLogger(__name__) @@ -51,15 +45,10 @@ handler.setLevel(logging.INFO) log.addHandler(handler) log.setLevel(logging.INFO) -configuration = client.Configuration() -configuration.host = "https://" + host -configuration.ssl_ca_cert = cert -configuration.api_key['authorization'] = token -configuration.api_key_prefix['authorization'] = 'Bearer' -coreV1Api = client.CoreV1Api(client.ApiClient(configuration)) -api = client.AppsV1Api(client.ApiClient(configuration)) -batchV1Api = client.BatchV1Api(client.ApiClient(configuration)) - +config.load_incluster_config() +coreV1Api = client.CoreV1Api() +api = client.AppsV1Api() +batchV1Api = client.BatchV1Api() def is_job_complete(job_name): """ -- cgit 1.2.3-korg