Exemplo n.º 1
0
            ('Detected a large cluster (> 20) with {} nodes. Consider '
             'setting one or more of the following to decrease the size '
             'of the sysdump as many nodes will slow down the collection '
             'and increase the size of the resulting '
             'archive:\n').format(len(nodes)) +
            '  --nodes       (Nodes to collect from)          \n'
            '  --since       (How far back in time to collect)\n'
            '  --size-limit  (Size limit of Cilium logs)      \n')

        choice = prompt('Continue [y/N] (default is N)? ').strip().lower()
        if not choice or choice == 'n':
            sys.exit(0)

    try:
        sysdump_dir_name = './cilium-sysdump-{}'\
            .format(time.strftime('%Y%m%d-%H%M%S'))
        if not os.path.exists(sysdump_dir_name):
            os.makedirs(sysdump_dir_name)
        sysdumpcollector = sysdumpcollector.SysdumpCollector(
            sysdump_dir_name, args.since, args.size_limit, args.output,
            args.quick, args.cilium_labels, args.hubble_labels,
            args.hubble_relay_labels, args.hubble_ui_labels)
        sysdumpcollector.collect(args.nodes)
        sysdumpcollector.archive()
        sys.exit(0)
    except AttributeError:
        log.exception('Fatal error in collecting sysdump')
        sys.exit(1)

    sys.exit(0)
Exemplo n.º 2
0
        parser_sysdump.add_argument('--size-limit',
                                    type=int,
                                    help='size limit (bytes) for the '
                                    'collected logs',
                                    default=256 * 1024 * 1024)

    args = parser.parse_args()
    try:
        if args.sysdump:
            sysdump_dir_name = "./cilium-sysdump-{}"\
                .format(time.strftime("%Y%m%d-%H%M%S"))
            if not os.path.exists(sysdump_dir_name):
                os.makedirs(sysdump_dir_name)
            sysdumpcollector = sysdumpcollector.SysdumpCollector(
                sysdump_dir_name, args.since, args.size_limit)
            sysdumpcollector.collect()
            sys.exit(0)
    except AttributeError:
        pass
    nodes = utils.get_nodes()

    k8s_check_grp = utils.ModuleCheckGroup("k8s")
    k8s_check_grp.add(
        utils.ModuleCheck("check the kube-apiserver version",
                          lambda: k8schecks.check_kube_apiserver_version_cb()))
    k8s_check_grp.add(
        utils.ModuleCheck("check RBAC configuration",
                          lambda: k8schecks.check_rbac_cb()))
    if not k8s_check_grp.run():
        exit_code = 1