-
Notifications
You must be signed in to change notification settings - Fork 630
Kafka Bus Implementation #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a1987cb
Introduce bus backed by Kafka
ericbottard d77f223
Address review comments
ericbottard f66a0c6
Anticipate ClusterBus
ericbottard 9f9d823
Less invasive update-deps
ericbottard b766d26
Rebase on latest master
ericbottard ab326e2
Update old copyright headers
ericbottard 2f1dfcb
Remove unreachable code
ericbottard 812d056
Adapt to latest bus changes
ericbottard 93709f7
Rebase against latest master
ericbottard acd949e
Use separate directory for kafka bus. Add README.
ericbottard 4e7c4fb
Address review comments
ericbottard 81b1ec0
Add embryo of error handling while dispatching
ericbottard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| bazel-* | ||
| *~ | ||
| .idea/ | ||
| .idea/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Kafka - Knative Bus | ||
|
|
||
| Deployment steps: | ||
| 1. Setup [Knative Eventing](../../../DEVELOPMENT.md) | ||
| 1. Install a Kafka broker. A simple setup is provided: | ||
| ``` | ||
| kubectl create namespace kafka | ||
| kubectl apply -n kafka -f config/buses/kafka/kafka-broker.yaml | ||
| ``` | ||
| 1. For cluster wide deployment, change the kind in `config/buses/kafka/kafka-bus.yaml` from `Bus` to `ClusterBus`. | ||
| 1. Apply the Kafka Bus: | ||
| ``` | ||
| ko apply -f config/buses/kafka/kafka-bus.yaml | ||
| ``` | ||
| 1. Create Channels that reference the 'kafka' Bus | ||
| 1. (Optional) Install [Kail](https://github.com/boz/kail) - Kubernetes tail | ||
|
|
||
| The bus has an independent provisioner and dispatcher. | ||
|
|
||
| The provisioner will create Kafka topics for each Knative Channel | ||
| targeting the Bus (named `<namespace>.<channel-name>`. | ||
| Clients should avoid interacting with topics provisioned by the bus. | ||
|
|
||
| The dispatcher | ||
| - receives events via a Channel's Service from inside the cluster and | ||
| writes them to the corresponding Kafka topic | ||
| - creates a Kafka consumer for each `Subscription`, that reads events | ||
| from the subscription's channel and forwards them over HTTP to the | ||
| subscriber. | ||
|
|
||
| To view logs: | ||
| - for the dispatcher `kail -d kafka-bus -c dispatcher` | ||
| - for the provisioner `kail -d kafka-bus-provisioner -c provisioner` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| ########################################## KAFKA BROKER ###################################### | ||
| # The following does not need to live in the same namespace as the bus. | ||
| --- | ||
| apiVersion: extensions/v1beta1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: kafka-broker | ||
| spec: | ||
| replicas: 1 | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: kafka-broker | ||
| spec: | ||
| containers: | ||
| - name: kafka-broker | ||
| image: wurstmeister/kafka:1.1.0 | ||
| ports: | ||
| - containerPort: 9092 | ||
| env: | ||
| - name: MY_POD_NAMESPACE | ||
| valueFrom: | ||
| fieldRef: | ||
| fieldPath: metadata.namespace | ||
| - name: KAFKA_BROKER_ID | ||
| value: "0" | ||
| - name: KAFKA_LISTENERS | ||
| value: "INTERNAL://:9093,EXTERNAL://:9092" | ||
| - name: KAFKA_ADVERTISED_LISTENERS | ||
| value: "INTERNAL://:9093,EXTERNAL://kafkabroker.$(MY_POD_NAMESPACE):9092" | ||
| - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP | ||
| value: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT" | ||
| - name: KAFKA_INTER_BROKER_LISTENER_NAME | ||
| value: "INTERNAL" | ||
| - name: KAFKA_ZOOKEEPER_CONNECT | ||
| value: "zookeeper.$(MY_POD_NAMESPACE):2181" | ||
| - name: KAFKA_AUTO_CREATE_TOPICS_ENABLE | ||
| value: "false" | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: kafkabroker | ||
| spec: | ||
| type: NodePort | ||
| selector: | ||
| app: kafka-broker | ||
| ports: | ||
| - port: 9092 | ||
| name: kafka | ||
| protocol: TCP | ||
| nodePort: 31349 | ||
|
|
||
| --- | ||
| apiVersion: extensions/v1beta1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: zookeeper | ||
| spec: | ||
| replicas: 1 | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: zookeeper | ||
| spec: | ||
| containers: | ||
| - name: zookeeper | ||
| image: wurstmeister/zookeeper:3.4.6 | ||
| ports: | ||
| - containerPort: 2181 | ||
| env: | ||
| - name: ZOOKEEPER_ID | ||
| value: "1" | ||
| - name: ZOOKEEPER_SERVER_1 | ||
| value: zookeeper | ||
|
|
||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: zookeeper | ||
| spec: | ||
| selector: | ||
| app: zookeeper | ||
| ports: | ||
| - port: 2181 | ||
| name: zookeeper | ||
| protocol: TCP | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| apiVersion: channels.knative.dev/v1alpha1 | ||
| kind: Bus | ||
| metadata: | ||
| name: kafka | ||
| spec: | ||
| parameters: | ||
| subscription: | ||
| - name: "initialOffset" | ||
| description: "The initial offset to use when subscribing, either Oldest or Newest. Defaults to Newest." | ||
| default: "Newest" | ||
| provisioner: | ||
| name: provisioner | ||
| image: github.com/knative/eventing/pkg/buses/kafka/provisioner | ||
| args: [ | ||
| "-logtostderr", | ||
| "-stderrthreshold", "INFO", | ||
| ] | ||
| env: | ||
| - name: KAFKA_BROKERS | ||
| value: "kafkabroker.kafka:9092" | ||
| dispatcher: | ||
| name: dispatcher | ||
| image: github.com/knative/eventing/pkg/buses/kafka/dispatcher | ||
| args: [ | ||
| "-logtostderr", | ||
| "-stderrthreshold", "INFO", | ||
| ] | ||
| env: | ||
| - name: KAFKA_BROKERS | ||
| value: "kafkabroker.kafka:9092" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a pointer on how to install kail? Since it's used throughout the examples, wonder if this should be made part of the DEVELOPMENT.md (as optional?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the same snippet that was just merged in other READMEs