---
# Source: partition/templates/service.yaml
#  Copyright © Microsoft Corporation
#
#  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: v1
kind: Service
metadata:
  name: partition
  namespace: osdu
spec:
  type: ClusterIP
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  selector:
    app: partition
---
# Source: partition/templates/deployment.yaml
#  Copyright © Microsoft Corporation
#
#  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: osdu-gitlab-partition
  namespace: osdu
spec:
  replicas: 1
  selector:
    matchLabels:
      app: partition
  template:
    metadata:
      labels:
        app: partition
        aadpodidbinding: osdu-identity
    spec:
      volumes:
      - name: azure-keyvault
        csi:
          driver: secrets-store.csi.k8s.io
          readOnly: true
          volumeAttributes:
            secretProviderClass: azure-keyvault
      containers:
      - name: partition
        image: community.opengroup.org:5555/osdu/platform/system/partition/partition-trusted-azure-pipeline:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 80
        readinessProbe:
          httpGet:
            path: /actuator/health
            port: 8081
        livenessProbe:
          httpGet:
            path: /actuator/health
            port: 8081
          initialDelaySeconds: 250
          periodSeconds: 10
        volumeMounts:
        - name: azure-keyvault
          mountPath: "/mnt/azure-keyvault"
          readOnly: true
        env:
        - name: spring_application_name
          value: partition
        - name: server.servlet.contextPath
          value: /api/partition/v1/
        - name: server_port
          value: "80"
        - name: ACCEPT_HTTP  # TEMPORARY UNTIL HTTPS
          value: "true"
        - name: KEYVAULT_URI
          valueFrom:
            configMapKeyRef:
              name: osdu-svc-properties
              key: ENV_KEYVAULT
        - name: AZURE_TENANT_ID
          valueFrom:
            secretKeyRef:
              name: active-directory
              key: tenantid
        - name: AZURE_CLIENT_ID
          valueFrom:
            secretKeyRef:
              name: active-directory
              key: principal-clientid
        - name: AZURE_CLIENT_SECRET
          valueFrom:
            secretKeyRef:
              name: active-directory
              key: principal-clientpassword
        - name: appinsights_key
          valueFrom:
            secretKeyRef:
              name: central-logging
              key: appinsights
        - name: aad_client_id
          valueFrom:
            secretKeyRef:
              name: active-directory
              key: application-appid
        - name: azure_activedirectory_AppIdUri
          value: "api://$(aad_client_id)"
        - name: azure_activedirectory_session_stateless
          value: "true"