在使用Grafana之前得先佈署好資料庫,因為Grafana需要從資料庫中取出資料才能作呈現。
底下是佈署的YAML清單:
# edge-influxdb.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: default
annotations:
creationTimestamp: null
generation: 1
labels:
app: influxdb
name: influxdb
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: influxdb
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: influxdb
spec:
containers:
- envFrom:
- secretRef:
name: influxdb-creds
image: docker.io/influxdb:1.7.7
imagePullPolicy: IfNotPresent
name: influxdb
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/influxdb
subPath: influxdb
name: var-lib-influxdb
ports:
- name: influxdb
containerPort: 8086
hostPort: 8086
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: var-lib-influxdb
hostPath:
path: /mnt/influxdb
nodeSelector:
name: edge-1
幾個比較重要的地方是:
最後用nodeSelector將服務佈署至指定節點上。
接著在佈署之前,別忘了先創建好secret:
kubectl create secret generic influxdb-creds \
--from-literal=INFLUXDB_DATABASE=db \
--from-literal=INFLUXDB_USERNAME=telegraf \
--from-literal=INFLUXDB_PASSWORD=telegraf \
--from-literal=INFLUXDB_HOST=influxdb
kubectl get secret
kubectl apply -f edge-influxdb.yaml