apiVersion: v1
kind: Service
metadata:
  name: nodered-influxdb
  namespace: nodered
  labels:
    app: nodered
spec:
  type: NodePort
  ports:
    - name: influxdb
      port: 8086
      nodePort: 30686
      targetPort: influxdb
  selector:
    app: nodered
    tier: influxdb
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: influxdb-pv-claim
  namespace: nodered
  labels:
    app: nodered
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 25Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodered-influxdb
  namespace: nodered
  labels:
    app: nodered
spec:
  selector:
    matchLabels:
      app: nodered
      tier: influxdb
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nodered
        tier: influxdb
    spec:
      containers:
      - image: influxdb:latest
        name: influxdb
        ports:
        - containerPort: 8086
          name: influxdb
        volumeMounts:
        - name: influxdb-persistent-storage
          mountPath: /var/lib/influxdb2
      imagePullSecrets:
      - name: reg-cred-secret    
      volumes:
      - name: influxdb-persistent-storage
        persistentVolumeClaim:
          claimName: influxdb-pv-claim
