apiVersion: apps/v1
kind: Deployment
metadata:
  name: vaultwarden
  namespace: default
  labels:
    app: vaultwarden_app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: vaultwarden_app
  template:
    metadata:
      labels:
        app: vaultwarden_app
    spec:
      containers:
        - name: vaultwarden
          image: vaultwarden/server:latest
          env:
            - name: ADMIN_TOKEN
              valueFrom:
                secretKeyRef:
                  name: vaultwarden-admin
                  key: admin-token
            - name: WEBSOCKET_ENABLED
              value: "true"
          ports:
            - containerPort: 80
          volumeMounts:
          - mountPath: /data
            name: data
          resources:
            limits:
              cpu: 100m
              memory: 128Mi
            requests:
              cpu: 50m
              memory: 64Mi
          livenessProbe:
            httpGet:
              path: /index.html
              port: 80
              scheme: HTTP
            initialDelaySeconds: 60
            timeoutSeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 6
      volumes:
        - hostPath:
            path: /media/kube/vaultwarden
            type: ""
          name: data

---

apiVersion: v1
kind: Secret
metadata:
  name: vaultwarden-admin
  namespace: default
  labels:
    app.kubernetes.io/name: vaultwarden
    app.kubernetes.io/instance: vaultwarden
type: Opaque
stringData:
  admin-token: txYvuZyDLH8kAGHDuakujlIKPsDOnfd5WMvLaRN79qhFgv5cwswXq8fgwIIVLiHa

---

apiVersion: v1
kind: Service
metadata:
  name: vaultwarden
  namespace: default
spec:
  type: NodePort
  selector:
    app: vaultwarden_app
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30007
