Пример #1
0
def start_dashboard():
    print("starting kube-dashboard.")
    cmd("kubectl create -f {}sa-admin-user.yaml".format(_script_dir))
    cmd("kubectl create -f {}sa-clusterrolebinding-admin-user.yaml".format(_script_dir))
    cmd("kubectl create -f https://raw.githubusercontent.com/"
        "kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml")
    import time
    time.sleep(5)
    cmd("kubectl proxy >> ~/log/kube-build.log 2>&1 &")
    cmd("kubectl -n kube-system describe secret "
        "$(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')")
    print("done.")
Пример #2
0
def port():
    # TODO: better way of getting the prometheus pod
    cmd("pkill kubectl || true")
    cmd("kubectl port-forward -n monitoring "
        "$(kubectl get pods -n monitoring -o name | grep prometheus-deployment | cut -d \"/\" -f2) "
        "{}:{} &>/dev/null &"
        .format(cg.prometheus_server_port, cg.prometheus_server_port))
    # TODO: replace the keep-alive with kubelet configurations to hold the tunnel
    cmd("watch -n120 curl localhost:{} &> /dev/null &".format(cg.prometheus_server_port))
    print("port forwarding completed.")
Пример #3
0
def cmd_with_bash(command):
    cmd("bash {}".format(command))
Пример #4
0
def stop_monitor():
    prometheus_path = _dir_path + "/../../thirdparty/prometheus"
    cmd("cd {}/contrib/kube-prometheus/; ./hack/cluster-monitoring/teardown".format(prometheus_path))
Пример #5
0
def start_metric_server():
    metric_server_path = _dir_path + "/../metrics-server"
    cmd("kubectl create -f {}/deploy/1.8+/".format(metric_server_path))
Пример #6
0
def start_prometheus_operator():
    cmd("kubectl apply -f https://raw.githubusercontent.com/kubernetes"
        "/kops/master/addons/prometheus-operator/v0.19.0.yaml --validate=false")
    cmd("kubectl get pods -n monitoring")
Пример #7
0
def start_monitor():
    prometheus_path = _dir_path + "/prometheus"
    cmd("kubectl create namespace monitoring; kubectl apply -f {}".format(prometheus_path))
Пример #8
0
def install_schedulers():
    cmd("kubectl create -f {}".format(_dir_path + "/scheduler/origin-scheduler.yaml"))
    cmd("kubectl create -f {}".format(_dir_path + "/scheduler/image-scheduler.yaml"))
Пример #9
0
def make():
    cmd("cd {}; source env.exp; cd ${{KUBE_ROOT}}; "
        "make quick-release".format(_script_dir))
Пример #10
0
def validate_svc():
    cmd("kubectl get svc -n kube-system")
Пример #11
0
def get_dashboard_token():
    cmd("kubectl -n kube-system describe secret "
        "$(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')")
Пример #12
0
def export_cluster():
    cmd(_script_dir + "export.sh")
Пример #13
0
def edit_cluster():
    cmd("source {}; kops edit ig nodes; kops update cluster $NAME --yes; kops rolling-update cluster --yes".format(
        _script_dir + "env.exp"))
Пример #14
0
def update_cluster():
    # update the cluster
    utils.cmd("source {}; kops update cluster --yes".format(_env_file))
Пример #15
0
def upload_ig(ig_config: dict, cmd):
    temp_file = "/tmp/" + utils.uuid_str()
    with open(temp_file, "w") as f:
        f.write(utils.yaml_dump_str(ig_config))
    utils.cmd("source {}; kops {} -f {}".format(_env_file, cmd, temp_file))
    utils.cmd("rm " + temp_file)