本文整理汇总了Python中kubernetes.client.api_client.ApiClient方法的典型用法代码示例。如果您正苦于以下问题:Python api_client.ApiClient方法的具体用法?Python api_client.ApiClient怎么用?Python api_client.ApiClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kubernetes.client.api_client
的用法示例。
在下文中一共展示了api_client.ApiClient方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from kubernetes.client import api_client [as 别名]
# 或者: from kubernetes.client.api_client import ApiClient [as 别名]
def setUp(self):
if AirflowKubernetesScheduler is None:
self.skipTest("kubernetes python package is not installed")
self.kube_config = mock.MagicMock()
self.kube_config.airflow_home = '/'
self.kube_config.airflow_dags = 'dags'
self.kube_config.airflow_logs = 'logs'
self.kube_config.dags_volume_subpath = None
self.kube_config.dags_volume_mount_point = None
self.kube_config.logs_volume_subpath = None
self.kube_config.dags_in_image = False
self.kube_config.dags_folder = None
self.kube_config.git_dags_folder_mount_point = None
self.kube_config.kube_labels = {'dag_id': 'original_dag_id', 'my_label': 'label_id'}
self.kube_config.pod_template_file = ''
self.kube_config.restart_policy = ''
self.kube_config.image_pull_policy = ''
self.api_client = ApiClient()
示例2: deserialize_model_file
# 需要导入模块: from kubernetes.client import api_client [as 别名]
# 或者: from kubernetes.client.api_client import ApiClient [as 别名]
def deserialize_model_file(path: str) -> k8s.V1Pod:
"""
:param path: Path to the file
:return: a kubernetes.client.models.V1Pod
Unfortunately we need access to the private method
``_ApiClient__deserialize_model`` from the kubernetes client.
This issue is tracked here; https://github.com/kubernetes-client/python/issues/977.
"""
api_client = ApiClient()
if os.path.exists(path):
with open(path) as stream:
pod = yaml.safe_load(stream)
else:
pod = yaml.safe_load(path)
# pylint: disable=protected-access
return api_client._ApiClient__deserialize_model(pod, k8s.V1Pod)
示例3: __init__
# 需要导入模块: from kubernetes.client import api_client [as 别名]
# 或者: from kubernetes.client.api_client import ApiClient [as 别名]
def __init__(self, context, cluster):
self.ca_file = None
self.cert_file = None
self.key_file = None
if cluster.magnum_cert_ref:
(self.ca_file, self.key_file,
self.cert_file) = create_client_files(cluster, context)
config = k8s_config.Configuration()
config.host = cluster.api_address
config.ssl_ca_cert = self.ca_file.name
config.cert_file = self.cert_file.name
config.key_file = self.key_file.name
# build a connection with Kubernetes master
client = ApiClient(configuration=config)
super(K8sAPI, self).__init__(client)
示例4: get_k8s_client
# 需要导入模块: from kubernetes.client import api_client [as 别名]
# 或者: from kubernetes.client.api_client import ApiClient [as 别名]
def get_k8s_client(self, auth_plugin):
config = client.Configuration()
config.host = auth_plugin['auth_url']
if ('username' in auth_plugin) and ('password' in auth_plugin)\
and (auth_plugin['password'] is not None):
config.username = auth_plugin['username']
config.password = auth_plugin['password']
basic_token = config.get_basic_auth_token()
config.api_key['authorization'] = basic_token
if 'bearer_token' in auth_plugin:
config.api_key_prefix['authorization'] = 'Bearer'
config.api_key['authorization'] = auth_plugin['bearer_token']
ca_cert_file = auth_plugin.get('ca_cert_file')
if ca_cert_file is not None:
config.ssl_ca_cert = ca_cert_file
config.verify_ssl = True
else:
config.verify_ssl = False
k8s_client = api_client.ApiClient(configuration=config)
return k8s_client
示例5: get_k8s_clients
# 需要导入模块: from kubernetes.client import api_client [as 别名]
# 或者: from kubernetes.client.api_client import ApiClient [as 别名]
def get_k8s_clients(conf):
config = k8s_config.Configuration()
config.host = conf.kubernetes.kube_host
if conf.kubernetes.use_api_certificate:
config.ssl_ca_cert = conf.kubernetes.ssl_ca_cert
config.cert_file = conf.kubernetes.cert_file
config.key_file = conf.kubernetes.key_file
else:
config.verify_ssl = False
client = api_client.ApiClient(configuration=config)
v1 = core_v1_api.CoreV1Api(client)
v1extension = extensions_v1beta1_api.ExtensionsV1beta1Api(client)
# apps_v1 = apps_v1_api.AppsV1Api(client)
clients = {
'v1': v1,
# 'apps_v1': apps_v1
'v1extension': v1extension
}
return clients
示例6: _get_client_with_patched_configuration
# 需要导入模块: from kubernetes.client import api_client [as 别名]
# 或者: from kubernetes.client.api_client import ApiClient [as 别名]
def _get_client_with_patched_configuration(cfg: Optional[Configuration]) -> client.CoreV1Api:
"""
This is a workaround for supporting api token refresh in k8s client.
The function can be replace with `return client.CoreV1Api()` once the
upstream client supports token refresh.
"""
if cfg:
return client.CoreV1Api(api_client=ApiClient(configuration=cfg))
else:
return client.CoreV1Api()
示例7: __init__
# 需要导入模块: from kubernetes.client import api_client [as 别名]
# 或者: from kubernetes.client.api_client import ApiClient [as 别名]
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client