Ejemplo n.º 1
0
        tokens[node.hostname] = (node.kind, node.ip, token)
    print("host".center(16, "="), "kind".center(8, "="), "ip".center(14, "="),
          "token".center(23, "="))
    for key, (kind, ip, token) in sorted(tokens.items()):
        print(key.rjust(16), kind.center(8),
              str(ip).center(14), token.ljust(23))
    print("host".center(16, "="), "kind".center(8, "="), "ip".center(14, "="),
          "token".center(23, "="))


def infra_install_packages(ops: setup.Operations) -> None:
    config = configuration.get_config()
    for node in config.nodes:
        ops.ssh("update apt repositories on @HOST", node, "apt-get", "update")
        ops.ssh("upgrade packages on @HOST", node, "apt-get", "upgrade", "-y")


main_command = command.mux_map(
    "commands about maintaining the infrastructure of a cluster", {
        "admit":
        command.wrap("request a token to admit a node to the cluster",
                     infra_admit),
        "admit-all":
        command.wrap(
            "request tokens to admit every non-supervisor node to the cluster",
            infra_admit_all),
        "install-packages":
        setup.wrapop("install and update packages on a node",
                     infra_install_packages),
    })
Ejemplo n.º 2
0
        tokens.append((node.hostname, node.kind, node.ip, token))
    print('{:=^16} {:=^8} {:=^14} {:=^23}'.format('host', 'kind', 'ip', 'token'))
    for hostname, kind, ip, token in tokens:
        print('{:>16} {:^8} {:^14} {:<23}'.format(hostname, kind, str(ip), token))
    print('{:=^16} {:=^8} {:=^14} {:=^23}'.format('host', 'kind', 'ip', 'token'))


def infra_install_packages(ops: setup.Operations) -> None:
    config = configuration.get_config()
    for node in config.nodes:
        ops.ssh("update apt repositories on @HOST", node, "apt-get", "update")
        ops.ssh("upgrade packages on @HOST", node, "apt-get", "upgrade", "-y")


def infra_sync(ops: setup.Operations, node_name: str) -> None:
    node = configuration.get_config().get_node(node_name)
    ops.ssh("synchronize operations on @HOST", node, "sync")


def infra_sync_supervisor(ops: setup.Operations) -> None:
    infra_sync(ops, configuration.get_config().keyserver.hostname)


main_command = command.mux_map("commands about maintaining the infrastructure of a cluster", {
    "admit": command.wrap("request a token to admit a node to the cluster", infra_admit),
    "admit-all": command.wrap("request tokens to admit every non-supervisor node to the cluster", infra_admit_all),
    "install-packages": setup.wrapop("install and update packages on a node", infra_install_packages),
    "sync": setup.wrapop("synchronize the filesystem to disk on a node", infra_sync),
    "sync-supervisor": setup.wrapop("synchronize the filesystem to disk on the supervisor", infra_sync_supervisor),
})
Ejemplo n.º 3
0
        for key in keys:
            f.write("%s.%s %s\n" %
                    (node.hostname, config.external_domain, key))


def pull_supervisor_key_from(source_file):
    pull_supervisor_key(
        util.readfile(source_file).decode().strip().split("\n"))


etcdctl_command = command.wrap("invoke commands through the etcdctl wrapper",
                               dispatch_etcdctl)
kubectl_command = command.wrap("invoke commands through the kubectl wrapper",
                               dispatch_kubectl)
foreach_command = setup.wrapop(
    "invoke commands on every node (or every node of a given kind) in the cluster",
    ssh_foreach)
main_command = command.mux_map(
    "commands about establishing access to a cluster", {
        "ssh":
        command.wrap(
            "request SSH access to the cluster and add it to the SSH agent",
            access_ssh_with_add),
        "ssh-fetch":
        command.wrap(
            "request SSH access to the cluster but do not register it with the agent",
            access_ssh),
        "update-known-hosts":
        command.wrap(
            "update ~/.ssh/known_hosts file with @ca-certificates directive",
            update_known_hosts),
Ejemplo n.º 4
0
    ops.add_operation("deploy or update dns-addon", deploy.launch_dns_addon)
    ops.add_operation("verify that dns-addon is online", iterative_verifier(verify.check_dns_kubeinfo, 60.0))
    ops.add_operation("verify that dns-addon is functioning", verify.check_dns_function)

    ops.print_annotations("set up the dns-addon")


def sequence_addons(ops: setup.Operations) -> None:
    ops.add_operation("deploy or update flannel", deploy.launch_flannel)
    ops.add_operation("deploy or update dns-addon", deploy.launch_dns_addon)

    ops.add_operation("verify that flannel is online", iterative_verifier(verify.check_flannel_kubeinfo, 60.0))
    ops.add_operation("verify that dns-addon is online", iterative_verifier(verify.check_dns_kubeinfo, 60.0))

    ops.add_operation("verify that flannel is functioning", verify.check_flannel_function)
    ops.add_operation("verify that dns-addon is functioning", verify.check_dns_function)

    ops.print_annotations("set up the dns-addon")


main_command = command.mux_map("commands about running large sequences of cluster bring-up automatically", {
    "keysystem": setup.wrapop("set up and verify functionality of the keyserver and keygateway", sequence_keysystem),
    "ssh": setup.wrapop("set up and verify ssh access to the supervisor node", sequence_ssh),
    "supervisor": setup.wrapop("set up and verify functionality of entire supervisor node (keysystem + ssh)", sequence_supervisor),
    "core": setup.wrapop("set up and verify core infrastructure operation", sequence_core),
    "registry": setup.wrapop("set up and verify the bootstrap container registry", sequence_registry),
    "flannel": setup.wrapop("set up and verify the flannel core service", sequence_flannel),
    "dns-addon": setup.wrapop("set up and verify the dns-addon core service", sequence_dns_addon),
    "addons": setup.wrapop("set up and verify the flannel and dns-addon core services", sequence_addons),
})
Ejemplo n.º 5
0
def sequence_dns_addon(ops: setup.Operations,
                       config: configuration.Config) -> None:
    ops.add_operation("deploy or update dns-addon",
                      lambda: deploy.launch_spec("dns-addon.yaml"))
    ops.add_operation("verify that dns-addon is online",
                      iterative_verifier(verify.check_dns_kubeinfo, 60.0))
    ops.add_operation("verify that dns-addon is functioning",
                      verify.check_dns_function)


main_command = command.mux_map(
    "commands about running large sequences of cluster bring-up automatically",
    {
        "keysystem":
        setup.wrapop(
            "set up and verify functionality of the keyserver and keygateway",
            sequence_keysystem),
        "ssh":
        setup.wrapop("set up and verify ssh access to the supervisor node",
                     sequence_ssh),
        "core":
        setup.wrapop("set up and verify core infrastructure operation",
                     sequence_core),
        "registry":
        setup.wrapop("set up and verify the bootstrap container registry",
                     sequence_registry),
        "flannel":
        setup.wrapop("set up and verify the flannel core service",
                     sequence_flannel),
        "dns-addon":
        setup.wrapop("set up and verify the dns-addon core service",