File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ def get_client(
195
195
password : str | None = None ,
196
196
host : str | None = None ,
197
197
verify_ssl : bool | None = None ,
198
+ token : str | None = None ,
198
199
) -> DynamicClient :
199
200
"""
200
201
Get a kubernetes client.
@@ -218,6 +219,7 @@ def get_client(
218
219
password (str): password for basic auth
219
220
host (str): host for the cluster
220
221
verify_ssl (bool): whether to verify ssl
222
+ token (str): Use token to login
221
223
222
224
Returns:
223
225
DynamicClient: a kubernetes client.
@@ -238,6 +240,11 @@ def get_client(
238
240
username = username , password = password , host = host , configuration = client_configuration
239
241
)
240
242
243
+ elif host and token :
244
+ client_configuration .host = host
245
+ client_configuration .api_key = {"authorization" : f"Bearer { token } " }
246
+ _client = kubernetes .client .ApiClient (client_configuration )
247
+
241
248
# Ref: https://github.com/kubernetes-client/python/blob/v26.1.0/kubernetes/base/config/kube_config.py
242
249
elif config_dict :
243
250
_client = kubernetes .config .new_client_from_config_dict (
You can’t perform that action at this time.
0 commit comments