在近期的 K8S 开发调试的过程中,总会想知道 Node 或者 Pod 的更多信息。但
$ kubectl top node
$ kubectl top pod
中的 top 操作符,需要 metrics 服务的支持。
同理,DashBoard-UI 也需要通过 metrics 获得资源使用状态。
所以,盘他没商量。。。
$ git clone https://github.com/kubernetes-sigs/metrics-server.git
$ cd metrics-server/deploy/kubernetes
加入以下内容(command 部分),并修改镜像源
$ vim metrics-server-deployment.yaml
...
containers:
- name: metrics-server
image: bluersw/metrics-server-amd64:v0.3.6
imagePullPolicy: IfNotPresent
command:
- /metrics-server
- --kubelet-preferred-address-types=InternalIP
- --kubelet-insecure-tls
...
k8s.gcr.io/metrics-server-amd64:v0.3.6 => bluersw/metrics-server-amd64:v0.3.6
$ kubectl apply -f .
$ kubectl top node
$ wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta5/aio/deploy/recommended.yaml
添加 kubernetes-dashboard 的 ClusterRole 所需的权限,也可直接使用我已经改好的发布文件 https://raw.githubusercontent.com/PharbersDeveloper/BP-Server-Deploy/master/core-compose/dashboard.yaml
- apiGroups: [""]
resources:
- "nodes"
- "namespaces"
- "pods"
- "events"
- "secrets"
- "configmaps"
- "replicationcontrollers"
- "persistentvolumeclaims"
- "services"
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources:
- "ingresses"
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources:
- "statefulsets"
- "replicasets"
- "deployments"
- "daemonsets"
verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
resources:
- "jobs"
- "cronjobs"
verbs: ["get", "list", "watch"]
$ kubectl apply -f dashboard.yaml
确保已经配置了相关集群的 config-cert,并在此环境中
启动 ApiServer 代理
$ kubectl proxy
生成 token,复制打印的 token 并以其登陆
$ kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep kubernetes-dashboard-token | awk ‘{print $1}‘)
K8S 资源收集和展示 top & DashBoard-UI
原文:https://www.cnblogs.com/clockq/p/12622195.html