apiVersion: apps/v1
kind: Deployment
metadata:
  name: loadgen
spec:
  replicas: {{ .Values.Replicas | default 1 }}
  selector:
    matchLabels:
      app.kubernetes.io/name: loadgen
  template:
    metadata:
      labels:
        app.kubernetes.io/name: loadgen
    spec:
      volumes:
        # Optionally mount gcp-credentials for non-cloud producers.
        - name: gcp-credentials
          secret:
            secretName: gcp-dev-credentials
            optional: true
      containers:
        - image: loadgen
          name: loadgen
          resources:
            limits:
              cpu: 1000m
              memory: 1000Mi
            requests:
              cpu: 200m
              memory: 200Mi
          volumeMounts:
            - name: gcp-credentials
              mountPath: /secrets/key.json
              subPath: key.json
              readOnly: true
          env:
            - name: REPLAY
              value: "{{.Values.replay_count | default "10000" }}"
            - name: PRODUCER_COUNT
              value: "{{.Values.producer_count | default "2" }}"
            - name: PRODUCER_KEY
              value: "{{.Values.producer_key}}"
            - name: PRODUCER_VALUE_FORMAT
              value: "{{.Values.producer_value_format}}"
            - name: OUTPUT_TYPE
              value: "{{ $.Values.output_type | default "kafka" }}"
            - name: TOPIC_PREFIX
              value: "{{.Values.topic_prefix}}"
            - name: OUTPUT_ADDRESS
              value: "{{(.Values.kafka).brokers}}"
            - name: GCLOUD_PROJECT_ID
              value: "{{(.Values.gcp).project_id}}"
            - name: GCLOUD_REGION
              value: "{{(.Values.gcp).region}}"
            - name: GOOGLE_APPLICATION_CREDENTIALS
              value: /secrets/key.json
