一  influxdb,grafana 的rc配置文件创建

[root@k8s-master heapster-influxdb]# vim influxdb-grafana-controller.yaml

apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    name: influxGrafana
  name: influxdb-grafana
  namespace: kube-system
spec:
  replicas: 1
  selector:
    name: influxGrafana
  template:
    metadata:
      labels:
        name: influxGrafana
    spec:
      containers:
      - name: influxdb
        image: 192.168.31.50:5000/heapster_influxdb:v0.5
        volumeMounts:
        - mountPath: /data
          name: influxdb-storage
      - name: grafana
        image: 192.168.31.50:5000/heapster_grafana:v2.6.0
        env:
          - name: INFLUXDB_SERVICE_URL
            value: http://monitoring-influxdb:8086
            # 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
            value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
        volumeMounts:
        - mountPath: /var
          name: grafana-storage
      volumes:
      - name: influxdb-storage
        emptyDir: {}
      - name: grafana-storage
        emptyDir: {} 

二,heapster 的rc配置文件

[root@k8s-master heapster-influxdb]# vim heapster-controller.yaml

apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    k8s-app: heapster
    name: heapster
    version: v6
  name: heapster
  namespace: kube-system
spec:
  replicas: 1
  selector:
    k8s-app: heapster
    version: v6
  template:
    metadata:
      labels:
        k8s-app: heapster
        version: v6
    spec:
      containers:
      - name: heapster
        image: 192.168.31.50:5000/heapster:canary
        imagePullPolicy: Always
        command:
        - /heapster
        - --source=kubernetes:http://192.168.31.50:8080?inClusterConfig=false
        - --sink=influxdb:http://monitoring-influxdb:8086

三,事先需要准备好上面标红的三个镜像,并打上对应的标签

镜像可以通过

docker pull  docker.io/kubernetes/heapster_grafana:v2.6.0
docker pull docker.io/kubernetes/heapster_influxdb:v0.5
docker pull docker.io/kubernetes/heapster:canary 

也可以将本地准备好的上传

[root@k8s-master heapster-influxdb]# for n in `ls *.tar.gz`;do docker load -i $n;done  

打标签

[root@k8s-master heapster-influxdb]# docker tag docker.io/kubernetes/heapster_grafana:v2.6.0 192.168.31.50:5000/heapster_grafana:v2.6.0
[root@k8s-master heapster-influxdb]# docker tag docker.io/kubernetes/heapster_influxdb:v0.5 192.168.31.50:5000/heapster_influxdb:v0.5
[root@k8s-master heapster-influxdb]# docker tag docker.io/kubernetes/heapster:canary 192.168.31.50:5000/heapster:canary

推送到私有仓库

docker push 192.168.31.50:5000/heapster_grafana:v2.6.0
docker push 192.168.31.50:5000/heapster_influxdb:v0.5
docker push 192.168.31.50:5000/heapster:canary 

 四 grafana-service (svc配置文件)

 [root@k8s-master heapster-influxdb]# vim grafana-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    kubernetes.io/cluster-service: \'true\'
    kubernetes.io/name: monitoring-grafana
  name: monitoring-grafana
  namespace: kube-system
spec:
  # In a production setup, we recommend accessing Grafana through an external Loadbalancer
  # or through a public IP. 
  # type: LoadBalancer
  ports:
  - port: 80
    targetPort: 3000
  selector:
    name: influxGrafana

 五 heapster-service (svc配置文件)

[root@k8s-master heapster-influxdb]# vim heapster-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    kubernetes.io/cluster-service: \'true\'
    kubernetes.io/name: Heapster
  name: heapster
  namespace: kube-system
spec:
  ports:
  - port: 80
    targetPort: 8082
  selector:
    k8s-app: heapster  

六 influxdb-service (svc配置文件)

[root@k8s-master heapster-influxdb]# vim influxdb-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels: null
  name: monitoring-influxdb
  namespace: kube-system
spec:
  ports:
  - name: http
    port: 8083
    targetPort: 8083
  - name: api
    port: 8086
    targetPort: 8086
  selector:
    name: influxGrafana

八 启动所有的服务

[root@k8s-master heapster-influxdb]# ls *yaml
grafana-service.yaml  heapster-controller.yaml  heapster-service.yaml  influxdb-grafana-controller.yaml  influxdb-service.yaml
[root@k8s-master heapster-influxdb]# kubectl create -f .
service "monitoring-grafana" created
replicationcontroller "heapster" created
service "heapster" created
replicationcontroller "influxdb-grafana" created
service "monitoring-influxdb" created
[root@k8s-master heapster-influxdb]# 

 

 

 

 

版权声明:本文为yuanhua-cai原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/yuanhua-cai/articles/11557619.html