-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Kafka-15444: Native docker image for Apache Kafka(KIP-974) #15927
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
9 commits
Select commit
Hold shift + click to select a range
7bb2f99
KAFKA-15444: Add kafka startup to KafkaDockerWrapper
kagarwal06 18546c6
KAFKA-15444: Add native-image configs
kagarwal06 e41bcfc
KAFKA-15444: Add dockerfile and startup script
kagarwal06 6b5839b
KAFKA-15444: Integrate native docker image with build and test pipelines
kagarwal06 6c82b2e
KAFKA-15444: Update native-image configs
kagarwal06 452bb27
KAFKA-15444: Use generic test name
kagarwal06 742a331
Merge branch 'trunk' into native-image-KAFKA-15444
kagarwal06 406247a
KAFKA-15444: Add native docker image support in build_push script
kagarwal06 a3916a5
KAFKA-15444: Address PR comments
kagarwal06 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
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
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,90 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You 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. | ||
|
|
||
| FROM ghcr.io/graalvm/graalvm-community:21 AS build-native-image | ||
|
|
||
| ARG kafka_url | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ENV KAFKA_URL=$kafka_url | ||
| COPY native-image-configs native-image-configs | ||
|
|
||
| RUN mkdir kafka; \ | ||
| microdnf install wget; \ | ||
| wget -nv -O kafka.tgz "$KAFKA_URL"; \ | ||
| wget -nv -O kafka.tgz.asc "$kafka_url.asc"; \ | ||
| tar xfz kafka.tgz -C kafka --strip-components 1; \ | ||
| wget -nv -O KEYS https://downloads.apache.org/kafka/KEYS; \ | ||
| gpg --import KEYS; \ | ||
| gpg --batch --verify kafka.tgz.asc kafka.tgz; \ | ||
| rm kafka.tgz ; \ | ||
| cd kafka ; \ | ||
| # Build the native-binary of the apache kafka using graalVM native-image. | ||
| native-image --no-fallback \ | ||
| --enable-http \ | ||
| --enable-https \ | ||
| --allow-incomplete-classpath \ | ||
| --report-unsupported-elements-at-runtime \ | ||
| --install-exit-handlers \ | ||
| --enable-monitoring=jmxserver,jmxclient,heapdump,jvmstat \ | ||
| -H:+ReportExceptionStackTraces \ | ||
| -H:+EnableAllSecurityServices \ | ||
| -H:EnableURLProtocols=http,https \ | ||
| -H:AdditionalSecurityProviders=sun.security.jgss.SunProvider \ | ||
| -H:ReflectionConfigurationFiles=/app/native-image-configs/reflect-config.json \ | ||
| -H:JNIConfigurationFiles=/app/native-image-configs/jni-config.json \ | ||
| -H:ResourceConfigurationFiles=/app/native-image-configs/resource-config.json \ | ||
| -H:SerializationConfigurationFiles=/app/native-image-configs/serialization-config.json \ | ||
| -H:PredefinedClassesConfigurationFiles=/app/native-image-configs/predefined-classes-config.json \ | ||
| -H:DynamicProxyConfigurationFiles=/app/native-image-configs/proxy-config.json \ | ||
| --verbose \ | ||
| -march=compatibility \ | ||
| -cp "libs/*" kafka.docker.KafkaDockerWrapper \ | ||
| -o kafka.Kafka | ||
|
|
||
|
|
||
| FROM alpine:latest | ||
|
|
||
| EXPOSE 9092 | ||
|
|
||
| ARG build_date | ||
|
|
||
| LABEL org.label-schema.name="kafka" \ | ||
| org.label-schema.description="Apache Kafka" \ | ||
| org.label-schema.build-date="${build_date}" \ | ||
| org.label-schema.vcs-url="https://github.com/apache/kafka" \ | ||
| maintainer="Apache Kafka" | ||
|
|
||
| RUN apk update ; \ | ||
| apk add --no-cache gcompat ; \ | ||
| apk add --no-cache bash ; \ | ||
| mkdir -p /etc/kafka/docker /mnt/shared/config /opt/kafka/config /etc/kafka/secrets ; \ | ||
| adduser -h /home/appuser -D --shell /bin/bash appuser ; \ | ||
| chown appuser:root -R /etc/kafka /opt/kafka /mnt/shared/config ; \ | ||
| chmod -R ug+w /etc/kafka /opt/kafka /mnt/shared/config ; | ||
|
|
||
| COPY --chown=appuser:root --from=build-native-image /app/kafka/kafka.Kafka /opt/kafka/ | ||
| COPY --chown=appuser:root --from=build-native-image /app/kafka/config/kraft/server.properties /etc/kafka/docker/ | ||
| COPY --chown=appuser:root --from=build-native-image /app/kafka/config/log4j.properties /etc/kafka/docker/ | ||
| COPY --chown=appuser:root --from=build-native-image /app/kafka/config/tools-log4j.properties /etc/kafka/docker/ | ||
| COPY --chown=appuser:root resources/common-scripts /etc/kafka/docker/ | ||
| COPY --chown=appuser:root launch /etc/kafka/docker/ | ||
|
|
||
| USER appuser | ||
|
|
||
| VOLUME ["/etc/kafka/secrets", "/mnt/shared/config"] | ||
|
|
||
| CMD ["/etc/kafka/docker/run"] | ||
|
kagarwal06 marked this conversation as resolved.
|
||
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,50 @@ | ||
| #!/bin/sh | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You 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. | ||
|
|
||
| # Override this section from the script to include the com.sun.management.jmxremote.rmi.port property. | ||
| if [ -z "${KAFKA_JMX_OPTS-}" ]; then | ||
| export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote=true \ | ||
| -Dcom.sun.management.jmxremote.authenticate=false \ | ||
| -Dcom.sun.management.jmxremote.ssl=false " | ||
| fi | ||
|
|
||
| # The JMX client needs to be able to connect to java.rmi.server.hostname. | ||
| # The default for bridged n/w is the bridged IP so you will only be able to connect from another docker container. | ||
| # For host n/w, this is the IP that the hostname on the host resolves to. | ||
|
|
||
| # If you have more than one n/w configured, hostname -i gives you all the IPs, | ||
| # the default is to pick the first IP (or network). | ||
| export KAFKA_JMX_HOSTNAME=${KAFKA_JMX_HOSTNAME:-$(hostname -i | cut -d" " -f1)} | ||
|
|
||
| if [ "${KAFKA_JMX_PORT-}" ]; then | ||
| export JMX_PORT=$KAFKA_JMX_PORT | ||
| export KAFKA_JMX_OPTS="${KAFKA_JMX_OPTS-} -Djava.rmi.server.hostname=$KAFKA_JMX_HOSTNAME \ | ||
| -Dcom.sun.management.jmxremote.local.only=false \ | ||
| -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT \ | ||
| -Dcom.sun.management.jmxremote.port=$JMX_PORT" | ||
| fi | ||
|
kagarwal06 marked this conversation as resolved.
|
||
|
|
||
| # Invoke the docker wrapper to setup property files and format storage | ||
| result=$(/opt/kafka/kafka.Kafka setup \ | ||
| --default-configs-dir /etc/kafka/docker \ | ||
| --mounted-configs-dir /mnt/shared/config \ | ||
| --final-configs-dir /opt/kafka/config \ | ||
| -Dlog4j.configuration=file:/opt/kafka/config/tools-log4j.properties 2>&1) || \ | ||
| echo $result | grep -i "already formatted" || \ | ||
| { echo $result && (exit 1) } | ||
|
|
||
| KAFKA_LOG4J_CMD_OPTS="-Dkafka.logs.dir=/opt/kafka/logs/ -Dlog4j.configuration=file:/opt/kafka/config/log4j.properties" | ||
| exec /opt/kafka/kafka.Kafka start --config /opt/kafka/config/server.properties $KAFKA_LOG4J_CMD_OPTS $KAFKA_JMX_OPTS ${KAFKA_OPTS-} | ||
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,35 @@ | ||
| [ | ||
| { | ||
| "name":"[Lcom.sun.management.internal.DiagnosticCommandArgumentInfo;" | ||
| }, | ||
| { | ||
| "name":"[Lcom.sun.management.internal.DiagnosticCommandInfo;" | ||
| }, | ||
| { | ||
| "name":"com.github.luben.zstd.ZstdInputStreamNoFinalizer", | ||
| "fields":[{"name":"dstPos"}, {"name":"srcPos"}] | ||
| }, | ||
| { | ||
| "name":"com.sun.management.internal.DiagnosticCommandArgumentInfo", | ||
| "methods":[{"name":"<init>","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","boolean","boolean","int"] }] | ||
| }, | ||
| { | ||
| "name":"com.sun.management.internal.DiagnosticCommandInfo", | ||
| "methods":[{"name":"<init>","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","java.util.List"] }] | ||
| }, | ||
| { | ||
| "name":"java.lang.Boolean", | ||
| "methods":[{"name":"getBoolean","parameterTypes":["java.lang.String"] }] | ||
| }, | ||
| { | ||
| "name":"java.lang.OutOfMemoryError" | ||
| }, | ||
| { | ||
| "name":"java.util.Arrays", | ||
| "methods":[{"name":"asList","parameterTypes":["java.lang.Object[]"] }] | ||
| }, | ||
| { | ||
| "name":"sun.management.VMManagementImpl", | ||
| "fields":[{"name":"compTimeMonitoringSupport"}, {"name":"currentThreadCpuTimeSupport"}, {"name":"objectMonitorUsageSupport"}, {"name":"otherThreadCpuTimeSupport"}, {"name":"remoteDiagnosticCommandsSupport"}, {"name":"synchronizerUsageSupport"}, {"name":"threadAllocatedMemorySupport"}, {"name":"threadContentionMonitoringSupport"}] | ||
| } | ||
| ] |
7 changes: 7 additions & 0 deletions
7
docker/native/native-image-configs/predefined-classes-config.json
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,7 @@ | ||
| [ | ||
| { | ||
| "type":"agent-extracted", | ||
| "classes":[ | ||
| ] | ||
| } | ||
| ] |
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,5 @@ | ||
| [ | ||
| { | ||
| "interfaces":["sun.misc.SignalHandler"] | ||
| } | ||
| ] |
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.
Uh oh!
There was an error while loading. Please reload this page.