建立Heapster Influxdb Grafana叢集效能監控平台

來源:互聯網
上載者:User

標籤:cat   支援   ssi   temp   logs   file   令行   balance   fan   

依賴於kubenets dns服務
地址:https://note.youdao.com/web/#/file/WEB42cf75c02ae113136ff664f3f137cb67/note/WEB0eec19f3667471969b3354b7128fda9c/

 

圖形化展示度量指標的實現需要整合k8s的另外一個Addons組件: Heapster 。
Heapster原生支援K8s(v1.0.6及以後版本)和 CoreOS ,並且支援多種儲存後端,比如: InfluxDB 、 Elasticsearch 、 Kafka 。

鏡像地址:

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

 

安裝Heapster

 

heapster-deployment.yaml

[[email protected]_master ui]# cat heapster-deployment.yaml apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: heapster  namespace: kube-systemspec:  replicas: 1  template:    metadata:      labels:        task: monitoring        k8s-app: heapster    spec:      containers:      - name: heapster        image: index.tenxcloud.com/jimmy/heapster-amd64:v1.3.0-beta.1        imagePullPolicy: IfNotPresent        command:        - /heapster        - --source=kubernetes:http://192.168.132.148:8080?inClusterConfig=false        - --sink=influxdb:http://monitoring-influxdb:8086

 

注意:修改- --source為自己的master apiserver訪問地址 ,修改image地址(上面已經提供)

 

heapster-service.yaml

[[email protected]_master ui]# cat heapster-service.yaml apiVersion: v1kind: Servicemetadata:  labels:    task: monitoring    # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)    # If you are NOT using this as an addon, you should comment out this line.    kubernetes.io/cluster-service: ‘true‘    kubernetes.io/name: Heapster  name: heapster  namespace: kube-systemspec:  ports:  - port: 80    targetPort: 8082  selector:    k8s-app: heapster

 

建立deployment和service

#kubectl create -f heapster-deployment.yaml#kubectl create -f heapster-service.yaml

 

配置Influxdb

 

influxdb 官方建議使用命令列或 HTTP API 介面來查詢資料庫,從 v1.1.0 版本開始預設關閉 admin UI,將在後續版本中移除 admin UI 外掛程式。
開啟鏡像中 admin UI的辦法如下:先匯出鏡像中的 influxdb 設定檔,開啟外掛程式後,再將設定檔內容寫入 ConfigMap,最後掛載到鏡像中,達到覆蓋原始配置的目的。

$ #在鏡像所在的宿主機上,匯出鏡像中的influxdb設定檔$ docker run --rm --entrypoint ‘cat‘ -ti heapster-influxdb-amd64:v1.1.1 /etc/config.toml >config.toml.orig$ cp config.toml.orig config.toml
$ # 修改:啟用 admin 介面$ vim config.toml修改第35行< enabled = false---> enabled = true

 

$ #將修改後的config.toml拷貝到Master上,再將修改後的配置寫入到ConfigMap對象中

$ kubectl create configmap influxdb-config --from-file=config.toml -n kube-system

$ # 將ConfigMap中的設定檔掛載到Pod中,達到覆蓋原始配置的目的

 

influxdb-deployment.yaml檔案

[[email protected]_master ui]# cat influxdb-deployment.yaml apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: monitoring-influxdb  namespace: kube-systemspec:  replicas: 1  template:    metadata:      labels:        task: monitoring        k8s-app: influxdb    spec:      containers:      - name: influxdb        image: index.tenxcloud.com/jimmy/heapster-influxdb-amd64:v1.1.1        volumeMounts:        - 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.yaml apiVersion: v1kind: Servicemetadata:  labels:    task: monitoring    # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)    # If you are NOT using this as an addon, you should comment out this line.    kubernetes.io/cluster-service: ‘true‘    kubernetes.io/name: monitoring-influxdb  name: monitoring-influxdb  namespace: kube-systemspec:  type: NodePort  ports:  - port: 8086    targetPort: 8086    name: http  - port: 8083    targetPort: 8083    name: api  selector:    k8s-app: influxdb


建立deployment和service

#kubectl create -f influxdb-deployment.yaml#kubectl create -f influxdb-service.yaml

 

安裝grafana

grafana-deployment.yaml

 

[[email protected]_master ui]# cat grafana-deployment.yaml apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: monitoring-grafana  namespace: kube-systemspec:  replicas: 1  template:    metadata:      labels:        task: monitoring        k8s-app: grafana    spec:      containers:      - name: grafana        image: index.tenxcloud.com/jimmy/heapster-grafana-amd64:v4.0.2         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: {}

 

grafana-service.yaml

 

[[email protected]_master ui]# cat grafana-service.yaml apiVersion: v1kind: Servicemetadata:  labels:    # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)    # If you are NOT using this as an addon, you should comment out 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: NodePort  ports:  - port: 80    targetPort: 3000  selector:    k8s-app: grafana

 

 

建立deployment和service

#kubectl create -f grafana-deployment.yaml#kubectl create -f grafana-service.yaml

 

擷取所有pod

 

[[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

 

列印日誌

[[email protected]_master ui]# kubectl logs -f pods/heapster-3275159538-fdvhf -n kube-system

 

如果沒有配置dns,Influxdb會報如下錯誤

 

 

訪問驗證:

http://192.168.132.148:8080/ui

 

 驗證Influxdb

 

8086連接埠對應31878
訪問:
http://192.168.132.148:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb:8083/

這裡的ip為部署influxdb的主機

 

直接斷行符號

 

建立Heapster Influxdb Grafana叢集效能監控平台

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.