apiVersion: apps/v1
kind: Deployment
metadata:
  name: coturn
  labels:
    app: coturn
spec:
  selector:
    matchLabels:
      app: coturn
  replicas: 1
  template:
    metadata:
      labels:
        app: coturn
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/path: "/metrics"
        prometheus.io/port: "9641"
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      imagePullSecrets:
        {{- toYaml .Values.imagePullSecrets | nindent 8 }}
      volumes:
        - name: coturn-config-volume
          configMap:
            name: coturn-config
      containers:
        - name: coturn
          image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          command: ["turnserver", "-c", "/etc/coturn/turnserver.conf"]
          env:
            - name: MY_POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
          ports:
            - containerPort: 3478
              name: coturn
          volumeMounts:
            - name: coturn-config-volume
              mountPath: /etc/coturn/turnserver.conf
              subPath: turnserver.conf
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
