Exemple #1
0
    def run(self, args):
        context = choose_context()
        print("Listing all services with cluster.local in external_name",
              context)

        api = client.CoreV1Api()
        svcs = api.list_service_for_all_namespaces()
        print("Found", len(svcs.items), "services in all namespaces")
        counter = 0
        key = "cluster.local"
        print("Namespace\tService\tExternalName\t")
        for svc in svcs.items:
            if key in str(svc.spec.external_name):
                print("%s\t%s\t%s" %
                      (svc.metadata.namespace, svc.metadata.name,
                       svc.spec.external_name))
                counter += 1
        print("Found %u services with an external name containing '%s'" %
              (counter, key))
        # ingress hosts
        api2 = client.ExtensionsV1beta1Api()
        ingresses = api2.list_ingress_for_all_namespaces()
        print("Found %d ingresses in all namespaces" % len(ingresses.items))
        counter = 0
        print("Namespace\tIngress name\tHost name")
        for ing in ingresses.items:
            if ing.spec.rules is not None:
                for rule in ing.spec.rules:
                    if key in str(rule.host):
                        print("%s\t%s\t%s" % (ing.metadata.namespace,
                                              ing.metadata.name, rule.host))
        print("Found %u ingresses with host names containing '%s'" %
              (counter, key))
Exemple #2
0
    def run(self, args):
        context = choose_context(args.context)
        arguments = DynamicArgs(context, args,
                                self.get_additional_attr_config())

        path = arguments.val("path")
        tpl_files = arguments.val("files")
        name = arguments.val("name")

        if isinstance(tpl_files, str):
            tpl_files = [
                tpl_files,
            ]

        for i in tpl_files:
            print(i)
            tpl = YamlTemplateRunner(path, str(i), name)
            if tpl.is_ready():
                if confirm(
                        "Do you want to apply the contents of file with kubectl apply -f "
                        + tpl.rendered_tpl + ""):
                    # apply generated file via kubectl apply -f
                    kubectl_cmd = "kubectl apply -f " + tpl.rendered_tpl
                    print("executing:", kubectl_cmd)
                    print("---")
                    subprocess.run(kubectl_cmd, shell=True)
                    print("---")
                else:
                    print("File is not applied to context", context)
            else:
                print("problem with file", i)
Exemple #3
0
    def run(self, args):
        
        from lib.common import choose_context
        context = choose_context(args.context)

        if args.persistent_volume:
            remove_persistent_volume(context, args.persistent_volume)
            wait_for_persistent_volume_is_away(context, args.persistent_volume)
        else:
            obj = confirm_persistent_volume(context)
            if obj is not None and confirm("Do you really want to delete PersistentVolume " + obj + "?"):
                remove_persistent_volume(context, obj)
                wait_for_persistent_volume_is_away(context, obj)
            else:
                print("No PersistentVolume removal executed")
    def run(self, args):
        
        from lib.common import choose_context
        context = choose_context(args.context)

        if args.storage_class:
            remove_storage_class(context, args.storage_class)
            wait_for_storage_class_is_away(context, args.storage_class)
        else:
            obj = confirm_storage_class(context)
            if obj is not None and confirm("Do you really want to delete StorageClass " + obj + "?"):
                remove_storage_class(context, obj)
                wait_for_storage_class_is_away(context, obj)
            else:
                print("No StorageClass removal executed")
Exemple #5
0
    def run(self, args):
        
        from lib.common import choose_context
        context = choose_context(args.context)

        if args.custom_resource_definition:
            remove_custom_resource_definition(context, args.custom_resource_definition)
            wait_for_custom_resource_definition_is_away(context, args.custom_resource_definition)
        else:
            obj = confirm_custom_resource_definition(context)
            if obj is not None and confirm("Do you really want to delete CustomResourceDefinition " + obj + "?"):
                remove_custom_resource_definition(context, obj)
                wait_for_custom_resource_definition_is_away(context, obj)
            else:
                print("No CustomResourceDefinition removal executed")
    def run(self, args):
        
        from lib.common import choose_context
        context = choose_context(args.context)

        if args.volume_attachment:
            remove_volume_attachment(context, args.volume_attachment)
            wait_for_volume_attachment_is_away(context, args.volume_attachment)
        else:
            obj = confirm_volume_attachment(context)
            if obj is not None and confirm("Do you really want to delete VolumeAttachment " + obj + "?"):
                remove_volume_attachment(context, obj)
                wait_for_volume_attachment_is_away(context, obj)
            else:
                print("No VolumeAttachment removal executed")
    def run(self, args):

        from lib.common import choose_context
        context = choose_context(args.context)

        if args.cluster_role:
            remove_cluster_role(context, args.cluster_role)
            wait_for_cluster_role_is_away(context, args.cluster_role)
        else:
            obj = confirm_cluster_role(context)
            if obj is not None and confirm(
                    "Do you really want to delete ClusterRole " + obj + "?"):
                remove_cluster_role(context, obj)
                wait_for_cluster_role_is_away(context, obj)
            else:
                print("No ClusterRole removal executed")
Exemple #8
0
    def run(self, args):

        from lib.common import choose_context
        context = choose_context(args.context)

        if args.pod_security_policy:
            remove_pod_security_policy(context, args.pod_security_policy)
            wait_for_pod_security_policy_is_away(context,
                                                 args.pod_security_policy)
        else:
            obj = confirm_pod_security_policy(context)
            if obj is not None and confirm(
                    "Do you really want to delete PodSecurityPolicy " + obj +
                    "?"):
                remove_pod_security_policy(context, obj)
                wait_for_pod_security_policy_is_away(context, obj)
            else:
                print("No PodSecurityPolicy removal executed")
Exemple #9
0
    def run(self, args):

        from lib.common import choose_context
        context = choose_context(args.context)

        if args.certificate_signing_request:
            remove_certificate_signing_request(
                context, args.certificate_signing_request)
            wait_for_certificate_signing_request_is_away(
                context, args.certificate_signing_request)
        else:
            obj = confirm_certificate_signing_request(context)
            if obj is not None and confirm(
                    "Do you really want to delete CertificateSigningRequest " +
                    obj + "?"):
                remove_certificate_signing_request(context, obj)
                wait_for_certificate_signing_request_is_away(context, obj)
            else:
                print("No CertificateSigningRequest removal executed")
    def run(self, args):
        context_src = choose_context(args.context)

        arguments = DynamicArgs(context_src, args, self.get_additional_attr_config())
        MariaDBMigration(context_src, arguments).run()