K8S Dashboard

个人比较喜欢k8dash

1、安装 metrics-server

这里使用helm3安装

创建 custom-values.yaml,内容如下

image:
  repository: gcr.azk8s.cn/google_containers/metrics-server-amd64

args:
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP

安装

#!/bin/bash
helm install metrics-server stable/metrics-server --namespace kube-system -f custom-values.yaml

卸载

#!/bin/bash
helm uninstall metrics-server --namespace kube-system

通过下面两条命令metrics-server验证是否安装成功

[root@t1 metrics-server]# kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"
{"kind":"NodeMetricsList","apiVersion":"metrics.k8s.io/v1beta1","metadata":{"selfLink":"/apis/metrics.k8s.io/v1beta1/nodes"},"items":[{"metadata":{"name":"t1","selfLink":"/apis/metrics.k8s.io/v1beta1/nodes/t1","creationTimestamp":"2019-10-11T12:05:30Z"},"timestamp":"2019-10-11T12:04:38Z","window":"30s","usage":{"cpu":"178418503n","memory":"2180400Ki"}},{"metadata":{"name":"t3","selfLink":"/apis/metrics.k8s.io/v1beta1/nodes/t3","creationTimestamp":"2019-10-11T12:05:30Z"},"timestamp":"2019-10-11T12:04:39Z","window":"30s","usage":{"cpu":"103095749n","memory":"1958076Ki"}},{"metadata":{"name":"t2","selfLink":"/apis/metrics.k8s.io/v1beta1/nodes/t2","creationTimestamp":"2019-10-11T12:05:30Z"},"timestamp":"2019-10-11T12:04:42Z","window":"30s","usage":{"cpu":"95541246n","memory":"1968868Ki"}}]}
[root@t1 metrics-server]# kubectl top nodes
NAME   CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
t1     179m         8%     2129Mi          57%       
t2     96m          4%     1922Mi          52%       
t3     104m         5%     1912Mi          51% 

2、安装 k8dash

#创建k8dash
kubectl apply -f k8dash_me.yaml
#获取登录token
./get_token.sh

k8dash_me.yaml 内容如下:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: k8dash-sa
  namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: k8dash-sa
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: k8dash-sa
  namespace: kube-system
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: k8dash
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: k8dash
  template:
    metadata:
      labels:
        k8s-app: k8dash
    spec:
      containers:
      - name: k8dash
        image: herbrandson/k8dash:latest
        ports:
        - containerPort: 4654
        livenessProbe:
          httpGet:
            scheme: HTTP
            path: /
            port: 4654
          initialDelaySeconds: 30
          timeoutSeconds: 30
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
---
kind: Service
apiVersion: v1
metadata:
  name: k8dash-svc
  namespace: kube-system
spec:
  ports:
    - port: 80
      targetPort: 4654
  selector:
    k8s-app: k8dash
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: k8dash-ing
  namespace: kube-system
  labels:
    k8s-app: k8dash
spec:
  rules:
  - host: k8dash.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: k8dash-svc
          servicePort: 80

备注:k8dash.example.com 替换为你的ingress域名

get_token.sh内容如下:

#!/bin/bash
kubectl get secrets -n kube-system |grep k8dash-sa-token|awk '{print $1}'| xargs kubectl describe secret -n kube-system

其他Dashboard

1、官方Dashboard

2、第三方Dashboard

3、rancher 面向应用

4、wayne * https://github.com/Qihoo360/wayne/blob/master/README-CN.md

5、Openshift

参考