Heapster是容器集群监控和性能分析工具,天然的支持Kubernetes和CoreOS。
Kubernetes有个出名的监控agent—cAdvisor。在每个kubernetes Node上都会运行cAdvisor,它会收集本机以及容器的监控数据(cpu,memory,filesystem,network,uptime)。
在较新的版本中,K8S已经将cAdvisor功能集成到kubelet组件中。每个Node节点可以直接进行web访问。
1、镜像下载
[[email protected]_master ~]# docker pull ist0ne/heapster-grafana-amd64
[[email protected]_master ~]# docker pull ist0ne/heapster-amd64
[[email protected]_master ~]# docker pull ist0ne/heapster-influxdb-amd64:v1.1.1
2、下载Heapster,最新版本1.3.0
wget https://github.com/kubernetes/heapster/archive/v1.3.0.tar.gz
tar zxf v1.3.0.tar.gz
3、进入heapster-1.3.0/deploy/kube-config/influxdb/目录
[[[email protected]_master heapster-1.3.0]# ls -latr deploy/kube-config/influxdb/
total 24
-rw-rw-r-- 1 root root 477 Mar 17 2017 influxdb-service.yaml
-rw-rw-r-- 1 root root 493 Mar 17 2017 influxdb-deployment.yaml
-rw-rw-r-- 1 root root 453 Mar 17 2017 heapster-service.yaml
-rw-rw-r-- 1 root root 521 Mar 17 2017 heapster-deployment.yaml
-rw-rw-r-- 1 root root 695 Mar 17 2017 grafana-service.yaml
-rw-rw-r-- 1 root root 1417 Mar 17 2017 grafana-deployment.yaml
4、修改配置文件对应的image:
grafana-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-grafana
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
task: monitoring
k8s-app: grafana
spec:
containers:
- name: grafana
image: docker.io/ist0ne/heapster-grafana-amd64:latest
ports:
- containerPort: 3000
protocol: TCP
volumeMounts:
- mountPath: /var
name: grafana-storage
env:
- name: INFLUXDB_HOST
value: monitoring-influxdb
- name: GRAFANA_PORT
value: "3000"
# The following env variables are required to make Grafana accessible via
# the kubernetes api-server proxy. On production clusters, we recommend
# removing these env variables, setup auth for grafana, and expose the grafana
# service using a LoadBalancer or a public IP.
- name: GF_AUTH_BASIC_ENABLED
value: "false"
- name: GF_AUTH_ANONYMOUS_ENABLED
value: "true"
- name: GF_AUTH_ANONYMOUS_ORG_ROLE
value: Admin
- name: GF_SERVER_ROOT_URL
# If you‘re only using the API Server proxy, set this value instead:
# value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
value: /
volumes:
- name: grafana-storage
emptyDir: {}
heapster-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: heapster
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
task: monitoring
k8s-app: heapster
spec:
containers:
- name: heapster
image: docker.io/ist0ne/heapster-amd64:latest
imagePullPolicy: IfNotPresent
command:
- /heapster
- --source=kubernetes:http://192.168.3.216:8080?inClusterConfig=false
- --sink=influxdb:http://monitoring-influxdb:8086
influxdb-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-influxdb
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
task: monitoring
k8s-app: influxdb
spec:
containers:
- name: influxdb
image: docker.io/ist0ne/heapster-influxdb-amd64:v1.1.1
volumeMounts:
- mountPath: /data
name: influxdb-storage
volumes:
- name: influxdb-storage
emptyDir: {}
启动服务
[[email protected]_master heapster-1.3.0]# kubectl create -f deploy/kube-config/influxdb/
删除服务
[[email protected]_master heapster-1.3.0]# kubectl delete -f deploy/kube-config/influxdb/
查看pod
[[email protected]_master ~]# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default busybox 1/1 Running 93 3d
kube-system heapster-4127054459-wzppn 1/1 Running 0 3d
kube-system kube-dns-2074712928-dxv2q 4/4 Running 4 3d
kube-system kubernetes-dashboard-3665076642-9z0jc 1/1 Running 0 3d
kube-system monitoring-grafana-597639858-tqpf2 1/1 Running 0 3d
kube-system monitoring-influxdb-3575671003-9rpkh 1/1 Running 0 3d
web nginx-491251965-dp4xz 1/1 Running 2 4d
web nginx-491251965-rjhhp 1/1 Running 2 4d
打开浏览器http://192.168.3.216:8080/ui
原文地址:http://blog.51cto.com/jonauil/2088665