apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: unleash
  name: unleash
spec:
  selector:
    matchLabels:
      app: unleash
  template:
    metadata:
      labels:
        app: unleash
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 50
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                    - unleash
              topologyKey: kubernetes.io/hostname
      containers:
        - name: unleash
          image: unleash
          imagePullPolicy: Always
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsUser: 512
          ports:
          - containerPort: 4242
          env:
            - name: ZING_PRODUCT_NAME
              valueFrom:
                configMapKeyRef:
                  name: project-common
                  key: PRODUCT_NAME
            - name: ZING_PRODUCT_VERSION
              valueFrom:
                configMapKeyRef:
                  name: project-common
                  key: PRODUCT_VERSION
            - name: ZING_PRODUCT_COMPANY_NAME
              valueFrom:
                configMapKeyRef:
                  name: project-common
                  key: COMPANY_NAME
            - name: ZING_PRODUCT_OTHER_COMMENTS
              valueFrom:
                configMapKeyRef:
                  name: project-common
                  key: PROJECT_ID
            - name: UNLEASH_GCLOUD_PROJECT_ID
              valueFrom:
                configMapKeyRef:
                  name: project-common
                  key: PROJECT_ID
            - name: UNLEASH_LOG_LEVEL
              value: "debug"
            - name: UNLEASH_TRACING_SAMPLERATE
              value: "0.01"
            - name: UNLEASH_PROFILING_ENABLED
              value: "0"
            - name: GOOGLE_APPLICATION_CREDENTIALS
              value: "/run/credentials/unleash.json"
            # Kubernetes location information.
            - name: K8S_CLUSTER
              valueFrom:
                configMapKeyRef:
                  name: project-common
                  key: K8S_CLUSTER
            - name: K8S_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: K8S_POD
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
          resources:
            requests:
              cpu: 100m
              memory: 128M
            limits:
              cpu: 1000m
              memory: 1000M
          volumeMounts:
          - name: cred-secrets
            mountPath: /run/credentials
            readOnly: true
      volumes:
        - name: cred-secrets
          secret:
            secretName: unleash
