apiVersion: batch/v1
kind: Job
metadata:
  name: spill-av
  namespace: tbd
spec:
  ttlSecondsAfterFinished: 300
  backoffLimit: 1
  template:
    spec:
      containers:
        - name: spill-av
          image: "docker.pkg.github.com/navikt/helse-spill-av/spill-av:{{version}}"
          resources:
            requests:
              memory: 256Mi
              cpu: 100m
            limits:
              memory: 1024Mi
              cpu: 1000m
          volumeMounts:
            - mountPath: /var/run/secrets/nais.io/vault
              name: vault-secrets
              subPath: subpath/var/run/secrets/nais.io/vault
            - mountPath: /var/run/secrets/nais.io/kafka
              name: kafka-credentials
              readOnly: true
          args:
            - dryRun=true
            - starttidspunkt=2021-03-24T10:55:00
          env:
            - name: VAULT_TOKEN_PATH
              value: /var/run/secrets/nais.io/vault/vault_token
            - name: KAFKA_TARGET_TOPIC
              value: tbd.rapid.v1
            - name: DATABASE_HOST
              value: a01dbfl039.adeo.no
            - name: DATABASE_PORT
              value: "5432"
            - name: DATABASE_NAME
              value: spedisjon
            - name: VAULT_MOUNTPATH
              value: postgresql/prod-fss/
            - name: KAFKA_BROKERS
              valueFrom:
                secretKeyRef:
                  key: KAFKA_BROKERS
                  name: kafka-spill-av-nav-prod-25f9c13a
            - name: KAFKA_CREDSTORE_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: KAFKA_CREDSTORE_PASSWORD
                  name: kafka-spill-av-nav-prod-25f9c13a
            - name: KAFKA_KEYSTORE_PATH
              value: /var/run/secrets/nais.io/kafka/client.keystore.p12
            - name: KAFKA_TRUSTSTORE_PATH
              value: /var/run/secrets/nais.io/kafka/client.truststore.jks
      imagePullSecrets:
        - name: gpr-credentials
      initContainers:
        - name: vks-init
          image: navikt/vault-sidekick:v0.3.10-d122b16
          resources:
            requests:
              memory: "64Mi"
              cpu: "100m"
            limits:
              memory: "128Mi"
              cpu: "1000m"
          volumeMounts:
            - mountPath: /var/run/secrets/nais.io/vault
              name: vault-secrets
              subPath: subpath/var/run/secrets/nais.io/vault
          args:
            - -v=10
            - -logtostderr
            - -vault=https://vault.adeo.no
            - -one-shot
            - -save-token=/var/run/secrets/nais.io/vault/vault_token
          env:
            - name: VAULT_AUTH_METHOD
              value: kubernetes
            - name: VAULT_SIDEKICK_ROLE
              value: spill-av
            - name: VAULT_K8S_LOGIN_PATH
              value: auth/kubernetes/prod/fss/login
      serviceAccount: podcreator
      serviceAccountName: podcreator
      volumes:
        - name: vault-secrets
          emptyDir:
            medium: Memory
        - name: kafka-credentials
          secret:
            defaultMode: 420
            items:
              - key: KAFKA_CERTIFICATE
                path: kafka.crt
              - key: KAFKA_PRIVATE_KEY
                path: kafka.key
              - key: KAFKA_CA
                path: ca.crt
              - key: client.keystore.p12
                path: client.keystore.p12
              - key: client.truststore.jks
                path: client.truststore.jks
            secretName: kafka-spenn-avstemming-nav-prod-2195ff19
      restartPolicy: Never
