-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathclient.py
More file actions
41 lines (33 loc) · 1.45 KB
/
client.py
File metadata and controls
41 lines (33 loc) · 1.45 KB
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
36
37
38
39
40
41
import os, boto3
from kubernetes import client, config, dynamic
from kubernetes.client import api_client
import pkg.aws_az.types.types as experimentDetails
from botocore.config import Config
import pkg.aws_az.environment.environment as experimentEnv
# Client Class is maintaining clients for k8s
class K8sClient(object):
def __init__(self, conf=None):
self.clientCoreV1 = client.CoreV1Api(conf)
self.clientDyn = dynamic.DynamicClient(api_client.ApiClient(configuration=conf))
self.clientApps = client.AppsV1Api(conf)
# AWSClient is maintaining clients for aws
class AWSClient(object):
def __init__(self, experimentsDetails):
self.clientElb = boto3.client('elb', region_name=experimentsDetails.AWSRegion)
self.clientElbv2 = boto3.client('elbv2', region_name=experimentsDetails.AWSRegion)
# Config maintain configuration for in and out cluster
class Configuration(object):
def __init__(self, kubeconfig=None, configurations=None):
self.kubeconfig = kubeconfig
self.configurations = configurations
# get_config return the configuration
def get_config(self):
global configs
if self.kubeconfig != "":
configs = self.kubeconfig
elif os.getenv('KUBERNETES_SERVICE_HOST'):
configs = config.load_incluster_config()
else:
configs = config.load_kube_config()
self.configurations = configs
return configs