sh 简单的Kubernetes仪表板管理,用于本地开发

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 简单的Kubernetes仪表板管理,用于本地开发相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env bash

# Usage
#
# Start: ./kubernetes-dashboard-dev.sh k8s-dashboard-start
# Stop: ./kubernetes-dashboard-dev.sh k8s-dashboard-stop
#

K8S_DASHBOARD_PORT=30000

k8s-dashboard-start () {
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

    until kubectl get pods --namespace=kube-system | grep kubernetes-dashboard &> /dev/null
	    do
	        sleep 1
        done

    kube_dashboard_name=$(kubectl get pods --namespace=kube-system | grep kubernetes-dashboard | awk '{print $1}')

    until [ "true" == "$(kubectl get pod --namespace=kube-system ${kube_dashboard_name} -o json | jq -r .status.containerStatuses[0].ready)" ]
	    do
	        sleep 1
        done

    nohup kubectl port-forward $(kubectl get pods --namespace=kube-system | grep kubernetes-dashboard | awk '{print $1}') ${K8S_DASHBOARD_PORT}:8443 --namespace=kube-system &> /dev/null &

    echo "Kubernetes dashboard available at https://localhost:${K8S_DASHBOARD_PORT}"

}

k8s-dashboard-stop() {
    kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
    kill $(lsof -nP -i tcp:${K8S_DASHBOARD_PORT} | grep LISTEN | awk '{print $2}')
}

$*

以上是关于sh 简单的Kubernetes仪表板管理,用于本地开发的主要内容,如果未能解决你的问题,请参考以下文章

sh kubernetes仪表板外壳

Kubernetes仪表板-尝试生成管理员令牌时出现ansible任务错误

安装部署 Kubernetes 仪表板(Dashboard)

Kubernetes之部署Dashboard UI

Kubernetes之部署Dashboard UI

Kubernetes之部署Dashboard UI