What is Grafana?範例檔案Deploy Grafana On KubernetesStep 1: Create a file named grafana-datasource-config.yamlStep 2: Create the configmap using the following command.Step 3: Create a file named deployment.yamlStep 4: Create the deploymentStep 5: Create a service file named service.yaml查看 nodePort
What is Grafana?
an open-source lightweight dashboard tool, which can be integrated with many data sources like
Prometheus
, AWS cloud watch
, Stackdriver
範例檔案
git clone https://github.com/bibinwilson/kubernetes-grafana.git
Deploy Grafana On Kubernetes
Step 1: Create a file named grafana-datasource-config.yaml
Note:
The following data source configuration is for Prometheus. If you have more data sources, you can add more data sources with different YAMLs under the data section.
apiVersion: v1 kind: ConfigMap metadata: name: grafana-datasources namespace: monitoring data: prometheus.yaml: |- { "apiVersion": 1, "datasources": [ { "access":"proxy", "editable": true, "name": "prometheus", "orgId": 1, "type": "prometheus", "url": "http://prometheus-service.monitoring.svc:8080", "version": 1 } ] }
Step 2: Create the configmap using the following command.
microk8s kubectl create -f grafana-datasource-config.yaml
Step 3: Create a file named deployment.yaml
Note:
This Grafana deployment does not use a persistent volume. If you restart the pod all changes will be gone.
如果需要的話可以去查
persistent volume
apiVersion: apps/v1 kind: Deployment metadata: name: grafana namespace: monitoring spec: replicas: 1 selector: matchLabels: app: grafana template: metadata: name: grafana labels: app: grafana spec: containers: - name: grafana image: grafana/grafana:latest ports: - name: grafana containerPort: 3000 resources: limits: memory: "1Gi" cpu: "1000m" requests: memory: 500M cpu: "500m" volumeMounts: - mountPath: /var/lib/grafana name: grafana-storage - mountPath: /etc/grafana/provisioning/datasources name: grafana-datasources readOnly: false volumes: - name: grafana-storage emptyDir: {} - name: grafana-datasources configMap: defaultMode: 420 name: grafana-datasources
Step 4: Create the deployment
microk8s kubectl create -f deployment.yaml
Step 5: Create a service file named service.yaml
apiVersion: v1 kind: Service metadata: name: grafana namespace: monitoring annotations: prometheus.io/scrape: 'true' prometheus.io/port: '3000' spec: selector: app: grafana type: NodePort ports: - port: 3000 targetPort: 3000
microk8s kubectl create -f service.yaml
查看 nodePort
microk8s kubectl get svc --namespace=monitoring
查看目前的 node port 在哪裡
假設是在
3000:30617/TCP
那你輸入
http://<node-ip>:30617/login
就可以看到儀表板囉!issue: grafana 顯示 plugin.downStreamError
可以去改
deployment
的設定檔,指定 image 的版本為更新或舊的