# Copyright 2019 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: batch/v1
kind: Job
metadata:
  name: direct-perf-send-receive
  namespace: perf-eventing
  labels:
    role: direct-perf-consumer
spec:
  completions: 1
  parallelism: 1
  backoffLimit: 0
  template:
    metadata:
      labels:
        role: direct-perf-consumer
    spec:
      serviceAccountName: perf-eventing
      restartPolicy: Never
      containers:
        - name: sender-receiver
          image: knative.dev/eventing/test/test_images/performance
          args:
            - "--roles=sender,receiver"
            - "--sink=http://direct-perf-consumer.perf-eventing.svc.cluster.local"
            - "--aggregator=direct-perf-aggregator:10000"
            - "--pace=500:30,600:30,700:30,800:30,900:30,1000:30"
            - "--warmup=0"
          env:
            - name: GOGC
              value: "off"
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          resources:
            requests:
              cpu: 1000m
              memory: 6Gi
          ports:
            - name: cloudevents
              containerPort: 8080

---

apiVersion: v1
kind: Pod
metadata:
  name: direct-perf-aggregator
  namespace: perf-eventing
  labels:
    role: direct-perf-aggregator
spec:
  serviceAccountName: perf-eventing
  restartPolicy: Never
  containers:
    - name: aggregator
      image: knative.dev/eventing/test/test_images/performance
      args:
        - "--roles=aggregator"
        # set to the number of sender + receiver (same image that does both counts 2)
        - "--expect-records=2"
      ports:
        - name: grpc
          containerPort: 10000
      resources:
        requests:
          cpu: 1000m
          memory: 2Gi
      env:
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
      volumeMounts:
        - name: config-mako
          mountPath: /etc/config-mako
      terminationMessagePolicy: FallbackToLogsOnError
    - name: mako-stub
      image: knative.dev/pkg/test/mako/stub-sidecar
      args:
        - "-p=10001"
      ports:
        - name: quickstore
          containerPort: 9813
        - name: results
          containerPort: 10001
      volumeMounts:
        - name: config-mako
          mountPath: /etc/config-mako
      terminationMessagePolicy: FallbackToLogsOnError
  volumes:
    - name: config-mako
      configMap:
        name: config-mako