# 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: eventing.knative.dev/v1alpha1
kind: Broker
metadata:
  name: imc
  namespace: default
spec:
  channelTemplateSpec:
    apiVersion: messaging.knative.dev/v1alpha1
    kind: InMemoryChannel

---

apiVersion: eventing.knative.dev/v1alpha1
kind: Trigger
metadata:
  name: broker-imc
  namespace: default
spec:
  broker: imc
  subscriber:
    ref:
      apiVersion: v1
      kind: Service
      name: broker-imc-receiver

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: eventing-broker-ingress
  namespace: default

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: eventing-broker-filter
  namespace: default

---

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

---

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: default
roleRef:
  kind: ClusterRole
  name: perf-eventing
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: eventing-broker-ingress
  namespace: default
subjects:
  - kind: ServiceAccount
    name: eventing-broker-ingress
    namespace: default
roleRef:
  kind: ClusterRole
  name: eventing-broker-ingress
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: eventing-broker-filter
  namespace: default
subjects:
  - kind: ServiceAccount
    name: eventing-broker-filter
    namespace: default
roleRef:
  kind: ClusterRole
  name: eventing-broker-filter
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: configs.internal.knative.dev/v1alpha1
kind: ConfigMapPropagation
metadata:
  name: eventing
  namespace: default
spec:
  originalNamespace: knative-eventing
  selector:
    matchlabels:
      knative.dev/config-category: eventing

---

apiVersion: v1
kind: Service
metadata:
  name: broker-imc-receiver
spec:
  selector:
    role: broker-imc-receiver
  ports:
  - name: http
    port: 80
    targetPort: cloudevents
    protocol: TCP

---

apiVersion: v1
kind: Service
metadata:
  name: broker-imc-aggregator
spec:
  selector:
    role: broker-imc-aggregator
  ports:
  - name: grpc
    port: 10000
    targetPort: grpc
    protocol: TCP
