# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.enableGcsProxy }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gcs-proxy
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "splice-util-lib.default-labels" (set . "app" "gcs-proxy") | nindent 4 }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gcs-proxy
  strategy:
    type: "Recreate"
  template:
    metadata:
      labels:
        {{- include "splice-util-lib.default-labels" (set . "app" "gcs-proxy") | nindent 8 }}
    spec:
      {{- include "splice-util-lib.service-account" .Values | nindent 6 }}
      containers:
        - name: gcs-proxy
          image: "{{ .Values.imageRepo }}/gcs-proxy:{{ .Chart.AppVersion }}{{ ((.Values.imageDigests).gcs_proxy) }}"
          {{- with .Values.imagePullPolicy }}
          imagePullPolicy: {{ . }}
          {{- end }}
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          resources:
            limits:
              cpu: 1
              memory: "512Mi"
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
---
apiVersion: v1
kind: Service
metadata:
  name: gcs-proxy
  namespace: {{ .Release.Namespace }}
spec:
  selector:
    app: gcs-proxy
  ports:
    - name: http
      port: 8080
      protocol: TCP

{{- end }}
