apiVersion: apps/v1
kind: Deployment
metadata:
  name: coordinator-{{ include "graphscope.fullname" . }}
  namespace: {{ .Release.Namespace }}
spec:
  replicas: 1
  selector:
    matchLabels: {{- include "graphscope.coordinator.labels" . | nindent 6 }}
  template:
    metadata:
      labels: {{- include "graphscope.coordinator.labels" . | nindent 8 }}
      annotations:
        kubectl.kubernetes.io/default-container: coordinator
    spec:
      {{- include "graphscope.imagePullSecrets" . | indent 6 }}
      containers:
      - name: coordinator
        image: {{ include "graphscope.images.image" (dict "imageRoot" .Values.image "DefaultTag" .Chart.AppVersion "Component" .Values.coordinator) }}
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        resources: {{- toYaml .Values.coordinator.resources | nindent 10 }}
        env:
          - name: PYTHONUNBUFFERED
            value: "TRUE"
          {{- range $key, $value := .Values.coordinator.extraEnv }}
          - name: {{ $key | quote }}
            value: {{ $value | quote }}
          {{- end }}
        ports:
          - containerPort: 59001
            name: coordinator
        {{- if .Values.coordinator.readinessProbe.enabled }}
        readinessProbe:
          initialDelaySeconds: {{ .Values.coordinator.readinessProbe.initialDelaySeconds }}
          periodSeconds: {{ .Values.coordinator.readinessProbe.periodSeconds }}
          timeoutSeconds: {{ .Values.coordinator.readinessProbe.timeoutSeconds }}
          successThreshold: {{ .Values.coordinator.readinessProbe.successThreshold }}
          failureThreshold: {{ .Values.coordinator.readinessProbe.failureThreshold }}
          tcpSocket:
            port: 59001
        {{- end }}
        args:
          - /home/graphscope/start.sh
        volumeMounts:
          - name: config
            mountPath: /home/graphscope/config.yaml
            subPath: coordinator.config
          - name: config
            mountPath: /home/graphscope/start.sh
            subPath: start.sh
      {{- if .Values.withJupyter }}
      - name: jupyter
        image:  {{ include "graphscope.images.image" (dict "imageRoot" .Values.image "DefaultTag" .Chart.AppVersion "Component" .Values.jupyter) }}
        imagePullPolicy: {{ .Values.imagePullPolicy }}
        resources: {{- toYaml .Values.jupyter.resources | nindent 10 }}
        ports:
          - containerPort: 8888
            name: jupyter
      {{- end }}
      volumes:
        - name: config
          configMap:
            name: coordinator-{{ include "graphscope.fullname" . }}
            defaultMode: 0755
