# 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: v1
kind: Namespace
metadata:
  name: perf-eventing

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: config-mako
  namespace: perf-eventing
data:
  _example: |
    ################################
    #                              #
    #    EXAMPLE CONFIGURATION     #
    #                              #
    ################################

    # This block is not actually functional configuration,
    # but serves to illustrate the available configuration
    # options and document them in a way that is accessible
    # to users that `kubectl edit` this config map.
    #
    # These sample configuration options may be copied out of
    # this example block and unindented to be in the data block
    # to actually change the configuration.

    # The Mako environment in which we are running.
    # Only our performance automation should run in "prod", but
    # there should be a "dev" environment with a fairly broad
    # write ACL.  Users can also develop against custom configurations
    # by adding `foo.config` under their benchmark's kodata directory.
    environment: dev

    # Additional tags to tag the runs. These tags are added
    # to the list that the binary itself publishes (Kubernetes version, etc).
    # It is a comma separated list of tags.
    additionalTags: "key=value,absolute"
  dev.config: |
    ### Creating this benchmark:
    # mako create_benchmark test/performance/broker-latency/prod.config
    ### Updating this benchmark:
    # mako update_benchmark test/performance/broker-latency/prod.config

    project_name: "Knative"
    benchmark_name: "Broker Latency & Throughput"
    description: "Measure latency and throughput of the broker using various channels."
    benchmark_key: '5036156928393216'

    # Human owners for manual benchmark adjustments.
    owner_list: "grantrodgers@google.com"
    owner_list: "chizhg@google.com"

    # Only this robot should publish data to Mako for this key!
    owner_list: "mako-job@knative-eventing-performance.iam.gserviceaccount.com"

    # Define the name and type for x-axis of run charts
    input_value_info: {
      value_key: "t"
      label: "time"
      type: TIMESTAMP
    }

    # Note: value_key is stored repeatedly and should be very short (ideally one or two characters).
    metric_info_list: {
      value_key: "pl"
      label: "publish-latency"
    }
    metric_info_list: {
      value_key: "pe"
      label: "publish-errors"
    }
    metric_info_list: {
      value_key: "st"
      label: "send-throughput"
    }
    metric_info_list: {
      value_key: "dl"
      label: "deliver-latency"
    }
    metric_info_list: {
      value_key: "de"
      label: "deliver-errors"
    }
    metric_info_list: {
      value_key: "dt"
      label: "deliver-throughput"
    }
    metric_info_list: {
      value_key: "pet"
      label: "publish-failure-throughput"
    }
    metric_info_list: {
      value_key: "det"
      label: "deliver-failure-throughput"
    }

---

apiVersion: v1
kind: Service
metadata:
  name: direct-perf-consumer
  namespace: perf-eventing
spec:
  selector:
    role: direct-perf-consumer
  ports:
  - protocol: TCP
    port: 80
    targetPort: cloudevents
    name: http

---

apiVersion: v1
kind: Service
metadata:
  name: direct-perf-aggregator
  namespace: perf-eventing
spec:
  selector:
    role: direct-perf-aggregator
  ports:
    - name: grpc
      port: 10000
      targetPort: grpc
      protocol: TCP

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: perf-eventing
  namespace: perf-eventing

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: perf-eventing
rules:
  - apiGroups: [""]
    resources: ["nodes", "pods"]
    verbs: ["list"]

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: perf-eventing
subjects:
  - kind: ServiceAccount
    name: perf-eventing
    namespace: perf-eventing
roleRef:
  kind: ClusterRole
  name: perf-eventing
  apiGroup: rbac.authorization.k8s.io
