# (C) Copyright IBM Corp. 2021.

# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: appconfig-bluecharge
  namespace: appconfig
spec:
  revisionHistoryLimit: 10
  minReadySeconds: 60
  progressDeadlineSeconds: 900
  selector:
    matchLabels:
      app: bluecharge
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  replicas: 1
  template:
    metadata:
      labels:
        app: bluecharge
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - bluecharge
              topologyKey: kubernetes.io/hostname
      containers:
        - name: appconfig-bluecharge
          image: us.icr.io/<namespace>/appconfig-bluecharge:<tag>
          ports:
            - containerPort: 3000
          env:
            - name: MONGO_USER
              valueFrom:
                secretKeyRef:
                  name: my-app-secrets
                  key: MONGO_ROOT_USERNAME
            - name: MONGO_PWD
              valueFrom:
                secretKeyRef:
                  name: my-app-secrets
                  key: MONGO_ROOT_PASSWORD
            - name: REGION
              valueFrom:
                configMapKeyRef:
                  name: my-app-configmap
                  key: REGION
            - name: GUID
              valueFrom:
                configMapKeyRef:
                  name: my-app-configmap
                  key: GUID
            - name: APIKEY
              valueFrom:
                secretKeyRef:
                  name: my-app-secrets
                  key: APIKEY
            - name: COLLECTION_ID
              valueFrom:
                configMapKeyRef:
                  name: my-app-configmap
                  key: COLLECTION_ID
      imagePullSecrets:
        - name: all-icr-io
