k8s核心组件----UI界面Dashboard

一、Dashboard简介

Dashboard 是基于网页的 Kubernetes 用户界面。您可以使用 Dashboard 将容器应用部署到 Kubernetes 集群中,也可以对容器应用排错,还能管理集群本身及其附属资源。您可以使用 Dashboard 获取运行在集群中的应用的概览信息,也可以创建或者修改 Kubernetes 资源(如 Deployment,Job,DaemonSet 等等)。例如,您可以对 Deployment 实现弹性伸缩、发起滚动升级、重启 Pod 或者使用向导创建新的应用。

二、k8s集群部署Dashboard

k8s集群搭建文档参考:k8s核心组件----kubeadm初始化集群(v1.14.2)

2.1、获取github上Dashboard部署的yaml文件

Dashboard的github地址

[root@master ~]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
--2019-07-30 11:03:36--  https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
正在解析主机 raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.228.133
正在连接 raw.githubusercontent.com (raw.githubusercontent.com)|151.101.228.133|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4577 (4.5K) [text/plain]
正在保存至: “kubernetes-dashboard.yaml”

100%[=========================================================================================================================================================================>] 4,577       --.-K/s 用时 0s      

2019-07-30 11:03:38 (16.0 MB/s) - 已保存 “kubernetes-dashboard.yaml” [4577/4577])

2.2、修改下载的kubernetes-dashboard.yaml文件

service模块配置暴露k8s集群外部访问端口,配置如下:

# ------------------- Dashboard Service ------------------- #

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
    - port: 443
      targetPort: 8443
      nodePort: 30001
  selector:
    k8s-app: kubernetes-dashboard

修改与文件镜像

-        image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
+        image: cuiyf/kubernetes-dashboard-amd64:v1.10.1

2.3、启动Dashboard

[root@master yaml]# kubectl create -f kubernetes-dashboard.yaml 
secret/kubernetes-dashboard-certs created
serviceaccount/kubernetes-dashboard created
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
deployment.apps/kubernetes-dashboard created
service/kubernetes-dashboard created

2.4、访问node节点:https://nodeip:30001

注意:一定要https,web界面如下:
k8s核心组件----UI界面Dashboard_第1张图片

2.5、使用令牌登录(需要创建能够访问 Dashboard 的用户)

account.yaml配置如下:

# Create Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
# Create ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system

创建用户:

[root@master yaml]# kubectl create -f account.yaml

获取tocken:

[root@master ~]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
Name:         admin-user-token-p7p6p
Namespace:    kube-system
Labels:       
Annotations:  kubernetes.io/service-account.name: admin-user
              kubernetes.io/service-account.uid: aef9512e-b1e6-11e9-ac67-0800273a2eb7

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1025 bytes
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXA3cDZwIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJhZWY5NTEyZS1iMWU2LTExZTktYWM2Ny0wODAwMjczYTJlYjciLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.Z5VD5NBGUWTxteQoKsKSJNyQDBMNT5MlEB_WI60qjvltK2lggyxiN5pJdo0Rz7C9RP_HFMN4Vkni2X7zHvEIGuAKda74V4JQXg8wzQoQR-kX70f3YZWNEw5wkSZjKCNcWnxcptWAdDAHnsk_gMhR5nWqTKOkk3CZMKFZbJQ-fdkuw9GnyAfBJTSmg2ajXi4FSaRiQlhAr9fH9954Ed5iht5TZipVvb7T4LN-3Ba5rPBqFqKnyp92pntN-UTpesvo7oAffrauSyIjIU10zu4OEvrvQysAa5lT9beyMOQsWJ82_Owqqk4fYUyfsmc-KGVaa8XeR808DiPypwGvGy2oGg

2.6、最终登录界面如下k8s核心组件----UI界面Dashboard_第2张图片

参考资料

Kubernetes Dashboard 及监控组件 Heapster 部署

附004.Kubernetes Dashboard简介及使用

你可能感兴趣的:(Kubernetes)