apiVersion: apps/v1
kind: Deployment
metadata:
  name: goredirect
  namespace: hackerspace
spec:
  replicas: 2
  revisionHistoryLimit: 0
  selector:
    matchLabels:
      app.kubernetes.io/name: goredirect
  template:
    metadata:
      labels:
        app.kubernetes.io/name: goredirect
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                  - key: app.kubernetes.io/name
                    operator: In
                    values:
                    - goredirect
                topologyKey: topology.kubernetes.io/zone
              weight: 100
      containers:
        - image: harbor.k-space.ee/k-space/goredirect:latest
          imagePullPolicy: Always 
          env:
            - name: GOREDIRECT_NOT_FOUND
              value: https://inventory.k-space.ee/m/inventory/add-slug/%s
            - name: GOREDIRECT_FOUND
              value: https://inventory.k-space.ee/m/inventory/%s/view
            - name: MONGO_URI
              valueFrom:
                secretKeyRef:
                  key: MONGO_URI
                  name: inventory-mongodb
          name: goredirect
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          resources:
            limits:
              cpu: "1"
              memory: 500Mi
            requests:
              cpu: 100m
              memory: 200Mi
          securityContext:
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            runAsUser: 1000