def run(self, args):
        
        context, namespace = choose_context_and_namespace(args.context, args.namespace)

        if args.network_policy:
            remove_network_policy(context, namespace, args.network_policy)
            wait_for_network_policy_is_away(context, namespace, args.network_policy)
        else:
            obj = confirm_network_policy(context, namespace)
            if obj is not None and confirm("Do you really want to delete NetworkPolicy " + obj + " in namespace " + namespace + "?"):
                remove_network_policy(context, namespace, obj)
                wait_for_network_policy_is_away(context, namespace, obj)
            else:
                print("No NetworkPolicy removal executed")
Exemple #2
0
    def run(self, args):
        
        context, namespace = choose_context_and_namespace(args.context, args.namespace)

        if args.secret:
            remove_secret(context, namespace, args.secret)
            wait_for_secret_is_away(context, namespace, args.secret)
        else:
            obj = confirm_secret(context, namespace)
            if obj is not None and confirm("Do you really want to delete Secret " + obj + " in namespace " + namespace + "?"):
                remove_secret(context, namespace, obj)
                wait_for_secret_is_away(context, namespace, obj)
            else:
                print("No Secret removal executed")
Exemple #3
0
    def run(self, args):
        
        context, namespace = choose_context_and_namespace(args.context, args.namespace)

        if args.job:
            remove_job(context, namespace, args.job)
            wait_for_job_is_away(context, namespace, args.job)
        else:
            obj = confirm_job(context, namespace)
            if obj is not None and confirm("Do you really want to delete Job " + obj + " in namespace " + namespace + "?"):
                remove_job(context, namespace, obj)
                wait_for_job_is_away(context, namespace, obj)
            else:
                print("No Job removal executed")
    def run(self, args):
        
        context, namespace = choose_context_and_namespace(args.context, args.namespace)

        if args.horizontal_pod_autoscaler:
            remove_horizontal_pod_autoscaler(context, namespace, args.horizontal_pod_autoscaler)
            wait_for_horizontal_pod_autoscaler_is_away(context, namespace, args.horizontal_pod_autoscaler)
        else:
            obj = confirm_horizontal_pod_autoscaler(context, namespace)
            if obj is not None and confirm("Do you really want to delete HorizontalPodAutoscaler " + obj + " in namespace " + namespace + "?"):
                remove_horizontal_pod_autoscaler(context, namespace, obj)
                wait_for_horizontal_pod_autoscaler_is_away(context, namespace, obj)
            else:
                print("No HorizontalPodAutoscaler removal executed")
Exemple #5
0
    def run(self, args):
        context, namespace = common.choose_context_and_namespace(
            args.context, args.namespace)

        if args.pod:
            pod = args.pod
        else:
            pod = confirm_pod(context, namespace)
        print("using pod", pod)

        print(
            "For interactive shell in (the first container of) a pod please use:\n"
            "kubectl config use-context %s\n"
            "kubectl exec -ti %s %s -n %s" % (context, pod, "sh", namespace))
Exemple #6
0
    def run(self, args):
        
        context, namespace = choose_context_and_namespace(args.context, args.namespace)

        if args.lease:
            remove_lease(context, namespace, args.lease)
            wait_for_lease_is_away(context, namespace, args.lease)
        else:
            obj = confirm_lease(context, namespace)
            if obj is not None and confirm("Do you really want to delete Lease " + obj + " in namespace " + namespace + "?"):
                remove_lease(context, namespace, obj)
                wait_for_lease_is_away(context, namespace, obj)
            else:
                print("No Lease removal executed")
Exemple #7
0
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.namespace:
            remove_namespace(context, namespace, args.namespace)
            wait_for_namespace_is_away(context, namespace, args.namespace)
        else:
            if namespace is not None and confirm(
                    "Do you really want to delete Namespace " + namespace +
                    "?"):
                remove_namespace(context, namespace, namespace)
                wait_for_namespace_is_away(context, namespace, namespace)
            else:
                print("No Namespace removal executed")
Exemple #8
0
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.config_map:
            remove_config_map(context, namespace, args.config_map)
            wait_for_config_map_is_away(context, namespace, args.config_map)
        else:
            obj = confirm_config_map(context, namespace)
            if obj is not None and confirm(
                    "Do you really want to delete ConfigMap " + obj +
                    " in namespace " + namespace + "?"):
                remove_config_map(context, namespace, obj)
                wait_for_config_map_is_away(context, namespace, obj)
            else:
                print("No ConfigMap removal executed")
Exemple #9
0
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.pod:
            remove_pod(context, namespace, args.pod)
            wait_for_pod_is_away(context, namespace, args.pod)
        else:
            obj = confirm_pod(context, namespace)
            if obj is not None and confirm(
                    "Do you really want to delete Pod " + obj +
                    " in namespace " + namespace + "?"):
                remove_pod(context, namespace, obj)
                wait_for_pod_is_away(context, namespace, obj)
            else:
                print("No Pod removal executed")
Exemple #10
0
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.resource_quota:
            remove_resource_quota(context, namespace, args.resource_quota)
            wait_for_resource_quota_is_away(context, namespace,
                                            args.resource_quota)
        else:
            obj = confirm_resource_quota(context, namespace)
            if obj is not None and confirm(
                    "Do you really want to delete ResourceQuota " + obj +
                    " in namespace " + namespace + "?"):
                remove_resource_quota(context, namespace, obj)
                wait_for_resource_quota_is_away(context, namespace, obj)
            else:
                print("No ResourceQuota removal executed")
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.role_binding:
            remove_role_binding(context, namespace, args.role_binding)
            wait_for_role_binding_is_away(context, namespace,
                                          args.role_binding)
        else:
            obj = confirm_role_binding(context, namespace)
            if obj is not None and confirm(
                    "Do you really want to delete RoleBinding " + obj +
                    " in namespace " + namespace + "?"):
                remove_role_binding(context, namespace, obj)
                wait_for_role_binding_is_away(context, namespace, obj)
            else:
                print("No RoleBinding removal executed")
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.controller_revision:
            remove_controller_revision(context, namespace,
                                       args.controller_revision)
            wait_for_controller_revision_is_away(context, namespace,
                                                 args.controller_revision)
        else:
            obj = confirm_controller_revision(context, namespace)
            if obj is not None and confirm(
                    "Do you really want to delete ControllerRevision " + obj +
                    " in namespace " + namespace + "?"):
                remove_controller_revision(context, namespace, obj)
                wait_for_controller_revision_is_away(context, namespace, obj)
            else:
                print("No ControllerRevision removal executed")
Exemple #13
0
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.replication_controller:
            remove_replication_controller(context, namespace,
                                          args.replication_controller)
            wait_for_replication_controller_is_away(
                context, namespace, args.replication_controller)
        else:
            obj = confirm_replication_controller(context, namespace)
            if obj is not None and confirm(
                    "Do you really want to delete ReplicationController " +
                    obj + " in namespace " + namespace + "?"):
                remove_replication_controller(context, namespace, obj)
                wait_for_replication_controller_is_away(
                    context, namespace, obj)
            else:
                print("No ReplicationController removal executed")
    def run(self, args):

        context, namespace = choose_context_and_namespace(
            args.context, args.namespace)

        if args.persistent_volume_claim:
            remove_persistent_volume_claim(context, namespace,
                                           args.persistent_volume_claim)
            wait_for_persistent_volume_claim_is_away(
                context, namespace, args.persistent_volume_claim)
        else:
            obj = confirm_persistent_volume_claim(context, namespace)
            if obj is not None and confirm(
                    "Do you really want to delete PersistentVolumeClaim " +
                    obj + " in namespace " + namespace + "?"):
                remove_persistent_volume_claim(context, namespace, obj)
                wait_for_persistent_volume_claim_is_away(
                    context, namespace, obj)
            else:
                print("No PersistentVolumeClaim removal executed")
Exemple #15
0
    def run(self, args):
        context, namespace = common.choose_context_and_namespace(
            args.context, args.namespace)

        if args.set_type is not None and args.set_name is not None:
            remove_set(context, namespace, args.set_type, args.set_name)
            if args.no_wait is None or args.no_wait is False:
                wait_for_set_is_away(context, namespace, args.set_type,
                                     args.set_name)
        else:
            set = confirm_set(context, namespace)
            set_type = common.detect_set_type(set)

            set_name = set.metadata.name
            if set_name and confirm("Do you really want to delete set " +
                                    set_name + " in namespace " + namespace +
                                    "?"):
                remove_set(context, namespace, set_type, set_name)
                if args.no_wait is None or args.no_wait is False:
                    wait_for_set_is_away(context, namespace, set_type,
                                         set_name)
            else:
                print("NO set removal executed")
    def run(self, args):
        print("Starting scaling deployment")
        context, namespace = choose_context_and_namespace(args.context, args.namespace)

        if args.deployment is not None:
            deployment = args.deployment
        else:
            deployment = confirm_deployment(context, namespace)

        api = client.ExtensionsV1beta1Api()
        ret, status, _ = api.read_namespaced_deployment_scale_with_http_info(deployment, namespace)

        # detected desired and current state
        desired_replica_count = "undefined"
        current_replica_count = "undefined"
        if hasattr(ret.spec, "replicas") and ret.spec.replicas is not None:
            desired_replica_count = int(ret.spec.replicas)
        if hasattr(ret.status, "replicas") and ret.status is not None:
            current_replica_count = int(ret.status.replicas)

        print("Deployment %s has %s/%s replicas" % (ret.metadata.name, desired_replica_count, current_replica_count))

        replica_count = confirm_number("Please enter a number of replicas for scaling",
                                       "Current replicas: %s" % current_replica_count)

        if confirm(
                "Do you really want to scale Deployment '%s' in context '%s' from %d to %d replicas?"
                % (deployment, context, current_replica_count, replica_count)):
            print("Scaling deployment %s to %d replicas..." % (deployment, replica_count))
            ret, status, _ = api.patch_namespaced_deployment_scale_with_http_info(deployment, namespace, {
                'spec': {
                    'replicas': replica_count,
                }})
            print("Finish scale scaling deployment '%s'" % deployment)
        else:
            print("No change executed in namespace '%s'." % namespace)