File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ import kubernetes
2
+
1
3
from ocp_utilities .exceptions import NodeNotReadyError , NodeUnschedulableError
2
4
from ocp_utilities .logger import get_logger
3
5
4
6
5
7
LOGGER = get_logger (name = __name__ )
6
8
7
9
10
+ def get_client (config_file = None , config_dict = None , context = None ):
11
+ """
12
+ Get a kubernetes client.
13
+
14
+ Pass either config_file or config_dict.
15
+ If none of them are passed, client will be created from default OS kubeconfig
16
+ (environment variable or .kube folder).
17
+
18
+ Args:
19
+ config_file (str): path to a kubeconfig file.
20
+ config_dict (dict): dict with kubeconfig configuration.
21
+ context (str): name of the context to use.
22
+
23
+ Returns:
24
+ DynamicClient: a kubernetes client.
25
+ """
26
+ if config_dict :
27
+ return kubernetes .dynamic .DynamicClient (
28
+ client = kubernetes .config .new_client_from_config_dict (
29
+ config_dict = config_dict ,
30
+ context = context ,
31
+ )
32
+ )
33
+ return kubernetes .dynamic .DynamicClient (
34
+ client = kubernetes .config .new_client_from_config (
35
+ config_file = config_file ,
36
+ context = context ,
37
+ )
38
+ )
39
+
40
+
8
41
def assert_nodes_ready (nodes ):
9
42
"""
10
43
Validates all nodes are in ready
You can’t perform that action at this time.
0 commit comments