apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: vaultwarden-pvc
  namespace: nextgen
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  storageClassName: local-path
---
apiVersion: v1
kind: Service
metadata:
  name: vaultwarden
  namespace: nextgen
spec:
  selector:
    app: vaultwarden
  ports:
    - port: 80
      targetPort: 80
  type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: vaultwarden
  namespace: nextgen
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/proxy-body-size: "100m"
spec:
  tls:
    - hosts:
        - password.techarvest.co.zw
      secretName: password-techarvest-tls
  rules:
    - host: password.techarvest.co.zw
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: vaultwarden
                port:
                  number: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vaultwarden
  namespace: nextgen
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: vaultwarden
  template:
    metadata:
      labels:
        app: vaultwarden
    spec:
      containers:
        - name: vaultwarden
          image: vaultwarden/server:latest
          env:
            - name: SIGNUPS_ALLOWED
              value: "true"
            - name: DOMAIN
              value: "https://password.techarvest.co.zw"
            - name: DATABASE_URL
              value: "data/vaultwarden.db"
          ports:
            - containerPort: 80
          volumeMounts:
            - name: vaultwarden-data
              mountPath: /data
      volumes:
        - name: vaultwarden-data
          persistentVolumeClaim:
            claimName: vaultwarden-pvc
