apiVersion: apps/v1
kind: Deployment
metadata:
  name: foundry-vtt
  namespace: frost-wind-terror
  labels:
    app.kubernetes.io/name: foundry-vtt
spec:
  strategy:
    type: Recreate
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: foundry-vtt
  template:
    metadata:
      labels:
        app.kubernetes.io/name: foundry-vtt
      annotations:
        vault.hashicorp.com/agent-inject: "true"
        vault.hashicorp.com/role: "frost-wind-terror-foundry"
        vault.hashicorp.com/agent-inject-secret-config.json: "foundry/data/frost-wind-terror/config"
        vault.hashicorp.com/agent-inject-template-config.json: |
          {{- with secret "foundry/data/frost-wind-terror/config" -}}
          {
            "foundry_admin_key": "{{ .Data.data.FOUNDRY_ADMIN_KEY }}",
            "foundry_license_key": "{{ .Data.data.FOUNDRY_LICENSE_KEY }}",
            "foundry_password": "{{ .Data.data.FOUNDRY_PASSWORD }}",
            "foundry_username": "{{ .Data.data.FOUNDRY_USERNAME }}"
          }
          {{- end -}}
        vault.hashicorp.com/secret-volume-path-config.json: /run/secrets/
        vault.hashicorp.com/agent-inject-file-config.json: config.json

        vault.hashicorp.com/agent-inject-secret-awsConfig.json: "foundry/data/frost-wind-terror/config"
        vault.hashicorp.com/agent-inject-template-awsConfig.json: |
          {{- with secret "foundry/data/frost-wind-terror/config" -}}
          {
            "accessKeyId":"{{ .Data.data.AWS_ACCESS_KEY_ID }}",
            "secretAccessKey":"{{ .Data.data.AWS_SECRET_ACCESS_KEY }}",
            "region":"sfo2",
            "endpoint":"sfo2.digitaloceanspaces.com"
          }
          {{- end -}}
        vault.hashicorp.com/secret-volume-path-awsConfig.json: /run/secrets/
        vault.hashicorp.com/agent-inject-file-awsConfig.json: awsConfig.json
    spec:
      serviceAccountName: foundry-vtt
      containers:
      - name: foundry-vtt
        image: felddy/foundryvtt:0.7.9
        ports:
          - name: http
            containerPort: 30000
            protocol: TCP
        livenessProbe:
          httpGet:
            path: /
            port: http
        readinessProbe:
          httpGet:
            path: /
            port: http
        resources:
          limits:
            cpu: 1024m
            memory: 1024Mi
          requests:
            cpu: 512m
            memory: 512Mi
        volumeMounts:
        - name: data
          mountPath: /data
        env:
        - name: "FOUNDRY_AWS_CONFIG"
          value: "/run/secrets/awsConfig.json"
        - name: "FOUNDRY_MINIFY_STATIC_FILES"
          value: "true"
        - name: "FOUNDRY_PROXY_PORT"
          value: "443"
        - name: "FOUNDRY_PROXY_SSL"
          value: "true"
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: foundry-vtt
