Kubernetes-dashboard安装:修订间差异
跳转到导航
跳转到搜索
小 导入1个版本 |
|||
| 第1行: | 第1行: | ||
=ins= | =ins= | ||
==for aws eks== | |||
<pre> | |||
cat setup-dashboard.sh | |||
#!/bin/bash | |||
#Dec29 2025 | |||
set -e | |||
echo "🚀 部署 Kubernetes Dashboard..." | |||
#kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml | |||
#if have recommended.yaml here just apply local file | |||
kubectl apply -f recommended.yaml | |||
echo "👤 创建管理员用户..." | |||
kubectl apply -f dashboard-admin.yaml | |||
echo "⏳ 等待 Dashboard 启动..." | |||
kubectl wait --for=condition=ready pod -l k8s-app=kubernetes-dashboard -n kubernetes-dashboard --timeout=120s | |||
echo "" | |||
echo "✅ Dashboard 部署完成!" | |||
echo "" | |||
echo "🔑 获取登录 Token:" | |||
kubectl -n kubernetes-dashboard create token admin-user | |||
echo "" | |||
echo "📌 请复制上面的 Token" | |||
echo "" | |||
echo "🌐 在新终端运行: kubectl proxy" | |||
echo "🔗 然后访问: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/" | |||
</pre> | |||
== for Mainland China== | |||
<pre> | <pre> | ||
1.安装是一定要FQ | 1.安装是一定要FQ | ||
| 第64行: | 第95行: | ||
</pre> | </pre> | ||
=usage= | =usage= | ||
2025年12月29日 (一) 15:16的最新版本
ins
for aws eks
cat setup-dashboard.sh #!/bin/bash #Dec29 2025 set -e echo "🚀 部署 Kubernetes Dashboard..." #kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml #if have recommended.yaml here just apply local file kubectl apply -f recommended.yaml echo "👤 创建管理员用户..." kubectl apply -f dashboard-admin.yaml echo "⏳ 等待 Dashboard 启动..." kubectl wait --for=condition=ready pod -l k8s-app=kubernetes-dashboard -n kubernetes-dashboard --timeout=120s echo "" echo "✅ Dashboard 部署完成!" echo "" echo "🔑 获取登录 Token:" kubectl -n kubernetes-dashboard create token admin-user echo "" echo "📌 请复制上面的 Token" echo "" echo "🌐 在新终端运行: kubectl proxy" echo "🔗 然后访问: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/"
for Mainland China
1.安装是一定要FQ
2. docker pull k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
kubectl get pod --all-namespaces
kubectl describe pod kubernetes-dashboard-54fb766c84-cnj98 --namespace=kube-system
#开始安装
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/alternative/kubernetes-dashboard.yaml
kubectl create -f kubernetes-dashboard.yaml
kubectl --namespace=kube-system get deployment kubernetes-dashboard
NAME READY UP-TO-DATE AVAILABLE AGE
kubernetes-dashboard 0/1 1 0 105s
kubernetes-dashboard 1/1 1 1 21m
#修改配置
evan@k8s-master:~$ kubectl --namespace=kube-system edit service kubernetes-dashboard
service/kubernetes-dashboard edited
type: ClusterIP --> type: NodePort
evan@k8s-master:~$ kubectl --namespace=kube-system get service kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard NodePort 10.102.158.92 <none> 80:30875/TCP 2m27s
kubectl get secret --all-namespaces|grep dashboard
kube-system kubernetes-dashboard-token-88d6q kubernetes.io/service-account-token 3 36m
evan@k8s-master:~$ kubectl describe secret/kubernetes-dashboard-token-88d6q -n kube-system
有问题FQ delete 就行
kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/alternative/kubernetes-dashboard.yaml
#权限配置
cat dashboard-admin.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
labels:
k8s-app: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: kube-system
kubectl apply -f dashboard-admin.yaml
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
masterip:nodeport