apiVersion: apps/v1
kind: Deployment 
metadata:
  name: orthanc
  labels:
    app: orth
spec:
  replicas: 3 
  selector:
    matchLabels:
      app: orth
  template:
    metadata:
      labels:
        app: orth 
    spec:
      volumes:
      - name: cmvol
        configMap:
          name: orthanc-app
          defaultMode: 0755
      containers:
      - name: orthanc
        image: orthanc-plugins
        args: ["/run/secrets/"]
        ports:
          - containerPort: 8042
        #  - containerPort: 4242
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "128Mi" 
            cpu: "500m"
        env:
          - name: DB_PASSWORD
            valueFrom:
              secretKeyRef:
                name: postgres-ha-postgresql-ha-postgresql 
                key: postgresql-password
          - name: DB_USERNAME
            valueFrom:
              configMapKeyRef:
                name: orthanc-app 
                key: db.user 
          - name: DB_ADDR
            valueFrom:
              configMapKeyRef:
                name: orthanc-app
                key: db.addr
          - name: DB_PORT
            valueFrom:
              configMapKeyRef:
                name: orthanc-app
                key: db.port
        volumeMounts:
        - name: cmvol 
          mountPath: "/run/secrets/orthanc.json"
          subPath: "orthanc.json"
          readOnly: true
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /app/explorer.html
            port: 8042
            scheme: HTTP
            httpHeaders:
              - name: Authorization
                value: Basic b3J0aGFuYzpvcnRoYW5j
          initialDelaySeconds: 10
          periodSeconds: 20
          successThreshold: 1
          timeoutSeconds: 2
