首先部署grafana pod
1 apiVersion: extensions/v1beta1 2 kind: Deployment 3 metadata: 4 name: monitoring-grafana 5 namespace: kube-system 6 spec: 7 replicas: 1 8 template: 9 metadata: 10 labels: 11 task: monitoring 12 k8s-app: grafana 13 spec: 14 containers: 15 - name: grafana 16 image: grafana/grafana:5.0.0 17 ports: 18 - containerPort: 3000 19 protocol: TCP 20 env: 21 - name: INFLUXDB_HOST 22 value: monitoring-influxdb 23 - name: GF_INSTALL_PLUGINS 24 value: grafana-kubernetes-app
然后部署grafana service
1 apiVersion: v1 2 kind: Service 3 metadata: 4 name: monitoring-grafana 5 namespace: kube-system 6 labels: 7 k8s-app: grafana 8 component: core 9 spec: 10 type: NodePort 11 ports: 12 - port: 3000 13 nodePort: 31000 14 selector: 15 k8s-app: grafana