diff options
author | othman touijer <othman.touijer@soprasteria.com> | 2021-11-15 11:19:33 +0100 |
---|---|---|
committer | othman touijer <othman.touijer@soprasteria.com> | 2021-11-15 11:19:33 +0100 |
commit | 5274bc78dac2f2368456b4ad6338523d27b625ff (patch) | |
tree | c0ac18bf0a57f319baa927781b11e37c2a46787f | |
parent | 81e0b038e3a838a8a7378c669f2eb7ab5c7307ca (diff) |
[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 <othman.touijer@soprasteria.com>
Change-Id: Ife2635111f3267c0920f0a2631c7102b7eedcd3a
-rwxr-xr-x | ready.py | 23 |
1 files changed, 6 insertions, 17 deletions
@@ -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): """ |