コード例 #1
0
ファイル: general.py プロジェクト: achristianson/nipyapi-ds
def destroy_deployment(api: client.AppsV1Api, namespace, name):
    if len(
            api.list_namespaced_deployment(
                namespace=namespace,
                field_selector=f'metadata.name={name}').items) == 1:
        logger.info(f'destroying Deployment: {namespace}/{name}')
        api.delete_namespaced_deployment(name=name, namespace=namespace)
    else:
        logger.info(f'cannot find Deployment to destroy: {namespace}/{name}')
コード例 #2
0
def delete_deployment(apps_v1_api: AppsV1Api, name, namespace) -> None:
    """
    Delete a deployment.

    :param apps_v1_api: AppsV1Api
    :param name:
    :param namespace:
    :return:
    """
    print(f"Delete a deployment: {name}")
    delete_options = client.V1DeleteOptions()
    delete_options.grace_period_seconds = 0
    delete_options.propagation_policy = 'Foreground'
    apps_v1_api.delete_namespaced_deployment(name, namespace, delete_options)
    ensure_item_removal(apps_v1_api.read_namespaced_deployment_status, name, namespace)
    print(f"Deployment was removed with name '{name}'")
コード例 #3
0
def delete_deployment(apps_v1_api: AppsV1Api, name, namespace) -> None:
    """
    Delete a deployment.

    :param apps_v1_api: AppsV1Api
    :param name:
    :param namespace:
    :return:
    """
    delete_options = {
        "grace_period_seconds": 0,
        "propagation_policy": "Foreground",
    }
    print(f"Delete a deployment: {name}")
    apps_v1_api.delete_namespaced_deployment(name, namespace, **delete_options)
    ensure_item_removal(apps_v1_api.read_namespaced_deployment_status, name, namespace)
    print(f"Deployment was removed with name '{name}'")
コード例 #4
0
def delete_deployment(api_instance: AppsV1Api, deployment_names: List[str], namespace: str) -> None:
    """
    Delete our deployment
    :param api_instance: The api instance
    :param deployment_names: The names of the deployments.
    :param namespace: The namespace in which the pods are deployed.
    """
    for deployment_name in deployment_names:
        api_response = api_instance.delete_namespaced_deployment(
            name=deployment_name,
            namespace=namespace,
            body=client.V1DeleteOptions(
                propagation_policy='Foreground',
                grace_period_seconds=5))
        print("Deployment deleted. status='%s'" % str(api_response.status))