Esempio n. 1
0
def get_cluster_info():
    ci_raw = utils.cmd_out("source {}; kops get cluster --output yaml".format(
        _env_file)).decode("utf-8")
    ci = yaml.load(ci_raw)

    return {
        "name": ci["metadata"]["name"],
        "region":
        ci["spec"]["subnets"][0]["zone"],  # TODO: support multiple zones
    }
Esempio n. 2
0
def get_all_worker_ig_num():
    docs = utils.cmd_out("source {};  kops get ig --output yaml".format(
        _env_file)).decode("utf-8")
    igs = dict()
    for doc in yaml.load_all(docs):
        assert doc["spec"]["maxSize"] == doc["spec"]["minSize"]
        name = doc["metadata"]["name"]
        if name.startswith("master") or name.endswith("prom"):
            continue

        num = doc["spec"]["maxSize"]
        igs[name] = num
    return igs
Esempio n. 3
0
def get_ig_config_raw(ig_name: str):
    return utils.cmd_out(
        "source {};  kops get ig {} --name $NAME --output yaml".format(
            _env_file, ig_name)).decode("utf-8")
Esempio n. 4
0
def get_ins_ready_num(ins_type: str):
    # TODO: more reliable counting ready nodes
    return utils.cmd_out(
        "source {}; kubectl get nodes -l \"kops.k8s.io/instancegroup={}\" ".
        format(_env_file,
               get_ig_name(ins_type))).decode("utf-8").count(" Ready")