声明:本文是实战案例,经过实测检验,提供完整的解决方案。 包括国内网络问题的解决,提供完整的配置文件, 以及各种常见问题的解答等。
1 简介
Kubernetes Dashboard 是 Kubernetes 的官方 web UI(用户界面)。它允许用户管理其 Kubernetes 集群和部署在其上的应用程序。Dashboard 提供了一个图形界面,使得开发者和其他非 Kubernetes 专家能够更容易地了解集群的状态,并执行常见的管理任务。
2 环境
服务器:
192.168.10.90 cm90 kubernetes master
192.168.10.91 cm91 kubernetes node
192.168.10.92 cm92 kubernetes node
OS version: CentOS stream 8
Linux version: v4.18.0-553.5.1.el8.x86_64
Docker version: v26.1.3
Kubectl version: v1.28.2
3 安装Dashboard
3.1 获取Dashboard YAML文件
你可以从Kubernetes Dashboard项目的GitHub Releases页面下载特定版本的YAML文件
一般网络是无法下载的,我们这里直接创建:
vi recommended.yaml
#内容如下:
---
apiVersion: v1
kind: Namespace
metadata:
name: kubernetes-dashboard
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
---
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
type: NodePort
ports:
- port: 443
targetPort: 8443
nodePort: 30043
selector:
k8s-app: kubernetes-dashboard
---
apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-certs
namespace: kubernetes-dashboard
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-csrf
namespace: kubernetes-dashboard
type: Opaque
data:
csrf: ""
---
apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-key-holder
namespace: kubernetes-dashboard
type: Opaque
---
kind: ConfigMap
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-settings
namespace: kubernetes-dashboard
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
labels:
k8s-app: kubernetes-dash