Skip to content

Commit

Permalink
add config for namespace-scoped in-mem channel (#2555)
Browse files Browse the repository at this point in the history
* add config for namespace-scoped in-mem channel

* fix link

* add warning about having only one in-mem controller installed

* code review changes

* fix build

* add cleanup instruction
  • Loading branch information
lionelvillard authored Feb 14, 2020
1 parent 72cee55 commit 2f88069
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# 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: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: imc-controller
labels:
eventing.knative.dev/release: devel
rules:
- apiGroups:
- messaging.knative.dev
resources:
- inmemorychannels
- inmemorychannels/status
verbs:
- get
- list
- watch
- update
- apiGroups:
- messaging.knative.dev
resources:
- inmemorychannels/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- services
- serviceaccounts
verbs: &everything
- get
- list
- watch
- create
- update
- patch
- apiGroups:
- ""
resources:
- endpoints
verbs:
- get
- list
- watch
- apiGroups:
- "rbac.authorization.k8s.io"
resources:
- rolebindings
verbs: *everything
- apiGroups:
- apps
resources:
- deployments
verbs: *everything
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
59 changes: 59 additions & 0 deletions config/channels/in-memory-channel-ns/500-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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: apps/v1
kind: Deployment
metadata:
name: imc-controller
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
spec:
replicas: 1
selector:
matchLabels: &labels
messaging.knative.dev/channel: in-memory-channel
messaging.knative.dev/role: controller
template:
metadata:
labels: *labels
spec:
serviceAccountName: imc-controller
containers:
- name: controller
image: knative.dev/eventing/cmd/in_memory/channel_controller

env:
- name: CONFIG_LOGGING_NAME
value: config-logging
- name: CONFIG_OBSERVABILITY_NAME
value: config-observability
- name: METRICS_DOMAIN
value: knative.dev/inmemorychannel-controller
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: DISPATCHER_SCOPE
value: namespace
- name: DISPATCHER_IMAGE
value: knative.dev/eventing/cmd/in_memory/channel_dispatcher
securityContext:
allowPrivilegeEscalation: false

ports:
- name: metrics
containerPort: 9090
- name: profiling
containerPort: 8008
60 changes: 60 additions & 0 deletions config/channels/in-memory-channel-ns/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Namespace-Scoped In-Memory Channels

Namespace-scoped in-memory channels share the same characteristics as the
[in-memory channels](../in-memory-channel/README.md). The only difference is the in-memory
dispatcher is installed in the same namespace as the channel.

### Deployment steps:

1. Setup [Knative Eventing](../../../DEVELOPMENT.md).
1. Apply the `InMemoryChannel` CRD and controller.
```shell
ko apply -f config/channels/in-memory-channel-ns
```
1. Create InMemoryChannels

```sh
kubectl apply --filename - << END
apiVersion: messaging.knative.dev/v1alpha1
kind: InMemoryChannel
metadata:
name: foo
END
```
IMPORTANT: make sure you don't have the [cluster-scoped in-memory channels](../in-memory-channel/README.md)
configuration deployed in your cluster. Pick one or the other, but not both at the same time!
### Components
The major components are:
- InMemoryChannel Controller
- InMemoryChannel Dispatcher
```shell
kubectl get deployment -n knative-eventing imc-controller
```
The InMemoryChannel Dispatcher receives and distributes all events. There is
one Dispatcher per namespace.
```shell
kubectl get deployment -n default imc-dispatcher
```
### Cleanup
To remove the in-memory channel component, do:
```shell
kubectl delete -f config/channels/in-memory-channel-ns
```
To remove the InMemoryChannel Dispatcher deployments, do:
```shell
kubectl delete deployments imc-dispatcher
```
in all namespaces you installed channels.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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: v1
kind: ServiceAccount
metadata:
name: imc-dispatcher
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
9 changes: 0 additions & 9 deletions config/channels/in-memory-channel/200-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,3 @@ metadata:
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel

---
apiVersion: v1
kind: ServiceAccount
metadata:
name: imc-dispatcher
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
18 changes: 0 additions & 18 deletions config/channels/in-memory-channel/201-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,3 @@ roleRef:
kind: ClusterRole
name: imc-controller
apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: imc-dispatcher
labels:
eventing.knative.dev/release: devel
subjects:
- kind: ServiceAccount
name: imc-dispatcher
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: imc-dispatcher
apiGroup: rbac.authorization.k8s.io

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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: imc-dispatcher
labels:
eventing.knative.dev/release: devel
subjects:
- kind: ServiceAccount
name: imc-dispatcher
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: imc-dispatcher
apiGroup: rbac.authorization.k8s.io

4 changes: 3 additions & 1 deletion config/channels/in-memory-channel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ characterics:
```
1. Create InMemoryChannels

```yaml
```shell
kubectl apply --filename - << END
apiVersion: messaging.knative.dev/v1alpha1
kind: InMemoryChannel
metadata:
name: foo
END
```
### Components
Expand Down
1 change: 1 addition & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ COMPONENTS=(
["eventing-crds.yaml"]="config/core/resources"
["channel-broker.yaml"]="config/brokers/channel-broker"
["in-memory-channel.yaml"]="config/channels/in-memory-channel"
["in-memory-channel-namespace.yaml"]="config/channels/in-memory-channel-ns"
)
readonly COMPONENTS

Expand Down

0 comments on commit 2f88069

Please sign in to comment.