k8s部署prometheus之kube-state-metrics
k8s部署prometheus之kube-state-metrics
·
k8s部署prometheus之kube-state-metrics
-
说明
使用的镜像版本为bitnami/kube-state-metrics:2.2.0 该组件与kubernetes的版本相对应
-
部署kube-state-metrics组件
kubectl apply -f rbac.yaml kubectl apply -f deployment.yaml
rbac.yaml文件
--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: monitoring-kube-state-metrics roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: view subjects: - kind: ServiceAccount name: kube-state-metrics #该账号手动在kubesphere的monitoring项目中添加账号 namespace: monitoring
deployment.yaml文件
--- apiVersion: apps/v1 kind: Deployment metadata: name: kube-state-metrics namespace: monitoring spec: replicas: 1 selector: matchLabels: app: kube-state-metrics template: metadata: labels: app: kube-state-metrics spec: serviceAccountName: kube-state-metrics #与rbac中的账号一致 imagePullSecrets: - name: shu-cn containers: - name: kube-state-metrics # 官方镜像 bitnami/kube-state-metrics:2.2.0 image: shu.cn/prom/kube-state-metrics:2.2.0 args: - '--resources=pods,statefulsets,deployments,namespaces' #指定收集的资源对象 resources: requests: cpu: 100m memory: 200Mi limits: cpu: 150m memory: 300Mi ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: annotations: prometheus.io/scrape: 'true' name: svc-kube-state-metrics namespace: monitoring labels: app: kube-state-metrics spec: type: NodePort ports: - name: tcp-8080 port: 8080 targetPort: 8080 nodePort: 38080 protocol: TCP selector: app: kube-state-metrics
-
浏览器访问检测是否获取到数据
http://节点IP:38080/metrics
更多推荐
已为社区贡献8条内容
所有评论(0)