Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8408d06
Add natss provisioner: initial commit
Nov 14, 2018
050d484
Cleanup code, add more log messages
Nov 14, 2018
2259b1e
Remove unused code related to the configmap
Nov 15, 2018
2b156f9
Update vendor and gopkg.toml
Nov 16, 2018
d9ea8c4
Remove sample applicatoin
Nov 16, 2018
61efb16
Update Gopkg.lock
Nov 16, 2018
767d39e
Update VENDOR-LICENSE
Nov 16, 2018
634becd
Update vendor
Nov 16, 2018
7012ca8
Add README.md
Nov 19, 2018
d556456
Update based on running update-deps.sh
Nov 19, 2018
32433fb
Update based on running update-codegen.sh
Nov 19, 2018
330441f
Add the omited files generated by update-codegen.sh
Nov 19, 2018
806a843
Update README.md with NATSS configuration link
Nov 20, 2018
fd017f1
Add first unit tests for controller/channel
Nov 28, 2018
e41a19b
Update after rebase
Nov 28, 2018
da50050
Fix missed import in test
Nov 28, 2018
809615f
Solve some of requested changes
Nov 28, 2018
a38e62b
Unsubscribe NATSS subscriptions if the related channel is simply deleted
Nov 30, 2018
7df51d4
Update unit tests to not use finalizers
Nov 30, 2018
6d4428c
Run NATS Streaming in "natss" namespace instead of "knative-eventing"…
Dec 3, 2018
1ac2018
Add more unit tests
Dec 4, 2018
c9a70e2
Update after rebase
Dec 4, 2018
98807bf
Update based on running update-deps.sh
Dec 4, 2018
aff8faa
Add test "Update Subscriptions" for dispatcher
Dec 4, 2018
961082b
Update after running update-deps.sh
Dec 4, 2018
ad8b23c
Move NATS Streaming installation in a subdirectory.
Dec 4, 2018
6dc52bc
Add subscription's namespace to DispatchDefault at calling DispatchMe…
Dec 4, 2018
f188a52
Use channel's finalizer to cleanup NATSS subscriptions
Dec 5, 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
120 changes: 116 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,15 @@ required = [
name = "sigs.k8s.io/controller-runtime"
# HEAD as of 2018-09-19
revision = "5373e8e1f3188ff4266902a6fc86372bc14b3815"

[[override]]
name = "github.com/nats-io/go-nats"
version = "1.6.0"

[[override]]
name = "github.com/nats-io/go-nats-streaming"
version = "0.4.0"

[[override]]
name = "github.com/nats-io/nats-streaming-server"
version = "0.11.0"
44 changes: 44 additions & 0 deletions config/provisioners/natss/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# NATS Streaming Channels

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth providing a quick overview here of the benefits of NATS Streaming:

Approx throughput?
Durability / chance of data loss?
Resource requirements?
Ordering guarantees?


### Deployment steps:

1. Setup [Knative Eventing](../../../DEVELOPMENT.md).
1. If not done already, install a [NATS Streaming](natss)
1. Apply the 'natss' ClusterChannelProvisioner, Controller, and Dispatcher.
```shell
ko apply -f config/provisioners/natss/provisioner.yaml
````
1. Create Channels that reference the 'natss'.

```yaml
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
metadata:
name: foo
spec:
provisioner:
apiVersion: eventing.knative.dev/v1alpha1
kind: ClusterChannelProvisioner
name: natss
```

### Components

The major components are:
* NATS Streaming
* ClusterChannelProvisioner Controller
* Channel Controller
* Channel Dispatcher

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

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

12 changes: 12 additions & 0 deletions config/provisioners/natss/natss/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# NATS Streaming - simple installation

1. For an installation of a simple NATS Streaming server, a setup is provided:
```sbtshell
kubectl create namespace natss
kubectl label namespace natss istio-injection=enabled
kubectl apply -n natss -f config/provisioners/natss/natss/natss.yaml
```
NATS Streaming is deployed as a StatefulSet, using "nats-streaming" ConfigMap in the namespace "natss".

For tuning NATS Streaming, see:
https://github.com/nats-io/nats-streaming-server#configuring
101 changes: 101 additions & 0 deletions config/provisioners/natss/natss/natss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: nats-streaming
name: nats-streaming
namespace: natss
data:
gnatsd.conf: |
# configuration file used to override default NATS server settings
stan.conf: |
# content of configuration file used to override default NATS Streaming server settings
---
apiVersion: v1
kind: Service
metadata:
name: nats-streaming
namespace: natss
labels:
app: nats-streaming
spec:
type: ClusterIP
ports:
- name: client
port: 4222
protocol: TCP
targetPort: client
selector:
app: nats-streaming
sessionAffinity: None
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: nats-streaming
namespace: natss
labels:
app: nats-streaming
spec:
serviceName: nats-streaming
replicas: 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 1 replica have durability implications? Can this number be changed on the fly?

selector:
matchLabels:
app: nats-streaming
template:
metadata:
annotations:
sidecar.istio.io/inject: "true"
labels:
app: nats-streaming
spec:
containers:
- name: nats-streaming
image: nats-streaming:0.11.0
imagePullPolicy: IfNotPresent
args:
- -D
- -SD
- --cluster_id=knative-nats-streaming
- --http_port=8222
- --max_age=24h
- --store=FILE
- --dir=/var/lib/nats-streaming/core-nats-streaming/$(POD_NAME)
- --port=4222
- --config=/etc/nats-streaming/core-nats-streaming/gnatsd.conf
- --stan_config=/etc/nats-streaming/core-nats-streaming/stan.conf
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
ports:
- containerPort: 4222
name: client
protocol: TCP
- containerPort: 8222
name: monitoring
protocol: TCP
volumeMounts:
- mountPath: /var/lib/nats-streaming/core-nats-streaming
name: datadir
- mountPath: /etc/nats-streaming/core-nats-streaming
name: config-volume
resources:
requests:
cpu: "100m"
limits:
memory: "32M"
volumes:
- configMap:
name: nats-streaming
name: config-volume
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "1Gi"
Loading