Relies on the Kubenets DNS service
Address: https://note.youdao.com/web/#/file/WEB42cf75c02ae113136ff664f3f137cb67/note/WEB0eec19f3667471969b3354b7128fda9c/
The implementation of the graphical presentation metrics requires the integration of another addons component of the k8s: Heapster.
Heapster Native supports k8s (v1.0.6 and later versions) and CoreOS, and supports a variety of storage backend, such as InfluxDB, ElasticSearch, Kafka.
Mirror address:
Index.tenxcloud.com/jimmy/heapster-amd64:v1.3.0-beta.1index.tenxcloud.com/jimmy/ heapster-influxdb-amd64:v1.1.1index.tenxcloud.com/jimmy/heapster-grafana-amd64:v4.0.2
Installing Heapster
Heapster-deployment.yaml
[[Email Protected]_master UI]#Cat Heapster-deployment.yamlapiversion:extensions/V1beta1kind:Deploymentmetadata:name:heapster Namespace:kube-Systemspec:replicas:1template:metadata:labels:task:monitoring k8s-app:heapster spec:containers:-name:heapster image:index.tenxcloud.com /jimmy/heapster-amd64:v1.3.0-beta.1imagepullpolicy:ifnotpresent Command:- /Heapster---source=kubernetes:http://192.168.132.148:8080?inclusterconfig=false---sink=influxdb:http://monitoring-influxdb:8086
Note: modify ---source for your own master apiserver access address , Modify the image address (provided above)
Heapster-service.yaml
[[Email Protected]_master UI]#Cat Heapster-service.yamlapiVersion:v1kind:Servicemetadata:labels:task:monitoring#For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) #If You is not using the this as a addon, you should comment out of this line.Kubernetes.io/cluster-service:'true'Kubernetes.io/name:heapster name:heapster Namespace:kube-Systemspec:ports:-PORT:80Targetport:8082selector:k8s-app:heapster
Create Deployment and Service
# kubectl create-f Heapster-deployment.yaml # kubectl create-f Heapster-service.yaml
Configure Influxdb
INFLUXDB official recommends using the command line or HTTP API interface to query the database, starting from the v1.1.0 version by default to close the Admin UI, the Admin UI plugin will be removed in subsequent releases.
the way to open the admin UI in the image is as follows : the INFLUXDB configuration file in the image is piloted, the plugin is turned on, the contents of the configuration file are then written to Configmap, and finally mounted in the mirror, to overwrite the original configuration.
# on the host where the mirror resides, export the Influxdb configuration file in the mirror ' Cat ' -ti heapster-influxdb-amd64:v1.1.1/etc/config.toml >config.toml.orig$ cp config.toml.orig Config.toml
# Modify: Enable Admin interface $ vim config.toml Modify line 35th < enabled = false---> enabled = True
$ #将修改后的config. toml Copy to master, and then write the modified configuration to the Configmap object
$ kubectl Create Configmap influxdb-config-from-file=config.toml-n Kube-system
$ # mount the configuration file in the Configmap to the pod for the purpose of overwriting the original configuration
Influxdb-deployment.yaml file
[[Email Protected]_master UI]#Cat Influxdb-deployment.yamlapiversion:extensions/v1beta1kind:Deploymentmetadata:name:monitoring-influxdb Namespace:kube-Systemspec:replicas:1template:metadata:labels:task:monitoring k8s-app:influxdb spec:containers:-name:influxdb Image: index.tenxcloud.com/jimmy/heapster-influxdb-amd64:v1.1.1volumemounts:-Mountpath:/Data Name:influxdb-Storage-Mountpath:/etc/Name:influxdb-Config volumes:-name:influxdb-config configMap:name:influxdb-Config-name:influxdb-storage emptydir: {}
Influxdb-service.yaml
[[Email Protected]_master UI]#Cat Influxdb-service.yamlapiVersion:v1kind:Servicemetadata:labels:task:monitoring#For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) #If You is not using the this as a addon, you should comment out of this line.Kubernetes.io/cluster-service:'true'Kubernetes.io/name:monitoring-influxdb name:monitoring-influxdb Namespace:kube-systemspec:type:NodePort Ports:-port:8086Targetport:8086name:http-port:8083Targetport:8083Name:api selector:k8s-app:influxdb
Create Deployment and Service
# kubectl create-f Influxdb-deployment.yaml # kubectl create-f Influxdb-service.yaml
Installing Grafana
Grafana-deployment.yaml
[[Email Protected]_master UI]#Cat Grafana-deployment.yamlapiversion:extensions/v1beta1kind:Deploymentmetadata:name:monitoring-Grafana Namespace:kube-Systemspec:replicas:1template:metadata:labels:task:monitoring k8s-App:grafana spec:containers:-Name:grafana Image: index.tenxcloud.com/jimmy/heapster-grafana-amd64:v4.0.2Ports:-containerport:3000protocol:tcp volumemounts:-Mountpath:/var Name:grafana-Storage env:-name:influxdb_host value:monitoring-Influxdb-Name:grafana_port Value:" the" #The following env variables is 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 are 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: {}
Grafana-service.yaml
[[Email Protected]_master UI]#Cat Grafana-service.yamlApiVersion:v1kind:Servicemetadata:labels:#For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) #If You is not using the this as a addon, you should comment out of this line.Kubernetes.io/cluster-service:'true'Kubernetes.io/name:monitoring-Grafana name:monitoring-Grafana Namespace:kube-Systemspec:#in a production setup, we recommend accessing Grafana through an external loadbalancer #or through a public IP. #Type:loadbalancer #You could also use Nodeport to expose the service at a randomly-generated port #Type:nodeportPorts:-PORT:80Targetport:3000selector:k8s-app:grafana
Create Deployment and Service
# kubectl create-f Grafana-deployment.yaml # kubectl create-f Grafana-service.yaml
Get all Pods
[[Email Protected]_master UI] # kubectl get pod-n kube-systemNAME ready STATUS restarts ageheapster- 3275159538-FDVHF 1/1 Running 0 5skubernetes-dashboard-latest-1381663337-0wwml 1/1 Running 1 19hmonitoring-grafana-2812960871-gbsdf 1/1 Running 1 16hmonitoring-influxdb-1975863524-nmbpk 1/1 Running 1 16h
Print Log
[[Email Protected]_master UI] # kubectl logs-f pods/heapster-3275159538-fdvhf-n kube-system
If not configured DNS,INFLUXDB will report the following error
Access verification:
Http://192.168.132.148:8080/ui
Verify Influxdb
8086 Port corresponds to 31878
Access:
http://192.168.132.148:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb:8083/
The IP here is the host that deploys the INFLUXDB
Direct return
Establish Heapster Influxdb Grafana cluster performance monitoring platform