kubernetes的dashboard搭建使用

1.查看k8s的版本

复制代码
kubectl version

#  下面是版本,GitVersion是v1.25.16
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.16", GitCommit:"c5f43560a4f98f2af3743a59299fb79f07924373", GitTreeState:"clean", BuildDate:"2023-11-15T22:39:12Z", GoVersion:"go1.20.10", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.16", GitCommit:"c5f43560a4f98f2af3743a59299fb79f07924373", GitTreeState:"clean", BuildDate:"2023-11-15T22:28:05Z", GoVersion:"go1.20.10", Compiler:"gc", Platform:"linux/amd64"}

2.在仓库里找对应的版本关系:Release v2.7.0 · kubernetes/dashboard · GitHub

如果是内网,下载对应的yaml: https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

3.安装:

a) 安装面板

修改下载的recommended.yaml,新增type和nodePort。

bash 复制代码
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: 30009 # 新增
  selector:
    k8s-app: kubernetes-dashboard

安装面板

复制代码
kubectl apply -f recommended.yaml

b)创建用户并授权

复制代码
vim dash-admin.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: admin-user
    namespace: kubernetes-dashboard

---

apiVersion: v1
kind: Secret
metadata:
  name: admin-user-token
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/service-account.name: admin-user
type: kubernetes.io/service-account-token
bash 复制代码
kubectl apply -f dash-admin.yaml

4.登录使用

a)查看token:

bash 复制代码
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')

b) 使用 https://<ip>:<前面定义的nodePort,这里是30009>,输入token登录即可

相关推荐
代码改善世界6 小时前
【前瞻创想】Kurator:驾驭分布式云原生世界的“统一舰队”
分布式·云原生
java_logo6 小时前
MySQL Server Docker 容器化部署指南
linux·运维·数据库·docker·容器
代码改善世界7 小时前
【探索实战】从零到一:Kurator 构建分布式云原生平台的探索与实践
分布式·云原生
e***19357 小时前
docker compose安装redis
redis·docker·容器
hadage2337 小时前
--- docker 一些指令的汇总 ---
运维·docker·容器
车传新7 小时前
Docker
docker·容器
BullSmall7 小时前
15分钟速通Docker核心实战
运维·docker·容器
小马爱打代码7 小时前
k8s:SpringBoot应用容器化
spring boot·容器·kubernetes