apiVersion: v1
kind: Service
metadata:
  name: redis-tcp
  labels:
    run: redis
  annotations:
    metallb.universe.tf/allow-shared-ip: "redis"
spec:
  ports:
    - name: redis
      protocol: TCP
      port: 6379
      targetPort: 6379
  selector:
    run: redis
  type: LoadBalancer
  loadBalancerIP: 10.42.42.237
  externalTrafficPolicy: Local
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis
spec:
  capacity:
    storage: 5Mi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain # Keep 4eva
  storageClassName: default
  mountOptions:
    - hard
    - nfsvers=3
  nfs:
    path: /mnt/DroboFS/Shares/Kubernetes/volumes/static/redis
    server: 10.42.42.10
  claimRef:
    name: redis
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redis
  annotations:
    nfs.io/storage-path: "redis"
spec:
  storageClassName: default
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Mi
status: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      run: redis
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        run: redis
    spec:
      terminationGracePeriodSeconds: 30
      containers:
        #        - image: arm64v8/redis # official, but no json
        - image: redisfab/rejson:master-arm64v8-bionic
          imagePullPolicy: "Always"
          name: redis
          env:
            - name: TZ
              value: US/Michigan
          ports:
            - containerPort: 6379
              protocol: TCP
          resources: {}
          volumeMounts:
            - mountPath: /data/
              name: redis
      restartPolicy: Always
      volumes:
        - name: redis
          persistentVolumeClaim:
            claimName: redis
status: {}
#---
## Hosting
#apiVersion: networking.k8s.io/v1
#kind: Ingress
#metadata:
#  name: redis-management
#  annotations:
#    #nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
#    #nginx.ingress.kubernetes.io/proxy-ssl-verify: "off"
#    cert-manager.io/cluster-issuer: "letsencrypt-stage"
#spec:
#  tls:
#  - hosts:
#    - redis.monkeybox.org
#    secretName: redis-tls
#  rules:
#  - host: redis.monkeybox.org
#    http:
#      paths:
#      - path: /
#        pathType: Prefix
#        backend:
#          service:
#            name: redis-tcp
#            port:
#              number: 6379
