---
apiVersion: v1
kind: Service
metadata:
  name: initdatabase
  namespace: edoc2
  labels:
    app: initdatabase
spec:
  ports:
  - name: initdatabase
    port: 8785
    targetPort: 8785
    protocol: TCP
  selector:
    app: initdatabase
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: initdatabase
  namespace: edoc2
  labels:
    app: initdatabase
    k8s-app: initdatabase
spec:
  replicas: 1
  revisionHistoryLimit: 9
  selector:
    matchLabels:
      app: initdatabase
  template:
    metadata:
      labels:
        app: initdatabase
    spec:
      hostname: initdatabase
      terminationGracePeriodSeconds: 30
      containers:
      - name: initdatabase-container
        #image: registry.edoc2.com:5000/edoc2v5/initdatabase:20230111 
        #image: registry.edoc2.com:5000/edoc2v5/initdatabase:v6.3.0.0
        image: registry.edoc2.com:5000/edoc2v5/initdatabase:v6.3.0.0
        #image: registry.edoc2.com:5000/edoc2v5/initdatabase:v6.3.0.0
        imagePullPolicy: Always
        ports:
        - name: initdatabase
          containerPort: 8785
        securityContext:
          capabilities:
            add: ["SYS_PTRACE"]
        env:
        - name: DatabaseServerName
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: DatabaseServerName
        - name: SyncDatabaseServerName
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: SyncDatabaseServerName
        - name: RedisHostName
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: RedisHostName
        - name: RedisPassword
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: RedisPassword
        - name: MQEndPoint
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: MQEndPoint
        - name: ESURL
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: ESURL
        - name: ELASTICSEARCH_HOSTS
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: ELASTICSEARCH_HOSTS
        - name: CONTAINER_PLATFORM
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: CONTAINER_PLATFORM
        - name: S3_Url
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: S3_Url
        - name: S3_SecretKey
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: S3_SecretKey
        - name: S3_AccessKey
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: S3_AccessKey
        - name: S3_Bucket
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: S3_Bucket
        - name: S3_SignatureVersion
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: S3_SignatureVersion
        - name: STORAGEPLATFORM
          valueFrom:
            configMapKeyRef:
              name: envfile
              key: STORAGEPLATFORM
        #- name: DatabaseType
        #  value: 1
        #- name: DatabaseServerName
        #  value: sqlserver
        #- name: DatabaseServerPort
        #  value: 1433
        #- name: DatabaseUserName
        #  valueFrom:
        #    secretKeyRef:
        #      name: edoc2-secret
        #      key: DBUSER
        #- name: DatabasePassword 
        #  valueFrom:
        #    secretKeyRef:
        #      name: edoc2-secret
        #      key: DBPASSWD
      restartPolicy: Always
      nodeSelector:
        node.drive.nodelabels: InDrive
      #  nodetype: InDrive
