{{ if .Values.coder.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sync-coder-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sync-coder-deployment
  template:
    metadata:
      labels:
        app: sync-coder-deployment
    spec:
      serviceAccountName: coder
      containers:
        - name: sync-coder-deployment
          image: {{ .Values.coder.sync_coder.image }}:{{ .Values.coder.sync_coder.version }}
          imagePullPolicy: Always
          {{- if .Values.azure }}
          env:
            - name: CLOUD_PROVIDER
              value: azure
            - name: AZURE_VAULT_URL
              valueFrom:
                secretKeyRef:
                  name: azure-kv-creds
                  key: vault_url
            - name: AZURE_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: azure-kv-creds
                  key: client_id
            - name: AZURE_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: azure-kv-creds
                  key: client_secret
            - name: AZURE_TENANT_ID
              valueFrom:
                secretKeyRef:
                  name: azure-kv-creds
                  key: tenant_id
          {{- end }}
      imagePullSecrets:
        - name: regcred

---
apiVersion: v1
kind: Service
metadata:
  name: sync-coder-service
spec:
  type: ClusterIP
  selector:
    app: sync-coder-deployment
  ports:
    - name: http
      protocol: TCP
      port: 8082
      targetPort: 8082
{{ end }}