From ec859d053107dc909cfd57e234482e059ffc4789 Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Thu, 6 Feb 2020 16:36:05 -0800 Subject: [PATCH 1/3] Split the channel broker off from eventing core --- cmd/channel_broker/main.go | 39 ++++++++++ cmd/controller/main.go | 6 -- config/200-channel-broker-binding.yaml | 1 + config/200-channel-broker-clusterrole.yaml | 1 + config/300-configmappropagation.yaml | 2 +- config/500-broker-controller.yaml | 1 + .../200-channel-broker-binding.yaml | 28 +++++++ .../deployments/controller.yaml | 75 +++++++++++++++++++ .../resources/configmappropagation.yaml | 0 .../roles/controller-clusterroles.yaml | 35 +++++++++ config/core/deployments/controller.yaml | 11 --- .../core/roles/controller-clusterroles.yaml | 8 -- hack/release.sh | 5 +- 13 files changed, 184 insertions(+), 28 deletions(-) create mode 100644 cmd/channel_broker/main.go create mode 120000 config/200-channel-broker-binding.yaml create mode 120000 config/200-channel-broker-clusterrole.yaml create mode 120000 config/500-broker-controller.yaml create mode 100644 config/brokers/channel-broker/200-channel-broker-binding.yaml create mode 100644 config/brokers/channel-broker/deployments/controller.yaml rename config/{core => brokers/channel-broker}/resources/configmappropagation.yaml (100%) create mode 100644 config/brokers/channel-broker/roles/controller-clusterroles.yaml diff --git a/cmd/channel_broker/main.go b/cmd/channel_broker/main.go new file mode 100644 index 00000000000..20fc501d01b --- /dev/null +++ b/cmd/channel_broker/main.go @@ -0,0 +1,39 @@ +/* +Copyright 2020 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. +*/ + +package main + +import ( + // Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters). + // _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + + "knative.dev/pkg/injection/sharedmain" + + "knative.dev/eventing/pkg/reconciler/broker" + "knative.dev/eventing/pkg/reconciler/configmappropagation" + "knative.dev/eventing/pkg/reconciler/trigger" +) + +func main() { + sharedmain.Main("controller", + // Eventing + broker.NewController, + trigger.NewController, + + // Utility for sole-tenancy brokers. + configmappropagation.NewController, + ) +} diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 118e65f211c..ff1c9ac64b0 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -23,9 +23,7 @@ import ( "knative.dev/pkg/injection/sharedmain" "knative.dev/eventing/pkg/reconciler/apiserversource" - "knative.dev/eventing/pkg/reconciler/broker" "knative.dev/eventing/pkg/reconciler/channel" - "knative.dev/eventing/pkg/reconciler/configmappropagation" "knative.dev/eventing/pkg/reconciler/eventtype" "knative.dev/eventing/pkg/reconciler/legacyapiserversource" "knative.dev/eventing/pkg/reconciler/legacycontainersource" @@ -35,7 +33,6 @@ import ( "knative.dev/eventing/pkg/reconciler/pingsource" "knative.dev/eventing/pkg/reconciler/sequence" "knative.dev/eventing/pkg/reconciler/subscription" - "knative.dev/eventing/pkg/reconciler/trigger" ) func main() { @@ -46,13 +43,10 @@ func main() { // Eventing subscription.NewController, - trigger.NewController, - broker.NewController, eventtype.NewController, // Flows parallel.NewController, - configmappropagation.NewController, sequence.NewController, // Sources diff --git a/config/200-channel-broker-binding.yaml b/config/200-channel-broker-binding.yaml new file mode 120000 index 00000000000..ac54ef03348 --- /dev/null +++ b/config/200-channel-broker-binding.yaml @@ -0,0 +1 @@ +brokers/channel-broker/200-channel-broker-binding.yaml \ No newline at end of file diff --git a/config/200-channel-broker-clusterrole.yaml b/config/200-channel-broker-clusterrole.yaml new file mode 120000 index 00000000000..b0aec1ce713 --- /dev/null +++ b/config/200-channel-broker-clusterrole.yaml @@ -0,0 +1 @@ +brokers/channel-broker/roles/controller-clusterroles.yaml \ No newline at end of file diff --git a/config/300-configmappropagation.yaml b/config/300-configmappropagation.yaml index cba754c58ea..98fc7ef3e1f 120000 --- a/config/300-configmappropagation.yaml +++ b/config/300-configmappropagation.yaml @@ -1 +1 @@ -core/resources/configmappropagation.yaml \ No newline at end of file +brokers/channel-broker/resources/configmappropagation.yaml \ No newline at end of file diff --git a/config/500-broker-controller.yaml b/config/500-broker-controller.yaml new file mode 120000 index 00000000000..c716eef7dd7 --- /dev/null +++ b/config/500-broker-controller.yaml @@ -0,0 +1 @@ +brokers/channel-broker/deployments/controller.yaml \ No newline at end of file diff --git a/config/brokers/channel-broker/200-channel-broker-binding.yaml b/config/brokers/channel-broker/200-channel-broker-binding.yaml new file mode 100644 index 00000000000..8a61bd64fd3 --- /dev/null +++ b/config/brokers/channel-broker/200-channel-broker-binding.yaml @@ -0,0 +1,28 @@ +# Copyright 2020 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: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: eventing-channel-broker-controller + labels: + eventing.knative.dev/release: devel +subjects: + - kind: ServiceAccount + name: eventing-controller + namespace: knative-eventing +roleRef: + kind: ClusterRole + name: knative-eventing-channel-broker-controller + apiGroup: rbac.authorization.k8s.io diff --git a/config/brokers/channel-broker/deployments/controller.yaml b/config/brokers/channel-broker/deployments/controller.yaml new file mode 100644 index 00000000000..08aa0be0e64 --- /dev/null +++ b/config/brokers/channel-broker/deployments/controller.yaml @@ -0,0 +1,75 @@ +# Copyright 2018 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: apps/v1 +kind: Deployment +metadata: + name: broker-controller + namespace: knative-eventing + labels: + eventing.knative.dev/release: devel +spec: + replicas: 1 + selector: + matchLabels: + app: broker-controller + template: + metadata: + labels: + app: broker-controller + eventing.knative.dev/release: devel + spec: + serviceAccountName: eventing-controller + + containers: + - name: eventing-controller + terminationMessagePolicy: FallbackToLogsOnError + image: knative.dev/eventing/cmd/channel_broker + + resources: + requests: + cpu: 100m + memory: 100Mi + + env: + - name: SYSTEM_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: CONFIG_LOGGING_NAME + value: config-logging + - name: CONFIG_OBSERVABILITY_NAME + value: config-observability + - name: METRICS_DOMAIN + value: knative.dev/eventing + # Broker + - name: BROKER_INGRESS_IMAGE + value: knative.dev/eventing/cmd/broker/ingress + - name: BROKER_INGRESS_SERVICE_ACCOUNT + value: eventing-broker-ingress + - name: BROKER_FILTER_IMAGE + value: knative.dev/eventing/cmd/broker/filter + - name: BROKER_FILTER_SERVICE_ACCOUNT + value: eventing-broker-filter + - name: BROKER_IMAGE_PULL_SECRET_NAME + value: + + securityContext: + allowPrivilegeEscalation: false + + ports: + - name: metrics + containerPort: 9090 + - name: profiling + containerPort: 8008 diff --git a/config/core/resources/configmappropagation.yaml b/config/brokers/channel-broker/resources/configmappropagation.yaml similarity index 100% rename from config/core/resources/configmappropagation.yaml rename to config/brokers/channel-broker/resources/configmappropagation.yaml diff --git a/config/brokers/channel-broker/roles/controller-clusterroles.yaml b/config/brokers/channel-broker/roles/controller-clusterroles.yaml new file mode 100644 index 00000000000..e0fad77d9f5 --- /dev/null +++ b/config/brokers/channel-broker/roles/controller-clusterroles.yaml @@ -0,0 +1,35 @@ +# Copyright 2020 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: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: knative-eventing-channel-broker-controller + labels: + eventing.knative.dev/release: devel +rules: + # Configs resources and status we care about. + - apiGroups: + - "configs.internal.knative.dev" + resources: + - "configmappropagations" + - "configmappropagations/status" + verbs: + - "get" + - "list" + - "create" + - "update" + - "delete" + - "patch" + - "watch" diff --git a/config/core/deployments/controller.yaml b/config/core/deployments/controller.yaml index ac3c0727e42..ca09e97b9e7 100644 --- a/config/core/deployments/controller.yaml +++ b/config/core/deployments/controller.yaml @@ -53,17 +53,6 @@ spec: value: config-observability - name: METRICS_DOMAIN value: knative.dev/eventing - # Broker - - name: BROKER_INGRESS_IMAGE - value: knative.dev/eventing/cmd/broker/ingress - - name: BROKER_INGRESS_SERVICE_ACCOUNT - value: eventing-broker-ingress - - name: BROKER_FILTER_IMAGE - value: knative.dev/eventing/cmd/broker/filter - - name: BROKER_FILTER_SERVICE_ACCOUNT - value: eventing-broker-filter - - name: BROKER_IMAGE_PULL_SECRET_NAME - value: # Legacy CronJobSource - name: CRONJOB_RA_IMAGE value: knative.dev/eventing/cmd/cronjob_receive_adapter diff --git a/config/core/roles/controller-clusterroles.yaml b/config/core/roles/controller-clusterroles.yaml index a8b3436bbcd..eb97da57e94 100644 --- a/config/core/roles/controller-clusterroles.yaml +++ b/config/core/roles/controller-clusterroles.yaml @@ -96,14 +96,6 @@ rules: - "parallels/status" verbs: *everything - # Configs resources and status we care about. - - apiGroups: - - "configs.internal.knative.dev" - resources: - - "configmappropagations" - - "configmappropagations/status" - verbs: *everything - # Messaging resources and finalizers we care about. - apiGroups: - "messaging.knative.dev" diff --git a/hack/release.sh b/hack/release.sh index 19e5c93784a..e5d181f9a6b 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -22,8 +22,9 @@ source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/release.sh # Yaml files to generate, and the source config dir for them. declare -A COMPONENTS COMPONENTS=( - ["eventing-core.yaml"]="config" + ["eventing-core.yaml"]="config/core" ["eventing-crds.yaml"]="config/core/resources" + ["channel-broker.yaml"]="config/brokers/channel-broker" ["in-memory-channel.yaml"]="config/channels/in-memory-channel" ) readonly COMPONENTS @@ -49,7 +50,7 @@ function build_release() { for yaml in "${!COMPONENTS[@]}"; do local config="${COMPONENTS[${yaml}]}" echo "Building Knative Eventing - ${config}" - ko resolve ${KO_FLAGS} -f ${config}/ | "${LABEL_YAML_CMD[@]}" > ${yaml} + ko resolve ${KO_FLAGS} -R -f ${config}/ | "${LABEL_YAML_CMD[@]}" > ${yaml} all_yamls+=(${yaml}) done # Assemble the release From 0bf2efe05ecced21eca59e44e021a76e9a3d2ffd Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Thu, 6 Feb 2020 17:10:08 -0800 Subject: [PATCH 2/3] Add the channel-broker to the eventing.yaml bundle --- hack/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/release.sh b/hack/release.sh index e5d181f9a6b..7cc5dd99b92 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -31,7 +31,7 @@ readonly COMPONENTS declare -A RELEASES RELEASES=( - ["eventing.yaml"]="eventing-core.yaml in-memory-channel.yaml" + ["eventing.yaml"]="eventing-core.yaml channel-broker.yaml in-memory-channel.yaml" ) readonly RELEASES From 6bf9d22cdaf81d07297e2a35a49a1eb41437eb1d Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Thu, 6 Feb 2020 17:14:56 -0800 Subject: [PATCH 3/3] Move namespace reconciler, add kodata --- cmd/channel_broker/kodata/HEAD | 1 + cmd/channel_broker/kodata/LICENSE | 1 + cmd/channel_broker/kodata/VENDOR-LICENSE | 1 + cmd/channel_broker/kodata/refs | 1 + cmd/channel_broker/main.go | 2 ++ cmd/controller/main.go | 2 -- 6 files changed, 6 insertions(+), 2 deletions(-) create mode 120000 cmd/channel_broker/kodata/HEAD create mode 120000 cmd/channel_broker/kodata/LICENSE create mode 120000 cmd/channel_broker/kodata/VENDOR-LICENSE create mode 120000 cmd/channel_broker/kodata/refs diff --git a/cmd/channel_broker/kodata/HEAD b/cmd/channel_broker/kodata/HEAD new file mode 120000 index 00000000000..8f63681d362 --- /dev/null +++ b/cmd/channel_broker/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/cmd/channel_broker/kodata/LICENSE b/cmd/channel_broker/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/cmd/channel_broker/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/cmd/channel_broker/kodata/VENDOR-LICENSE b/cmd/channel_broker/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..3cc89764519 --- /dev/null +++ b/cmd/channel_broker/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/cmd/channel_broker/kodata/refs b/cmd/channel_broker/kodata/refs new file mode 120000 index 00000000000..5c9979c2618 --- /dev/null +++ b/cmd/channel_broker/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs/ \ No newline at end of file diff --git a/cmd/channel_broker/main.go b/cmd/channel_broker/main.go index 20fc501d01b..4015e125e99 100644 --- a/cmd/channel_broker/main.go +++ b/cmd/channel_broker/main.go @@ -24,12 +24,14 @@ import ( "knative.dev/eventing/pkg/reconciler/broker" "knative.dev/eventing/pkg/reconciler/configmappropagation" + "knative.dev/eventing/pkg/reconciler/namespace" "knative.dev/eventing/pkg/reconciler/trigger" ) func main() { sharedmain.Main("controller", // Eventing + namespace.NewController, broker.NewController, trigger.NewController, diff --git a/cmd/controller/main.go b/cmd/controller/main.go index ff1c9ac64b0..80cc40ae32c 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -28,7 +28,6 @@ import ( "knative.dev/eventing/pkg/reconciler/legacyapiserversource" "knative.dev/eventing/pkg/reconciler/legacycontainersource" "knative.dev/eventing/pkg/reconciler/legacycronjobsource" - "knative.dev/eventing/pkg/reconciler/namespace" "knative.dev/eventing/pkg/reconciler/parallel" "knative.dev/eventing/pkg/reconciler/pingsource" "knative.dev/eventing/pkg/reconciler/sequence" @@ -38,7 +37,6 @@ import ( func main() { sharedmain.Main("controller", // Messaging - namespace.NewController, channel.NewController, // Eventing