Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
4c3b5ce
mvn io.quarkus:quarkus-maven-plugin:0.12.0:create
solsson Mar 23, 2019
b234dba
Self-contained docker build based on
solsson Mar 23, 2019
e42877c
Updates the build for quarkus+maven
solsson Mar 23, 2019
0c176da
Adds kafka libs including native support (no snappy or JMX)
solsson Mar 23, 2019
fe11fa5
Fixes a package name typo
solsson Mar 23, 2019
5754dce
Not enough OOD, maybe
solsson Mar 24, 2019
7fc57d7
Passes, no onupdate yet
solsson Mar 24, 2019
23aa795
Finds an issue with how the group is used, we reset something
solsson Mar 25, 2019
e4b11e0
Verifies our current raw onupdate, if topic1 starts empty
solsson Mar 25, 2019
ef9d060
Adapts gitignore to maven use
solsson Mar 25, 2019
8867017
Bumps the kafka lib to 2.2.0,
solsson Mar 27, 2019
9884614
Formatting
solsson Apr 12, 2019
01c046b
indentation still messed up
solsson Apr 12, 2019
bd3946d
Removes the old app framework
solsson Apr 13, 2019
085abce
Evaluated redhat-developer/vscode-java
solsson Apr 13, 2019
8ea2c76
Latest graalvm
solsson Apr 12, 2019
3f49c15
Latest quarkus, and testkafka cnsistent with client
solsson Apr 13, 2019
8f665c4
We alrady had JSON serialization declared on UpdateRecord
solsson Apr 13, 2019
5ab39a8
Found a cleaner kafka-junit lib, I think
solsson Apr 12, 2019
f935b19
Migrated the test to kafka-junit5
solsson Apr 13, 2019
cbdd345
Resteasy http client with quarkus, anyone?
solsson Apr 13, 2019
1ed0a35
Eclipse warned that this version is "managed"
solsson Apr 15, 2019
27f0347
Removes JSON binding for UpdateRecord, to send batches instead
solsson Apr 15, 2019
a3a9afd
Rudimentary HTTP endpoints
solsson Apr 15, 2019
3d24ac5
Lazy initialization, i.e. on first dependent REST request
solsson Apr 15, 2019
3220d9b
Eager initialization
solsson Apr 15, 2019
5248566
... and we'll need Converters
solsson Apr 15, 2019
8249d06
Build would fail when a config source was throwing
solsson Apr 19, 2019
19b58f8
Current quarkus
solsson Apr 19, 2019
415832b
Adds support for Duration config, but builds seem to disagree
solsson Apr 19, 2019
3389c07
Gave up on registering a converter, UnsatisfiedResolutionException
solsson Apr 20, 2019
e80310c
Collection resulted in AmbiguousResolutionException but List didn't
solsson Apr 20, 2019
4793785
Evaluates use of Provider, but getting UnsatisfiedResolutionException…
solsson Apr 21, 2019
e6c8d61
Pretty useful: Provider is for config that can change. @Produces is p…
solsson Apr 21, 2019
11ad0c4
Config is successful up until kafka client start now
solsson Apr 21, 2019
ec1fc04
Monkey test with quarkus.io/guides/maven-tooling#development-mode
solsson Apr 21, 2019
76e3463
Removes an unused import
solsson Apr 21, 2019
a5595d6
Fixes running forever, the mode we can't integration test
solsson Apr 21, 2019
bb1b61a
Starts a single threaded consumer after Quarkus logs "started"
solsson Apr 21, 2019
5b07459
Redesigns OnUpdate for rigidity
solsson Apr 21, 2019
8825c27
REST @QuarkusTest fires up the entire application, which requires config
solsson Apr 22, 2019
3b2fdd5
Just to get a running application, with NOP update triggers
solsson Apr 22, 2019
94c2469
Dockerfile's archetype for libs caching must match pom's quarkus version
solsson Apr 22, 2019
c91c5ad
Still can't get named depdenencies to resolve reliably
solsson Apr 22, 2019
11ac7cf
Tests running in docker require slightly longer metadata timeout
solsson Apr 22, 2019
9be648b
Documents a test signal gotcha
solsson Apr 22, 2019
af072af
Updates build-contract to use env for config and
solsson Apr 22, 2019
43d30c0
Kafka can listen both on localhost and in docker-compose
solsson Apr 22, 2019
0782bbe
Guarantees a minimum pause between polls, but adapts to time taken fo…
solsson Apr 22, 2019
ee89d97
Removes the ConfigSource experiment as we'd probably want to
solsson Apr 22, 2019
1e2d304
Increases test metadata timeout further, to maybe fix docker hub build
solsson Apr 22, 2019
31551b0
Another attempt to fix Docker Hub builds by increasing the timeout
solsson Apr 22, 2019
455a15c
Upgrade to Quarkus 0.14.0
solsson Apr 26, 2019
6626391
Fixes a typo
solsson Apr 26, 2019
cb16d82
Quarkus 0.14.0 seems to cause parsing of a Duration value
solsson Apr 26, 2019
4f306c5
Fixes tabs->spaces
solsson Apr 26, 2019
37909dc
We'll need health so we can trigger termination
solsson Apr 26, 2019
64b0635
Health must be exposed through a top level CDI resource
solsson Apr 26, 2019
b67973d
Tries to use Health to produce meaningful test failures
solsson Apr 26, 2019
7384b4d
Frequently saw "failed to elect leader for partition" with 2 test bro…
solsson Apr 26, 2019
dc6b11f
Test coverage for two types of startup failures
solsson Apr 26, 2019
ff57cf7
Disables JUnit tests during docker build, to get solsson/kafka-keyval…
solsson Apr 27, 2019
0d3b6b5
A k8s test setup, towards (build-)kontrakt
solsson Apr 27, 2019
570c786
Must always remember to bump the offline build prep at Quarkus upgrade
solsson Apr 27, 2019
8f3d955
Builds a non-native image too
solsson Apr 27, 2019
e2e8ef7
How to build locally to kind's images
solsson Apr 27, 2019
68bcd22
Adopts the non-quarkus REST resource to the current impl
solsson Apr 27, 2019
6438fe1
We have introduced a generic sleep now
solsson Apr 27, 2019
a972b96
The partition assignment never happens in the k8s setup
solsson Apr 27, 2019
af0dfa3
Yolean/kubernetes-kafka#266 fixes the scale=1 issue
solsson Apr 27, 2019
95882f4
This wait seems to be necessary
solsson Apr 27, 2019
30f3d24
More health state ideas
solsson Apr 29, 2019
a915b19
Makes error handling less of a hack
solsson Apr 29, 2019
b157eb6
Adds explicit handling of missing group offset,
solsson Apr 29, 2019
e33b5b5
Would need to invoke the Thread in tests to assert on health
solsson Apr 29, 2019
0967c3e
Let's crashloop at topic non-existence, to avoid complex retry logic,
solsson Apr 29, 2019
d373254
WIP try to wait for subscriptions without more poll calls
solsson Apr 29, 2019
7fd913c
Still confused
solsson Apr 29, 2019
9a8b687
Manual partition assignment went a lot better
solsson Apr 29, 2019
a612484
Removes leftovers from topic existence retries
solsson Apr 29, 2019
d7bcf1d
Log levels based on master's log4j2.properties
solsson Apr 29, 2019
b3c46f7
Use >1 partitions for test topic, to keep that in scope
solsson May 24, 2019
48f36af
Quarkus 0.15
solsson May 24, 2019
7b01d23
Graalvm 1.0/19 isn't compatible yet
solsson May 24, 2019
a1b7720
Now works with `skaffold dev`'s live reload using the following yaml:
solsson May 24, 2019
d0740d9
Moves Health annotations out from actual resources to fix DI
solsson May 24, 2019
48c741e
Avoid filling up logs
solsson May 25, 2019
4bc93ee
Implements streaming JSON output for keys
solsson May 25, 2019
7307b84
We don't need any extra layer on top of httpclient
solsson May 25, 2019
0bf33db
Adds a URL helper to aid connection reuse
solsson May 25, 2019
96111d7
Adds a topic prop for clients that don't want topic name in URI
solsson May 25, 2019
2565d51
Maybe Gson next time, or jackson, or yasson, or whatever
solsson May 25, 2019
21d0ae4
Actually per poll per topic
solsson May 25, 2019
0c54e48
Some clients will want different handlers for different tokens
solsson May 25, 2019
73840d1
KKV is intended as sidecar so avoid port 8080 by default
solsson May 25, 2019
3a2f007
Draft replacement for OnUpdateConfig
solsson May 26, 2019
4a403b2
Reshuffle to try to simplify but aid http connection mgmt
solsson May 26, 2019
bf4ff17
More drafting
solsson May 26, 2019
1b93b5c
A test stack, currently for manual kafkacat+curl+tail
solsson May 26, 2019
17c2ac3
HTTP stuff
solsson May 26, 2019
98ea58a
Failed to pass host this way
solsson May 26, 2019
08222d6
Separates host and URI, to facilitate connection reuse
solsson May 26, 2019
d0ab39f
Sets helpful headers
solsson May 26, 2019
901db23
Use byte array to avoid encoding; let httpclient figure out coontent …
solsson May 26, 2019
4ffd0b5
Example usage. What's a good offsets endpoint?
solsson May 26, 2019
be1c8ee
This Kind setup transitioned to Yolean/kubernetes-kafka#267
solsson May 26, 2019
50c8a6d
All we need now is a Kontrakt readiness Tester for Skaffold :)
solsson May 26, 2019
11ef870
Merge branch 'httpcomponents' into quarkus-as-sidecar
solsson May 26, 2019
3684aa7
Individual envs lend themselves better to referencing, overriding etc
solsson May 27, 2019
ea68a78
Sampe principle for targets as for topics, same rationale
solsson May 27, 2019
379752c
Merge branch 'topic-envs' into quarkus-as-sidecar
solsson May 27, 2019
52f91d4
Use a statefulset to get consistent pod names (for exec) and demo upd…
solsson May 27, 2019
0803463
q
solsson May 27, 2019
b0450e6
Where to start
solsson May 27, 2019
b30a8fc
Merge branch 'example' into quarkus-as-sidecar
solsson May 27, 2019
9643bc8
Readiness is essential for not returning old results,
solsson May 27, 2019
07eca84
Can't log anything on every message
solsson May 27, 2019
5500450
Introduces proper readiness, i.e. consumed up to committed offset
solsson May 27, 2019
40fdae6
Better logging at update failure
solsson May 27, 2019
6e82f81
Restores support for multiple targets
solsson May 27, 2019
f981503
Clarifies the error when no topic has been configured
solsson May 27, 2019
eb16284
Forgot to add these
solsson May 27, 2019
29dbba7
Creates a Prometheus Operator target
solsson May 27, 2019
f8b1de8
Restores metrics code from gen 1, the streams based, impl
solsson May 27, 2019
d3d0cc9
Make the old prometheus code compile
solsson May 27, 2019
d01ca9c
But /metrics returns nothing
solsson May 27, 2019
5d0c6d1
Now exporting metrics, with a consumer.metrics() call on every scrape
solsson May 27, 2019
97ef170
When multiple tests run only one can set up metrics
solsson May 27, 2019
2c7a0d9
Removes an unused import
solsson May 27, 2019
21f1560
Merge branch 'metrics-restore' into quarkus-as-sidecar
solsson May 27, 2019
e911d07
Liveness may have caused frequent restarts, but I'm unsure
solsson May 27, 2019
3a6e844
Enables an endpoint with some failure rate
solsson May 27, 2019
f3134e2
During frequent restarts I had issues with the gauge alread registered
solsson May 27, 2019
2bd8e9c
Evaluate update request retries, disable ssl as workaround for native
solsson May 27, 2019
f354bf5
Apparently labels vary in some of kafka's metrics
solsson May 28, 2019
5f44d56
If we troubleshoot metric registration it helps to keep it final
solsson May 28, 2019
66b404a
I think we'll need to get rid of the prometheus client
solsson May 28, 2019
84f5505
Use only quarkus libs
solsson May 28, 2019
f73c7c9
javax.json is a dependency of smallrye-health
solsson May 28, 2019
e9d9421
If we need metrics we should probably use quarkus-smallrye-metrics
solsson May 28, 2019
cda2347
Merge branch 'libs-prefer-quarkus' into quarkus-as-sidecar
solsson May 28, 2019
a4cb525
With microprofile metrics we can't make it optional
solsson May 28, 2019
e86e481
Disables the monitor as we no longer have metrics
solsson May 28, 2019
1573d8c
Fixes readiness in case of any empty partition
solsson May 28, 2019
7477482
Blocks REST responses (except for offsets) when cache is unready
solsson May 28, 2019
31ee792
Need e2e test cases before we change error handling on updates
solsson May 28, 2019
50568de
Log consumer loop settings to aid eperimentation
solsson May 28, 2019
3a3e9e6
helps push for two types of hub autobuilds
solsson May 28, 2019
6204008
Adapt bulid to quarkus 0.15.0 example dockerfiles, re-enable tests
solsson May 29, 2019
851729e
Still can't get junit tests to run on docker hub
solsson May 29, 2019
39907ac
Adds a metric, any really, so target isn't reported as down
solsson May 29, 2019
94b3339
This has been fixed
solsson May 29, 2019
5465b3c
The metrics framework prefixes everything with "application:" and class,
solsson May 29, 2019
b43d3fe
Logs build env coming from docker hub
solsson May 29, 2019
10f7bcb
Shows that updates error handling is still far from graceful
solsson May 29, 2019
dfffb59
Tries to use httpclient's retry APIs
solsson May 29, 2019
7a15896
Connection refused is fast so retry without wait is useless,
solsson May 29, 2019
99d5900
Switch to ready=true as soon as consumer has no lag,
solsson May 29, 2019
85c0a38
Restore the OK update endpoint
solsson May 29, 2019
25b9413
Merge branch 'retries-test' into quarkus-as-sidecar
solsson May 29, 2019
a7b1aa3
Attempt to fix build meta from docker hub
solsson May 29, 2019
af75a19
The reason to use the non-native build is to support all kafka compre…
solsson May 29, 2019
cb4edb6
Reverts the switch to Quarkus' base jre, to avoid alpine and
solsson May 29, 2019
aa4fd8a
Quarkus 0.16 and Kafka client 2.2.1
solsson Jun 4, 2019
d3c1647
Java props had no effect when placed after -jar, so only native can u…
solsson Jun 4, 2019
9f076a7
There's Duration converter fixes in Quarkus 0.16
solsson Jun 4, 2019
ccc42f1
Fixes flawed config entries
solsson Jun 4, 2019
937987e
Avoids accumulating retry interval, avoids slf4j param omission
solsson Jun 4, 2019
0a8231c
Unlike smallrye-reactive-messaging we have no generic
solsson Jun 4, 2019
42d19b5
Native build complains about missing no-args constructor
solsson Jun 4, 2019
2469065
Tries to avoid retry state despite an API that makes backoff hard
solsson Jun 4, 2019
a30b756
You'll frequently want to override port, but never log manager
solsson Jun 4, 2019
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
7 changes: 6 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*
# For ./mvnw package -Pnative -Dnative-image.docker-build=true
#!target/*-runner
#!target/*-runner.jar
#!target/lib/*
# For docker build .
!src
!build.gradle
!pom.xml
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ gradlew
out/
node_modules
dist
.mvn
target
.vscode
kubeconfig-kkv-kind
104 changes: 104 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
FROM maven:3.6.1-jdk-8-slim@sha256:dce33cc7a4702cc5f3ea3a6deb4ea840c17001895ffe169d96e1fd9d7041eb15 as maven

FROM openjdk:11.0.3-jdk-slim@sha256:ee1ee5fd0c9cef0ec5ed72999567ed7a6efd5bfdbf49326bfd9423c0dca84ef0 \
as dev

COPY --from=maven /usr/share/maven /usr/share/maven
RUN ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME=/usr/share/maven
ENV MAVEN_CONFIG=/root/.m2

WORKDIR /workspace
RUN mvn io.quarkus:quarkus-maven-plugin:0.15.0:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=getting-started \
-DclassName="org.acme.quickstart.GreetingResource" \
-Dpath="/hello"
COPY pom.xml .
RUN mvn package && \
rm -r src target mvnw* && \
ls -la
COPY . .

ENTRYPOINT [ "mvn", "compile", "quarkus:dev" ]
CMD [ "-Dquarkus.http.host=0.0.0.0", "-Dquarkus.http.port=8090" ]

FROM openjdk:11.0.3-jdk-slim@sha256:ee1ee5fd0c9cef0ec5ed72999567ed7a6efd5bfdbf49326bfd9423c0dca84ef0 \
as maven-build

COPY --from=maven /usr/share/maven /usr/share/maven
RUN ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME=/usr/share/maven
ENV MAVEN_CONFIG=/root/.m2

COPY --from=dev ${MAVEN_HOME} ${MAVEN_HOME}
COPY --from=dev ${MAVEN_CONFIG} ${MAVEN_CONFIG}

WORKDIR /workspace
COPY . .
# Can't get integration tests to pass on docker hub, and can't get logs from them
#RUN mvn -o package
RUN mvn -o package -DskipTests

FROM openjdk:11.0.3-jre-slim@sha256:73c29cc971f328f1456e443f55e4a7ce403638a0429a173549b5be76ef24ab37 \
as runtime-plainjava
ARG SOURCE_COMMIT
ARG SOURCE_BRANCH
ARG IMAGE_NAME

WORKDIR /app
COPY --from=maven-build /workspace/target/lib ./lib
COPY --from=maven-build /workspace/target/*-runner.jar ./quarkus-kafka.jar

EXPOSE 8090
ENTRYPOINT [ "java", \
"-Dquarkus.http.host=0.0.0.0", \
"-Dquarkus.http.port=8090", \
"-Djava.util.logging.manager=org.jboss.logmanager.LogManager", \
"-cp", "./lib/*", \
"-jar", "./quarkus-kafka.jar" ]

ENV SOURCE_COMMIT=${SOURCE_COMMIT} SOURCE_BRANCH=${SOURCE_BRANCH} IMAGE_NAME=${IMAGE_NAME}

# https://github.com/quarkusio/quarkus/issues/2412#issuecomment-494933951
#FROM oracle/graalvm-ce:19.0.0@sha256:71d4990f47e9b2300c57775e1306af477232019b624376c8f120d910caedb4b4 \
# as native-build
#RUN gu install native-image
FROM oracle/graalvm-ce:1.0.0-rc16@sha256:aa8b12e0bf15ffec6581f1a9feb42bf4c4f67d7c57d5739cca5fdc6c25fe4c54 \
as native-build

WORKDIR /project
COPY --from=maven-build /workspace/target/lib ./lib
COPY --from=maven-build /workspace/target/*-runner.jar ./

# from Quarkus' maven plugin mvn package -Pnative -Dnative-image.docker-build=true
# but CollectionPolicy commented out due to "Error: policy com.oracle.svm.core.genscavenge.CollectionPolicy cannot be instantiated."
RUN native-image \
-J-Djava.util.logging.manager=org.jboss.logmanager.LogManager \
#-H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime \
-jar kafka-keyvalue-1.0-SNAPSHOT-runner.jar \
-J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1 \
-H:FallbackThreshold=0 \
-H:+PrintAnalysisCallTree \
-H:-AddAllCharsets \
-H:EnableURLProtocols=http \
-H:-SpawnIsolates \
-H:-JNI \
--no-server \
-H:-UseServiceLoaderFeature \
-H:+StackTrace

# The rest should be identical to src/main/docker/Dockerfile which is the recommended quarkus build
FROM registry.fedoraproject.org/fedora-minimal@sha256:28dcdc19fd1d55598dc308a44c40287f4b00d0bf5a53cd01c39368c16cf85d57
ARG SOURCE_COMMIT
ARG SOURCE_BRANCH
ARG IMAGE_NAME

WORKDIR /work/
COPY --from=native-build /project/*-runner /work/application
#RUN chmod 775 /work
EXPOSE 8090
ENTRYPOINT ["./application", "-Djava.util.logging.manager=org.jboss.logmanager.LogManager"]
CMD ["-Dquarkus.http.host=0.0.0.0", "-Dquarkus.http.port=8090"]

ENV SOURCE_COMMIT=${SOURCE_COMMIT} SOURCE_BRANCH=${SOURCE_BRANCH} IMAGE_NAME=${IMAGE_NAME}
47 changes: 9 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,25 @@

## Example usage

See [the Node.js example](./example-nodejs-client/cache-update-flow.spec.js).
See the `- name: kkv` sidecar in [the example yaml](kontrakt/kkv-example.yaml).

## Design choices

* OnUpdate does not include message value because it could mean that consumers get old values, for example at retries or restarts.
* Restricted to a single replica per application ID at the moment. Based on [bakdata/kafka-key-value-store](https://medium.com/bakdata/queryable-kafka-topics-with-kafka-streams-8d2cca9de33f) we can add support for patitioned stores later.
Automated docker builds are available at [docker.io/solsson/kafka-keyvalue](https://hub.docker.com/r/solsson/kafka-keyvalue).

## Constraints

* Topic keys must be deserializable as [String](https://kafka.apache.org/21/javadoc/org/apache/kafka/common/serialization/Serdes.html#String--) because these strings are used in REST URIs.

## Running

Docker builds are available at [docker.io/kafka/keyvalue](https://hub.docker.com/r/yolean/kafka-keyvalue).

See examples of CLI args in [ArgsToOptionsTest](./src/test/java/se/yolean/kafka/keyvalue/cli/ArgsToOptionsTest.java).

For REST endpoints see `@Path` in [Endpoints](./src/main/java/se/yolean/kafka/keyvalue/Endpoints.java).

## Development

The [build-contract](https://github.com/Yolean/build-contract/) can be used as dev stack.
Use [Skaffold](), for example:

```bash
eval $(minikube docker-env)
kubectl apply -k github.com/Yolean/kubernetes-kafka/variants/dev-small?ref=v6.0.0
kubectl apply -f https://github.com/Yolean/kubernetes-kafka/raw/50345f266287861d7964d3339a2c2a28e79db2fe/variants/prometheus-operator-example/k8s-cluster-rbac.yaml
SKAFFOLD_NO_PRUNE=true skaffold dev
```
alias compose='docker-compose -f build-contracts/docker-compose.yml'
gradle jibDockerBuild --image=yolean/kafka-keyvalue:dev
compose up -d cache1
compose up smoketest
compose up --build example-nodejs-client
compose down
```

Note: `build-contract` (see [build-and-push.sh](./build-and-push.sh)) sometimes fails due to timing issues. Try re-running.

During development of the cache itself or the example nodejs client
it's more convenient to start only `kafka` and `pixy` through docker.

The main class is `se.yolean.kafka.keyvalue.cli.Main`.

Run the cache service from your IDE with args like: `--port 18081 --streams-props bootstrap.servers=localhost:19092 num.standby.replicas=0 --hostname localhost --topic topic1 --application-id kv-test1-local-001 --onupdate http://127.0.0.1:8081/kafka-keyvalue/v1/updates`

Test manually using for example `echo 'mytest={"t":1}' | kafkacat -b localhost:19092 -P -t topic1 -K '='; curl http://localhost:19081/cache/v1/raw/mytest`.

Run the nodejs locally using: `cd example-nodejs-client; npm ci; ./node_modules/.bin/jest --runInBand --watch `
(Note that the mock server for unupdate calls only exists during Jest runs)

## Logging

The distribution bundles log4j2, which we also use as logging API.
To configure per deployment, provide a file and set `-Dlog4j.configurationFile`.
For reconfigurability at runtime Kubernets configmaps could be used with [monitorInterval](https://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticReconfiguration).
See [Quarkus' logging configuration](https://quarkus.io/guides/logging-guide).
8 changes: 2 additions & 6 deletions build-and-push.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#!/bin/sh
set -e
# TODO make jib build run the unit tests

# If all tooling is available locally use
#gradlejibdocker=gradle
# github.com/Yolean/build-contract local or in-docker
#contract=build-contract
gradlejibdocker="docker run --rm -v $(pwd):/workspace -v /var/run/docker.sock:/var/run/docker.sock solsson/gradle-jib-docker@sha256:390f765ba4c8423e30ae1668bfd2e74f026a11b5ec3f0bae23bd36b0ed4c0c75 gradle --no-daemon --no-parallel"
contract="docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/:/source --rm --name kafka-keyvalue-build solsson/build-contract@sha256:961624a502c4bf64bdec328e65a911a2096192e7c1a268d7360b9c85ae7a35b8"

$gradlejibdocker --stacktrace test
$gradlejibdocker --stacktrace jibDockerBuild --image=yolean/kafka-keyvalue:dev -Djib.baseImageCache=build/jib-base-image-cache
docker build -t yolean/kafka-keyvalue:dev .

$contract test

Expand Down
140 changes: 54 additions & 86 deletions build-contracts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version: "3.4"
services:

zookeeper:
image: solsson/kafka:2.1.1@sha256:8bc8242c649c395ab79d76cc83b1052e63b4efea7f83547bf11eb3ef5ea6f8e1
image: solsson/kafka:2.2.0@sha256:cf048d6211b6b48f1783f97cb41add511386e2f0a5f5c62fa0eee9564dcd3e9a
entrypoint: ./bin/zookeeper-server-start.sh
command:
- ./config/zookeeper.properties

kafka:
image: solsson/kafka:2.1.1@sha256:8bc8242c649c395ab79d76cc83b1052e63b4efea7f83547bf11eb3ef5ea6f8e1
image: solsson/kafka:2.2.0@sha256:cf048d6211b6b48f1783f97cb41add511386e2f0a5f5c62fa0eee9564dcd3e9a
depends_on:
- zookeeper
entrypoint:
Expand Down Expand Up @@ -47,7 +47,7 @@ services:
- 0.0.0.0:19090

topic1-create:
image: solsson/kafka:2.1.1@sha256:8bc8242c649c395ab79d76cc83b1052e63b4efea7f83547bf11eb3ef5ea6f8e1
image: solsson/kafka:2.2.0@sha256:cf048d6211b6b48f1783f97cb41add511386e2f0a5f5c62fa0eee9564dcd3e9a
depends_on:
- kafka
entrypoint:
Expand All @@ -64,32 +64,34 @@ services:
- --replication-factor
- '1'

kkv-plainjava:
image: yolean/kafka-keyvalue:plainjava
build:
context: ../
target: runtime-plainjava
labels:
- com.yolean.build-target
command:
- echo
- This was only a build. Exiting.

cache1:
depends_on:
- kafka
- topic1-create
image: yolean/kafka-keyvalue:dev
image: yolean/kafka-keyvalue:latest
build:
context: ../
labels:
- com.yolean.build-target
ports:
- 19081:19081
command:
- --standalone
- --application-id
- kv-001-
- --port
- '19081'
- --streams-props
- bootstrap.servers=kafka:9092
- num.standby.replicas=0
- --topic
- topic1
- --onupdate
- http://example-nodejs-client:8081/kafka-keyvalue/v1/updates
- http://onupdate-logging:8080/
- http://example-nodejs-client:8082/testpost
- --starttimeout
- '10'
- 19081:8080
environment:
- kafka_bootstrap=kafka:9092
- kafka_group_id=cache1
- kafka_offset_reset=latest
- topics=topic1
#- update_targets=http://example-nodejs-client:8081/kafka-keyvalue/v1/updates,http://onupdate-logging:8080/,http://example-nodejs-client:8082/testpost

onupdate-logging:
image: solsson/httpstatus-random:access-logging@sha256:5330b2e84457e65ae9552acb00b26e8b7b2a878bcafb3baabddc13c1f840cd90
Expand Down Expand Up @@ -139,70 +141,36 @@ services:
# By design the cache service deals with a single topic, meaning that tests probably can't run concurrently
- --runInBand

topic2-create:
image: solsson/kafka:2.1.1@sha256:8bc8242c649c395ab79d76cc83b1052e63b4efea7f83547bf11eb3ef5ea6f8e1
depends_on:
- kafka
entrypoint:
- ./bin/kafka-topics.sh
# compose build && compose up -d k8s-kind && compose logs -f k8s-kind
# compose exec k8s-kind cat /root/.kube/kind-config-kkv > ./kubeconfig-kkv-kind
# export KUBECONFIG=$(pwd)/kubeconfig-kkv-kind
# kubectl apply -f kontrakt/
k8s-kind:
build:
context: ../kontrakt/kind
volumes:
- /var/run/docker.sock:/var/run/docker.sock:rw
network_mode: host
environment:
- KIND_NAME=kkv
- KUBECONFIG=/root/.kube/kind-config-kkv
command:
- --zookeeper
- zookeeper:2181
- --topic
- topic2
- --create
- --if-not-exists
- --partitions
- '12'
- --replication-factor
- '1'
- /bin/sh
- -cex
- |
kind delete cluster --name=$$KIND_NAME || echo "Found no prior cluster"
kind create cluster --name=$$KIND_NAME
kind get kubeconfig-path --name=$$KIND_NAME
kubectl cluster-info

cache2-01:
depends_on:
- kafka
- topic2-create
image: yolean/kafka-keyvalue:dev
expose:
- '19082'
command:
- --port
- '19082'
- --streams-props
- bootstrap.servers=kafka:9092
# Not sure how to do this in docker-compose
#- num.standby.replicas=1
- --hostname
- cache2-01
- --application-id
- kv-002
- --topic
- topic2
- --onupdate
- http://onupdate-logging:8080/sharded/01
- --starttimeout
- '25'
cd kubernetes-kafka
kubectl apply -f 00-namespace.yml
kubectl apply -f rbac-namespace-default/
kubectl apply -k variants/scale-1-ephemeral/
kubectl apply -f pixy/

cache2-02:
depends_on:
- kafka
- topic2-create
image: yolean/kafka-keyvalue:dev
expose:
- '19083'
command:
- --port
- '19083'
- --streams-props
- bootstrap.servers=kafka:9092
# Not sure how to do this in docker-compose
#- num.standby.replicas=1
- --hostname
- cache2-02
- --application-id
- kv-002
- --topic
- topic2
- --onupdate
- http://onupdate-logging:8080/sharded/02
- --starttimeout
- '25'
# Load images built by docker-compose (to re-load use compose exec)
kind load docker-image yolean/kafka-keyvalue:latest --name=$$KIND_NAME
kind load docker-image yolean/kafka-keyvalue:plainjava --name=$$KIND_NAME

tail -f /dev/null
Loading