Installation Dashboard on Kubernetes-1.25.2

一、Installation Dashboard on Kubernetes-1.25.2

Dashboard 用于展示集群中的各类资源,同时也可以通过Dashboard实时查看Pod的日志和在容器中执行一些命令等。

链接:https://github.com/kubernetes/dashboard/releases

下载页面中看到dashboard v2.7.0是支持Kuberneres 1.25版本的

1 wget 下载

cd /opt/kubernetes/addons
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

2 修改

vim /opt/kubernetes/addons/recommended.yaml
...
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: 30005 #添加这行
  selector:
    k8s-app: kubernetes-dashboard
...

3 查看镜像

 grep "image:" recommended.yaml
     image: kubernetesui/dashboard:v2.7.0
     image: kubernetesui/metrics-scraper:v1.0.8

4 安装

[root@kube-master01 addons]# kubectl  create -f /opt/kubernetes/addons/recommended.yaml
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created

5 创建管理员用户 admin.yaml

cat > /opt/kubernetes/addons/admin.yaml <<EOF
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
EOF

6 应用admin

[root@kube-master01 addons]# kubectl apply -f /opt/kubernetes/addons/admin.yaml
serviceaccount/admin-user created
clusterrolebinding.rbac.authorization.k8s.io/admin-user created

7 查看 dashboard 状态,浏览器访问端口号

kubectl get sc,csr,node,svc,pod -A -o wide

8 登录dashboard

在谷歌浏览器(Chrome)启动文件中加入启动参数,用于解决无法访问Dashboard的问题。

--test-type --ignore-certificate-errors

9 访问Dashboard:https://192.168.80.22:30008

10 token登录

创建token

kubectl -n kubernetes-dashboard create token admin-user

 

11 使用 kubeconfig 文件登录dashboard

# 先获取token
kubectl -n kubernetes-dashboard create token admin-user
# 复制admin文件
cp /opt/kubernetes/conf/admin.kubeconfig kubeconfig

vim kubeconfig 
...
#在最下面添加token
    token:

# 使用Xftp下载 kubeconfig 文件到 PC端

二、安装 Kubernetes-1.25.2

Kubernetes-1.25.2 Relevant Download Page:https://www.cnblogs.com/huaxiayuyi/p/16822521.html

Installation Kubernetes-1.25.2 on CentOS 8.3:https://www.cnblogs.com/huaxiayuyi/p/16831960.html

posted @ 2022-10-25 14:15  娇小赤雅  阅读(397)  评论(1编辑  收藏  举报