# Copyright 2021 The SODA Authors.
#
# 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:
  namespace: soda-multi-cloud
  labels:
    io.soda.service: s3
    app: soda-s3
  name: s3
spec:
  replicas: 2
  selector:
    matchLabels:
      io.soda.service: s3
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        io.soda.service: s3
        app: soda-s3
    spec:
      affinity:
         podAntiAffinity:
           requiredDuringSchedulingIgnoredDuringExecution:
           - labelSelector:
               matchExpressions:
               - key: "app"
                 operator: In
                 values:
                 - soda-s3
             topologyKey: "kubernetes.io/hostname"      
      containers:
        - env:
            - name: DB_HOST
              value: tidb:4000
            - name:  MICRO_REGISTRY
              value:  kubernetes
            - name: MICRO_SERVER_ADDRESS
              value: 0.0.0.0:9090
            - name: MICRO_BROKER_ADDRESS
              value: 0.0.0.0:9091
            - name: MICRO_ENVIRONMENT
              value: k8s              
            - name: USE_DEFAULT_STORAGE_CLASS
              value: "1"
          image: sodafoundation/multi-cloud-s3:latest
          name: s3
          ports:
            - containerPort: 8096
          resources: {}
          volumeMounts:
            - mountPath: /var/log/multi-cloud
              name: s3-logs
            - mountPath: /etc/yig
              name: s3-yig-datastore
            - mountPath: /etc/ceph
              name: s3-ceph-cfg
            - mountPath: /etc/config/multi-cloud
              name: multicloud-cfg-volume
            - mountPath: /etc/config/tidb
              name: tidb-cfg-volume
            - mountPath: /etc/config/yig
              name: yig-sql-volume
            - mountPath: /etc/multi-cloud
              name: s3-cfg-volume
      restartPolicy: Always
      volumes:
        - hostPath:
            path: /var/log/multi-cloud
            type: DirectoryOrCreate
          name: s3-logs
        - hostPath:
            path: /root/multi-cloud/s3/pkg/datastore/yig/conf
            type: DirectoryOrCreate
          name: s3-yig-datastore
        - hostPath:
            path: /etc/ceph
            type: DirectoryOrCreate
          name: s3-ceph-cfg
        - name: multicloud-cfg-volume
          configMap:
            name: multicloud-config
        - name: tidb-cfg-volume
          configMap:      
            name: tidb-sql
        - name: yig-sql-volume
          configMap:
            name: yig-sql
        - name: s3-cfg-volume
          configMap:
            name: s3-config

