-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitData.py
35 lines (32 loc) · 1.52 KB
/
InitData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from kubernetes import client
import os
import logger_settings
class InitData(object):
def __init__(self, auth_dict):
'''
set kubernetes configuration strings
:param auth_dict:
'''
try:
self.configuration = client.Configuration()
# kube cluster host
self.configuration.host = auth_dict['host']
self.configuration.verify_ssl = True
# certificate-authority-data
self.configuration.ssl_ca_cert = auth_dict['ssl_ca_cert_file']
# client-certificate-data
self.configuration.cert_file = auth_dict['ssl_cert_file']
# client-key-data
self.configuration.key_file = auth_dict['ssl_key_file']
# http proxy
self.configuration.proxy = auth_dict['proxy']
# check if debug env value is True/False to enable debugging
self.configuration.debug = os.environ.get('KUBE_DEBUG', False)
# kube cluster context
self.configuration.api_key['context'] = auth_dict['context']
self.v1 = client.CoreV1Api(client.ApiClient(self.configuration))
self.v1_extension = client.ExtensionsV1beta1Api(client.ApiClient(self.configuration))
self.storage = client.StorageV1Api(client.ApiClient(self.configuration))
self.scale = client.AutoscalingV1Api(client.ApiClient(self.configuration))
except BaseException:
logger_settings.logger.info('There is some generic problem parsing the config file')