apiVersion: apps/v1
kind: Deployment
metadata:
  name: influxdb
  labels:
    app: influxdb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: influxdb
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: influxdb
    spec:
      containers:
        - image: influxdb:1.7.4-alpine
          name: influxdb
          env:
            - name: INFLUXDB_DB
              value: iot
            - name: INFLUXDB_ADMIN_USER
              valueFrom:
                secretKeyRef:
                  name: influxdb-grafana
                  key: influxdb-user
            - name: INFLUXDB_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: influxdb-grafana
                  key: influxdb-password
          ports:
            - containerPort: 8086
          volumeMounts:
            - name: influxdb-data
              mountPath: /var/lib/influxdb
      restartPolicy: Always
      volumes:
        - name: influxdb-data
          persistentVolumeClaim:
            claimName: influxdb-volumeclaim
