Skip to content

addon: Schema registry and REST proxy #45

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 23 commits into from
Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3a12d2e
Adds schema registry
solsson Jul 25, 2017
c14d4cc
Avoids the schema-registry service name, becuase it interferes ...
solsson Jul 25, 2017
55f5b31
This is http so there's no reason to not use port 80
solsson Jul 25, 2017
dfc65f1
Adds kafka-rest proxy as rest:80
solsson Jul 25, 2017
d340d41
Tests rest-proxy, but hangs on GET /consumers/.../records
solsson Jul 27, 2017
8b1ddad
Adds more tests, and retries
solsson Jul 27, 2017
4fc6880
Starts a test case for rest-proxy
solsson Jul 29, 2017
713743e
We should probably wait for CP 3.3.0 because ...
solsson Jul 29, 2017
f587622
Sample config from v3.3.0 source
solsson Jul 31, 2017
2d4401b
Remove file appender as docker implies stdout
solsson Jul 31, 2017
4791068
New image uses config files instead of env
solsson Aug 1, 2017
86183d8
Runtime conf is logged at start, which documents host.name in case we…
solsson Aug 1, 2017
eb1a102
Once again be explicit (=unsurprising) about log config path
solsson Aug 1, 2017
f29e6eb
Logs, unlike docs, revealed that kafka-rest needs ...
solsson Aug 1, 2017
ac5c75a
Tests commands succeed now. Remains to add asserts.
solsson Aug 1, 2017
7b4cfb4
Merge pull request #54 from Yolean/addon-rest-new-build
solsson Aug 1, 2017
caf56c7
Looks like Schema Registry works with empty bootstrap servers
solsson Aug 1, 2017
ff69832
Demonstrates that rest+schemas work together
solsson Aug 1, 2017
edeca3d
Moves to an addon folder, kubectl apply -f addon-cp/
solsson Aug 7, 2017
4ee79a4
Stay online at update, even with only one replica
solsson Aug 7, 2017
2f946b2
Adds readiness probes
solsson Aug 7, 2017
c20adc0
Adds liveness probes identical to readiness
solsson Aug 7, 2017
3b6a11e
Confluent platform built from same java image as kafka:0.11.0.1
solsson Oct 3, 2017
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
68 changes: 68 additions & 0 deletions addon-cp/confluent-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
kind: ConfigMap
metadata:
name: confluent-config
namespace: kafka
apiVersion: v1
data:
schema-registry.properties: |-
# Copyright 2014 Confluent Inc.
#
# 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.

listeners=http://0.0.0.0:80
#kafkastore.bootstrap.servers
kafkastore.connection.url=zookeeper:2181
kafkastore.topic=_schemas
debug=false

kafka-rest.properties: |-
##
# Copyright 2015 Confluent Inc.
#
# 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.
##

#id=kafka-rest-test-server
listeners=http://0.0.0.0:80
bootstrap.servers=kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092,kafka-2.broker.kafka.svc.cluster.local:9092
zookeeper.connect=zookeeper:2181
schema.registry.url=http://schemas.kafka.svc.cluster.local:80
#
# Configure interceptor classes for sending consumer and producer metrics to Confluent Control Center
# Make sure that monitoring-interceptors-<version>.jar is on the Java class path
#consumer.interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringConsumerInterceptor
#producer.interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor

log4j.properties: |-
log4j.rootLogger=INFO, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n

log4j.logger.kafka=ERROR, stdout
log4j.logger.org.apache.zookeeper=ERROR, stdout
log4j.logger.org.apache.kafka=ERROR, stdout
log4j.logger.org.I0Itec.zkclient=ERROR, stdout
log4j.additivity.kafka.server=false
log4j.additivity.kafka.consumer.ZookeeperConsumerConnector=false
10 changes: 10 additions & 0 deletions addon-cp/rest-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: rest
namespace: kafka
spec:
ports:
- port: 80
selector:
app: kafka-rest
43 changes: 43 additions & 0 deletions addon-cp/rest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: rest
namespace: kafka
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
template:
metadata:
labels:
app: kafka-rest
spec:
containers:
- name: cp
image: solsson/kafka-cp@sha256:89e5b3b326bf8ef888efa9501cd22fb941ca7b5ccef8dfc2f44a1e218f4427e1
env:
- name: KAFKAREST_LOG4J_OPTS
value: -Dlog4j.configuration=file:/etc/kafka-rest/log4j.properties
command:
- kafka-rest-start
- /etc/kafka-rest/kafka-rest.properties
readinessProbe:
httpGet:
path: /
port: 80
livenessProbe:
httpGet:
path: /
port: 80
ports:
- containerPort: 80
volumeMounts:
- name: config
mountPath: /etc/kafka-rest
volumes:
- name: config
configMap:
name: confluent-config
10 changes: 10 additions & 0 deletions addon-cp/schemas-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: schemas
namespace: kafka
spec:
ports:
- port: 80
selector:
app: schema-registry
43 changes: 43 additions & 0 deletions addon-cp/schemas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: schemas
namespace: kafka
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
template:
metadata:
labels:
app: schema-registry
spec:
containers:
- name: cp
image: solsson/kafka-cp@sha256:89e5b3b326bf8ef888efa9501cd22fb941ca7b5ccef8dfc2f44a1e218f4427e1
env:
- name: SCHEMA_REGISTRY_LOG4J_OPTS
value: -Dlog4j.configuration=file:/etc/schema-registry/log4j.properties
command:
- schema-registry-start
- /etc/schema-registry/schema-registry.properties
readinessProbe:
httpGet:
path: /
port: 80
livenessProbe:
httpGet:
path: /
port: 80
ports:
- containerPort: 80
volumeMounts:
- name: config
mountPath: /etc/schema-registry
volumes:
- name: config
configMap:
name: confluent-config
42 changes: 42 additions & 0 deletions test/70rest-test1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: batch/v1
kind: Job
metadata:
name: rest-test1
namespace: kafka
spec:
template:
metadata:
name: rest-test1
spec:
containers:
- name: curl
image: solsson/curl@sha256:8b0927b81d10043e70f3e05e33e36fb9b3b0cbfcbccdb9f04fd53f67a270b874
env:
- name: REST
value: http://rest.kafka.svc.cluster.local
- name: TOPIC
value: test1
command:
- /bin/sh
- -c
- >
curl --retry 10 --retry-delay 30 --retry-connrefused -I $REST;

curl -H 'Accept: application/vnd.kafka.v2+json' $REST/topics;

curl --retry 10 -H 'Accept: application/vnd.kafka.v2+json' $REST/topics/test1;
curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" -H "Accept: application/vnd.kafka.v2+json" --data "{\"records\":[{\"value\":\"Test from $HOSTNAME at $(date)\"}]}" $REST/topics/$TOPIC -v;
curl --retry 10 -H 'Accept: application/vnd.kafka.v2+json' $REST/topics/test2;

curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" -H "Accept: application/vnd.kafka.v2+json" --data '{"records":[{"value":{"foo":"bar"}}]}' $REST/topics/$TOPIC -v;

curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data '{"name": "my_consumer_instance", "format": "json", "auto.offset.reset": "earliest"}' $REST/consumers/my_json_consumer -v;

curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data "{\"topics\":[\"$TOPIC\"]}" $REST/consumers/my_json_consumer/instances/my_consumer_instance/subscription -v;

curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" $REST/consumers/my_json_consumer/instances/my_consumer_instance/records -v;

curl -X DELETE -H "Content-Type: application/vnd.kafka.v2+json" $REST/consumers/my_json_consumer/instances/my_consumer_instance -v;

sleep 300
restartPolicy: Never
Loading