---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kraken-proxy
spec:
  replicas: {{ .Values.proxy.replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/name: kraken
      app.kubernetes.io/component: proxy
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: kraken
        app.kubernetes.io/component: proxy
        app.kubernetes.io/instance: {{ .Release.Name }}
      {{ with .Values.proxy.annotations -}}
      annotations:
{{ tpl . $ | indent 8 }}
      {{- end }}
    spec:
      {{ with .Values.proxy.initContainers -}}
      initContainers:
{{ toYaml . | indent 6 }}{{ end }}
      containers:
      - name: main
        image: {{ .Values.kraken.repository }}/kraken-proxy:{{ .Values.kraken.tag }}
        imagePullPolicy: {{ .Values.kraken.imagePullPolicy }}
        command:
        - /usr/bin/kraken-proxy
        - --config={{ .Values.proxy.config }}
        - --port=80
        volumeMounts:
        - name: config
          mountPath: /etc/config
{{ with .Values.proxy.extraVolumeMounts }}{{ toYaml . | indent 8 }}{{ end }}
      volumes:
      - name: config
        configMap:
          name: kraken
{{ with .Values.proxy.extraVolumes }}{{ toYaml . | indent 6 }}{{ end }}
---
kind: Service
apiVersion: v1
metadata:
  name: kraken-proxy
spec:
  selector:
    app.kubernetes.io/name: kraken
    app.kubernetes.io/component: proxy
    app.kubernetes.io/instance: {{ .Release.Name }}
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
