Kubernetes集群UI及主机资源监控
1. Kubernetes dashboard作用
- 通过dashboard能够直观了解Kubernetes集群中运行的资源对象,可以直接管理(创建、删除、重启等操作)资源对象
2. 获取Kubernetes dashboard资源清单文件
- 下载kubernetes-dashboard配置文件
cd /data/k8s-work
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml
3. 修改并部署kubernetes dashboard资源清单文件
- 修改kubernetes-dashboard配置文件recommended.yaml文件
vim recommended.yaml
修改后recommended.yaml内容,如下所示
apiVersion: v1
kind: Namespace
metadata:
name: kubernetes-dashboard
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
---
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
#添加type: NodePort,便于暴露服务
type: NodePort
ports:
- port: 443
targetPort: 8443
#添加nodePort: 30000 配置项,将kubernetes-dashboard服务映射到主机的30000端口
nodePort: 30000
selector:
k8s-app: kubernetes-dashboard
---
apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-certs
namespace: kubernetes-dashboard
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-csrf
namespace: kubernetes-dashboard
type: Opaque
data:
csrf: ""
---
apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-key-holder
namespace: kubernetes-dashboard
type: Opaque
---
#添加service-account-token配置,便于kubernetes-dashboard登录使用(切记:一定要加,否则无法获取到登录token)
apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-token
namespace: kubernetes-dashboard
annotations:
kubernetes.io/service-account.name: "kubernetes-dashboard"
type: kubernetes.io/service-account-token
---
kind: ConfigMap
apiVersion: v1
metadata:
labels