本文整理汇总了Python中kubernetes.client.ExtensionsV1beta1Api方法的典型用法代码示例。如果您正苦于以下问题:Python client.ExtensionsV1beta1Api方法的具体用法?Python client.ExtensionsV1beta1Api怎么用?Python client.ExtensionsV1beta1Api使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kubernetes.client
的用法示例。
在下文中一共展示了client.ExtensionsV1beta1Api方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_replica_set
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def delete_replica_set(name: str, ns: str = "default",
label_selector: str = "name in ({name})",
secrets: Secrets = None):
"""
Delete a replica set by `name` in the namespace `ns`.
The replica set is deleted without a graceful period to trigger an abrupt
termination.
The selected resources are matched by the given `label_selector`.
"""
label_selector = label_selector.format(name=name)
api = create_k8s_api_client(secrets)
v1 = client.ExtensionsV1beta1Api(api)
if label_selector:
ret = v1.list_namespaced_replica_set(ns, label_selector=label_selector)
else:
ret = v1.list_namespaced_replica_set(ns)
logger.debug("Found {d} replica sets named '{n}'".format(
d=len(ret.items), n=name))
body = client.V1DeleteOptions()
for r in ret.items:
v1.delete_namespaced_replica_set(r.metadata.name, ns, body=body)
示例2: ingress
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def ingress():
try:
valus = []
v1 = client.ExtensionsV1beta1Api()
keys = tables = ('name','request','domain', 'service_name', 'service_port')
ret = v1.list_ingress_for_all_namespaces()
for i in ret.items:
try:
for rule in i.spec.rules:
valus.append([i.metadata.name,
'http',
rule.host,
rule.http.paths[0].backend.service_name,
rule.http.paths[0].backend.service_port
])
except Exception as e:
logging.error(e)
return render_template('k8s-resource.html', valus=valus, tables=tables, keys=keys, resource='Ingress')
except Exception as e:
logging.error(e)
示例3: install_gpu_drivers
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def install_gpu_drivers(api_client):
"""Install GPU drivers on the cluster."""
logging.info("Install GPU Drivers.")
# Fetch the daemonset to install the drivers.
# TODO: Get cluster version and then install compatible driver version
link = "https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1.11/nvidia-device-plugin.yml" # pylint: disable=line-too-long
logging.info("Using daemonset file: %s", link)
f = urllib.urlopen(link)
daemonset_spec = yaml.load(f)
ext_client = k8s_client.ExtensionsV1beta1Api(api_client)
try:
namespace = daemonset_spec["metadata"]["namespace"]
ext_client.create_namespaced_daemon_set(namespace, daemonset_spec)
except rest.ApiException as e:
# Status appears to be a string.
if e.status == 409:
logging.info("GPU driver daemon set has already been installed")
else:
raise
示例4: check_ingresses
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def check_ingresses():
status = False
k8s_v1b1 = client.ExtensionsV1beta1Api(client.ApiClient(client.Configuration()))
if k8s_v1b1:
try:
if ambassador_single_namespace:
k8s_v1b1.list_namespaced_ingress(ambassador_namespace)
else:
k8s_v1b1.list_ingress_for_all_namespaces()
status = True
except ApiException as e:
logger.debug(f'Ingress check got {e.status}')
return status
示例5: __init__
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def __init__(self, **kwargs):
"""
Set cluster and prepare clients for all used resource types.
Args:
**kwargs: Keyword arguments (cluster is required)
"""
# load configuration
try:
self.cluster = kwargs['cluster']
except KeyError:
raise ValueError('Missing parameter cluster')
logger.debug('Initialized KubernetesAPI for {}'.format(self.cluster))
# set apis
api_client = self.get_api_client()
self.api_corev1 = client.CoreV1Api(api_client=api_client)
self.api_storagev1 = client.StorageV1Api(api_client=api_client)
self.api_extensionsv1beta1 = client.ExtensionsV1beta1Api(api_client=api_client)
self.api_version = client.VersionApi(api_client=api_client)
示例6: scale_deployment
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def scale_deployment(name: str, replicas: int, ns: str = "default",
secrets: Secrets = None):
"""
Scale a deployment up or down. The `name` is the name of the deployment.
"""
api = create_k8s_api_client(secrets)
v1 = client.ExtensionsV1beta1Api(api)
body = {"spec": {"replicas": replicas}}
try:
v1.patch_namespaced_deployment_scale(name, namespace=ns, body=body)
except ApiException as e:
raise ActivityFailed(
"failed to scale '{s}' to {r} replicas: {e}".format(
s=name, r=replicas, e=str(e)))
示例7: __init__
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def __init__(self, bearer_token=None):
'''
Initialize connection to Kubernetes
'''
self.bearer_token = bearer_token
api_client = None
try:
config.load_incluster_config()
except config.config_exception.ConfigException:
config.load_kube_config()
if self.bearer_token:
# Configure API key authorization: Bearer Token
configuration = client.Configuration()
configuration.api_key_prefix['authorization'] = 'Bearer'
configuration.api_key['authorization'] = self.bearer_token
api_client = client.ApiClient(configuration)
self.client = client.CoreV1Api(api_client)
self.batch_api = client.BatchV1Api(api_client)
self.batch_v1beta1_api = client.BatchV1beta1Api(api_client)
self.custom_objects = client.CustomObjectsApi(api_client)
self.api_extensions = client.ApiextensionsV1beta1Api(api_client)
self.extension_api = client.ExtensionsV1beta1Api(api_client)
self.apps_v1_api = client.AppsV1Api(api_client)
示例8: __init__
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def __init__(self):
'''
Initialize connection to Kubernetes
'''
try:
config.load_incluster_config()
except config.config_exception.ConfigException:
config.load_kube_config()
self.client = client.CoreV1Api()
self.batch_api = client.BatchV1Api()
self.batch_v1beta1_api = client.BatchV1beta1Api()
self.extension_api = client.ExtensionsV1beta1Api()
示例9: get_k8s_extensions_api_client
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def get_k8s_extensions_api_client():
apps_api_client = client.ExtensionsV1beta1Api(client.ApiClient(get_k8s_configuration()))
return apps_api_client
示例10: get_endpoint_ingress
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def get_endpoint_ingress(name, namespace):
extensions_api_instance = client.ExtensionsV1beta1Api(config.load_kube_config())
api_response = extensions_api_instance.read_namespaced_ingress(name, namespace)
return api_response
示例11: delete_deployment
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def delete_deployment(self):
try:
api_instance = client.ExtensionsV1beta1Api()
body = client.V1DeleteOptions(propagation_policy='Foreground', grace_period_seconds=5)
api_instance.delete_namespaced_deployment(name=self.dm_name, namespace=self.namespace, body=body)
return True
except Exception as e:
logging.error(e)
return False
示例12: extensions_client_from_config
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def extensions_client_from_config(config):
if config is None:
k8sconfig.load_incluster_config()
return k8sclient.ExtensionsV1beta1Api()
else:
client = k8sclient.ApiClient(configuration=config)
return k8sclient.ExtensionsV1beta1Api(api_client=client)
示例13: __init__
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def __init__(self):
self.logger = logging.getLogger(__name__)
try:
config_file = os.path.expanduser(kubeconfig_filepath)
config.load_kube_config(config_file=config_file)
except:
self.logger.warning("unable to load kube-config")
self.v1 = client.CoreV1Api()
self.v1Beta1 = client.AppsV1beta1Api()
self.extensionsV1Beta1 = client.ExtensionsV1beta1Api()
self.autoscalingV1Api = client.AutoscalingV1Api()
self.rbacApi = client.RbacAuthorizationV1beta1Api()
self.batchV1Api = client.BatchV1Api()
self.batchV2Api = client.BatchV2alpha1Api()
示例14: get_extension_api_client
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def get_extension_api_client(self, auth):
k8s_client = self.get_k8s_client(auth_plugin=auth)
return client.ExtensionsV1beta1Api(api_client=k8s_client)
示例15: k8s_beta_api
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import ExtensionsV1beta1Api [as 别名]
def k8s_beta_api(self):
if not self._k8s_beta_api:
self._k8s_beta_api = client.ExtensionsV1beta1Api(self.api_client)
return self._k8s_beta_api