apiVersion: v1
kind: Service
metadata:
  name: nodered
  namespace: enphase
  labels:
    app: enphase
spec:
  type: NodePort
  ports:
    - port: 1880
      nodePort: 30099
      targetPort: nodered
  selector:
    app: enphase
    tier: frontend
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nr-pv-claim
  namespace: enphase
  labels:
    app: enphase
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ""
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodered
  namespace: enphase
  labels:
    app: enphase
spec:
  selector:
    matchLabels:
      app: enphase
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: enphase
        tier: frontend
    spec:
      containers:
      - image: nodered/node-red:latest
        name: nodered
        ports:
        - containerPort: 1880
          name: nodered
        volumeMounts:
        - name: nodered-persistent-storage
          mountPath: /data
      imagePullSecrets:
      - name: reg-cred-secret
      volumes:
      - name: nodered-persistent-storage
        persistentVolumeClaim:
          claimName: nr-pv-claim
