写一个k8s dashboard
时间: 2024-01-16 07:18:14 浏览: 82
以下是搭建Kubernetes Dashboard的步骤:
1. 选择版本:根据你的Kubernetes版本选择相应的Dashboard版本。你可以在GitHub上的Kubernetes Dashboard发布页面找到不同版本的Dashboard。
2. 下载yaml:使用wget命令下载相应版本的yaml文件。例如,如果你选择的版本是v2.4.0,可以使用以下命令下载yaml文件:
```shell
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml
```
3. 执行yaml:使用kubectl命令执行下载的yaml文件,部署Dashboard。执行以下命令:
```shell
kubectl apply -f recommended.yaml
```
4. 访问Dashboard:使用kubectl命令创建一个代理,以便可以通过本地浏览器访问Dashboard。执行以下命令:
```shell
kubectl proxy
```
然后,在浏览器中访问以下URL:http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
5. Token登录:在上一步中打开的页面上选择“Token”选项,然后使用以下命令获取登录令牌:
```shell
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
```
将输出中的令牌复制到登录页面的令牌输入框中,然后点击“Sign In”按钮登录。
6. 配置权限:如果你想为Dashboard配置访问权限,可以创建一个具有适当权限的ServiceAccount,并将其与ClusterRoleBinding关联。这样,你可以根据需要控制用户对Dashboard的访问权限。
阅读全文
相关推荐














