Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8df08c4
Start on the new Stub bus controller and provisioner.
Harwayne Sep 28, 2018
e2c2f1f
Start on unit tests.
Harwayne Sep 28, 2018
b632f71
Fulfill Sinkable and Subscribable.
Harwayne Sep 28, 2018
eb2c458
Merge updates from fanout.
Harwayne Oct 1, 2018
13a912b
Merge branch 'master' into split-stub
Harwayne Oct 1, 2018
e87adf0
Rename to in-memory bus.
Harwayne Oct 2, 2018
a9bb764
Add unit tests for the ClusterProvisioner Controller.
Harwayne Oct 2, 2018
10034f6
Add unit tests for the Channel reconciler.
Harwayne Oct 3, 2018
906e8f9
Rename in-memory-bus-provisioner to in-memory-channel, as requested i…
Harwayne Oct 3, 2018
437d2df
Add a README.md.
Harwayne Oct 3, 2018
8dbaeee
Typo.
Harwayne Oct 3, 2018
9c1654f
Use a service account with specific RBAC permissions.
Harwayne Oct 5, 2018
c1d3082
hack/update-deps.sh
Harwayne Oct 5, 2018
99bc3e4
Merge branch 'master' into split-stub
Harwayne Oct 5, 2018
9e014e9
isio -> istio
Harwayne Oct 5, 2018
4a8f264
Respond to PR comments.
Harwayne Oct 9, 2018
af00150
ConfigMap create ClusterRole cannot be bound by resourceName.
Harwayne Oct 10, 2018
1d73bba
Watch K8s Services and VirtualServices.
Harwayne Oct 10, 2018
fd0efd4
Merge branch 'master' into split-stub
Harwayne Oct 11, 2018
a3aaf5a
Re-add SerializeConfig (accidentally removed during last merge).
Harwayne Oct 11, 2018
0a75ae7
goimports
Harwayne Oct 11, 2018
e955a14
Collapse if conditions.
Harwayne Oct 11, 2018
c79aa43
Only reconcile Channels.
Harwayne Oct 11, 2018
73f94b9
Merge branch 'master' into split-stub
Harwayne Oct 11, 2018
d32d44d
Manipulate Status only via methods on the Status object.
Harwayne Oct 11, 2018
486a2ba
Don't rely on the default values for sidecar flags.
Harwayne Oct 11, 2018
b2438e1
Merge branch 'master' into split-stub
Harwayne Oct 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cmd/fanoutsidecar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ package main

import (
"context"
"errors"
"flag"
Comment thread
adamharwayne marked this conversation as resolved.
"fmt"
"log"
"net/http"
"strings"
"time"

"github.com/knative/eventing/pkg/sidecar/configmap/filesystem"
"github.com/knative/eventing/pkg/sidecar/configmap/watcher"
"github.com/knative/eventing/pkg/sidecar/swappable"
"github.com/knative/eventing/pkg/system"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"k8s.io/client-go/kubernetes"
"log"
"net/http"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
"strings"
"time"
)

const (
defaultConfigMapName = "in-memory-bus-config"
defaultConfigMapName = "in-memory-channel-dispatcher-config-map"

// The following are the only valid values of the config_map_noticer flag.
cmnfVolume = "volume"
Expand All @@ -60,12 +60,12 @@ var (

func init() {
flag.IntVar(&port, "sidecar_port", -1, "The port to run the sidecar on.")
flag.StringVar(&configMapNoticer, "config_map_noticer", "", fmt.Sprintf("The system to notice changes to the ConfigMap. Valid values are: %s", configMapNoticerFlags()))
flag.StringVar(&configMapNoticer, "config_map_noticer", "", fmt.Sprintf("The system to notice changes to the ConfigMap. Valid values are: %s", configMapNoticerValues()))
flag.StringVar(&configMapNamespace, "config_map_namespace", system.Namespace, "The namespace of the ConfigMap that is watched for configuration.")
flag.StringVar(&configMapName, "config_map_name", defaultConfigMapName, "The name of the ConfigMap that is watched for configuration.")
}

func configMapNoticerFlags() string {
func configMapNoticerValues() string {
return strings.Join([]string{cmnfVolume, cmnfWatcher}, ", ")
}

Expand Down Expand Up @@ -132,7 +132,7 @@ func setupConfigMapNoticer(logger *zap.Logger, configUpdated swappable.UpdateCon
case cmnfWatcher:
err = setupConfigMapWatcher(logger, mgr, configUpdated)
default:
err = errors.New("need to provide the --config_map_noticer flag")
err = fmt.Errorf("need to provide the --config_map_noticer flag (valid values are %s)", configMapNoticerValues())
}
if err != nil {
return nil, err
Expand Down
63 changes: 63 additions & 0 deletions config/provisioners/in-memory-channel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# In-Memory Channels

In-memory channels are a best effort Channel. They should **NOT** be used in Production. They are
useful for development.

They differ from most Channels in that they have:
* No persistence.
- If a Pod goes down, messages go with it.
* No ordering guarantee.
- There is nothing enforcing an ordering, so two messages that arrive at the same time may
go downstream in any order.
- Different downstream subscribers may see different orders.
* No redelivery attempts.
- If downstream rejects a request, a log message is written, but that request is never sent
again.


### Deployment steps:

1. Setup [Knative Eventing](../../../DEVELOPMENT.md).
1. Apply the 'in-memory-channel' ClusterProvisioner, Controller, and Dispatcher.
```shell
ko apply -f config/providers/in-memory-channel/in-memory-channel.yaml
````
1. Create Channels that reference the 'in-memory-channel'.

```yaml
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
metadata:
name: foo
spec:
provisioner:
ref:
apiVersion: eventing.knative.dev/v1alpha1
kind: ClusterProvisioner
name: in-memory-channel
```

### Components

The major components are:
* ClusterProvisioner Controller
* Channel Controller
* Channel Dispatcher
* Channel Dispatcher Config Map.

The ClusterProvisioner Controller and the Channel Controller are colocated in one Pod.
```shell
kubectl get deployment -n knative-eventing in-memory-channel-controller
```

The Channel Dispatcher receives and distributes all events. There is a single Dispatcher for all
in-memory Channels.
```shell
kubectl get deployment -n knative-eventing in-memory-channel-dispatcher
```

The Channel Dispatcher Config Map is used to send information about Channels and Subscriptions from
the Channel Controller to the Channel Dispatcher.
```shell
kubectl get configmap -n knative-eventing in-memory-channel-dispatcher-config-map
```
183 changes: 183 additions & 0 deletions config/provisioners/in-memory-channel/in-memory-channel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# 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: eventing.knative.dev/v1alpha1
kind: ClusterProvisioner
metadata:
name: in-memory-channel
spec:
reconciles:
group: eventing.knative.dev/v1alpha1
kind: Channel

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: in-memory-channel-controller
namespace: knative-eventing

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: in-memory-channel-controller
rules:
- apiGroups:
- eventing.knative.dev
resources:
- channels
- clusterprovisioners
verbs:
- get
- list
- watch
- update
- apiGroups:
- "" # Core API group.
resources:
- configmaps
- services
verbs:
- get
- list
- watch
- create
- apiGroups:
- "" # Core API Group.
resources:
- configmaps
resourceNames:
- in-memory-channel-dispatcher-config-map
verbs:
- update
- apiGroups:
- networking.istio.io
resources:
- virtualservices
verbs:
- get
- list
- watch
- create

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: in-memory-channel-controller
namespace: knative-eventing
subjects:
- kind: ServiceAccount
name: in-memory-channel-controller
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: in-memory-channel-controller
apiGroup: rbac.authorization.k8s.io

---

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: in-memory-channel-controller
namespace: knative-eventing
spec:
replicas: 1
selector:
matchLabels: &labels
clusterProvisioner: in-memory-channel
role: controller
template:
metadata:
labels: *labels
spec:
serviceAccountName: in-memory-channel-controller
containers:
- name: controller
image: github.com/knative/eventing/pkg/controller/eventing/inmemory/controller

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: in-memory-channel-dispatcher
namespace: knative-eventing

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: in-memory-channel-dispatcher
namespace: knative-eventing
rules:
- apiGroups:
- "" # Core API group.
resources:
- configmaps
verbs:
- get
- list
- watch

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: in-memory-channel-dispatcher
namespace: knative-eventing
subjects:
- kind: ServiceAccount
name: in-memory-channel-dispatcher
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: in-memory-channel-dispatcher
apiGroup: rbac.authorization.k8s.io

---

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: in-memory-channel-dispatcher
namespace: knative-eventing
spec:
replicas: 1
selector:
matchLabels: &labels
clusterProvisioner: in-memory-channel
role: dispatcher
template:
metadata:
annotations:
sidecar.istio.io/inject: "true"
labels: *labels
spec:
serviceAccountName: in-memory-channel-dispatcher
containers:
- name: dispatcher
image: github.com/knative/eventing/cmd/fanoutsidecar
args:
- --sidecar_port=8080
- --config_map_noticer=watcher
- --config_map_namespace=knative-eventing
- --config_map_name=in-memory-channel-dispatcher-config-map
Loading