File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ import kubernetes
3
+
4
+ def load_kubernetes_config (logger ):
5
+ try :
6
+ if os .getenv ('KUBERNETES_SERVICE_HOST' ):
7
+ logger .info ("KUBERNETES_SERVICE_HOST has a value so we must be running inside of kubernetes" )
8
+ logger .info ('Attempting to load in-cluster Kubernetes configuration' )
9
+ kubernetes .config .load_incluster_config ()
10
+ else :
11
+ logger .info ('Using local Kubeconfig because we are not running in kubernetes' )
12
+ kubernetes .config .load_kube_config ()
13
+ logger .info ('Successfully loaded Kubernetes configuration' )
14
+ except kubernetes .config .ConfigException as e :
15
+ logger .error (f'Kubernetes configuration error: { e } ' )
16
+ os .sys .exit ('Failed to load Kubernetes configuration, exiting application' )
17
+
18
+ try :
19
+ v1 = kubernetes .client .CoreV1Api ()
20
+ custom_api = kubernetes .client .CustomObjectsApi ()
21
+ return v1 , custom_api
22
+ except Exception as e :
23
+ logger .error (f'Error setting up Kubernetes API clients: { e } ' )
24
+ os .sys .exit ('Failed to setup Kubernetes API clients, exiting application' )
Original file line number Diff line number Diff line change 3
3
4
4
setup (
5
5
name = 'glueops-helpers' ,
6
- version = '0.2 .0' ,
6
+ version = '0.3 .0' ,
7
7
packages = find_packages (),
8
8
install_requires = [
9
9
'requests' ,
10
10
'boto3' ,
11
- 'slowapi ' ,
12
- 'cryptography '
11
+ 'cryptography ' ,
12
+ 'kubernetes '
13
13
],
14
14
entry_points = {
15
15
# If needed, you can add entry points for command line utilities here
You can’t perform that action at this time.
0 commit comments