Skip to content

Commit

Permalink
Single operator image (strimzi#1431)
Browse files Browse the repository at this point in the history
  • Loading branch information
tombentley authored Mar 15, 2019
1 parent 9d628b5 commit bf867b8
Show file tree
Hide file tree
Showing 35 changed files with 270 additions and 185 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ master.html

helm-charts/strimzi-kafka-operator-*.*.*.tgz

docker-images/operator/.*.tmp
docker-images/operator/tmp/**

# Connect plugin (tests)
systemtest/*.tar.gz
systemtest/my-plugins/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ifneq ($(RELEASE_VERSION),latest)
GITHUB_VERSION = $(RELEASE_VERSION)
endif

SUBDIRS=docker-images helm-charts mockkube test crd-generator api certificate-manager operator-common cluster-operator topic-operator user-operator kafka-init install examples metrics
SUBDIRS=mockkube test crd-generator api certificate-manager operator-common cluster-operator topic-operator user-operator kafka-init docker-images helm-charts install examples metrics
DOCKER_TARGETS=docker_build docker_push docker_tag

all: $(SUBDIRS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class KafkaClusterSpec implements UnknownPropertyPreserving, Serializable
private static final long serialVersionUID = 1L;

public static final String DEFAULT_INIT_IMAGE =
System.getenv().getOrDefault("STRIMZI_DEFAULT_KAFKA_INIT_IMAGE", "strimzi/kafka-init:latest");
System.getenv().getOrDefault("STRIMZI_DEFAULT_KAFKA_INIT_IMAGE", "strimzi/operator:latest");

public static final String FORBIDDEN_PREFIXES = "listeners, advertised., broker., listener., host.name, port, "
+ "inter.broker.listener.name, sasl., ssl., security., password., principal.builder.class, log.dir, "
Expand Down
10 changes: 0 additions & 10 deletions cluster-operator/Dockerfile

This file was deleted.

7 changes: 5 additions & 2 deletions cluster-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
PROJECT_NAME=cluster-operator

docker_build: java_build

docker_tag:

docker_push:

all: docker_build docker_push
clean: java_clean

include ../Makefile.docker

include ../Makefile.maven

.PHONY: build clean release
47 changes: 23 additions & 24 deletions cluster-operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<exclusions>
<!-- We just depend on the CronExpression class, not all of quartz's deps -->
<exclusion>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -125,33 +132,25 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.version}</version>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
</execution>
<execution>
<id>set-classpath</id>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-dist-assembly</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.strimzi.operator.cluster.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
4 changes: 4 additions & 0 deletions cluster-operator/scripts/cluster_operator_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
export JAVA_CLASSPATH=lib/[email protected]@[email protected]@:@project.dist.classpath@
export JAVA_MAIN=io.strimzi.operator.cluster.Main
exec ${STRIMZI_HOME}/bin/launch_java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ protected List<Container> getContainers(ImagePullPolicy imagePullPolicy) {
return singletonList(new ContainerBuilder()
.withName(TOPIC_OPERATOR_CONTAINER_NAME)
.withImage(getImage())
.withArgs("/opt/strimzi/bin/topic_operator_run.sh")
.withEnv(getEnvVars())
.withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP")))
.withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ protected List<Container> getContainers(ImagePullPolicy imagePullPolicy) {
return singletonList(new ContainerBuilder()
.withName(USER_OPERATOR_CONTAINER_NAME)
.withImage(getImage())
.withArgs("/opt/strimzi/bin/user_operator_run.sh")
.withEnv(getEnvVars())
.withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP")))
.withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ protected List<Container> getInitContainers(ImagePullPolicy imagePullPolicy) {
Container initContainer = new ContainerBuilder()
.withName(INIT_NAME)
.withImage(initImage)
.withArgs("/opt/strimzi/bin/kafka_init_run.sh")
.withResources(resources)
.withEnv(varList)
.withVolumeMounts(createVolumeMount(INIT_VOLUME_NAME, INIT_VOLUME_MOUNT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ protected List<Container> getContainers(ImagePullPolicy imagePullPolicy) {
Container container = new ContainerBuilder()
.withName(TOPIC_OPERATOR_NAME)
.withImage(getImage())
.withArgs("/opt/strimzi/bin/topic-operator-run.sh")
.withEnv(getEnvVars())
.withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP")))
.withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout))
Expand Down
26 changes: 26 additions & 0 deletions dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>dist</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<filtered>true</filtered>
<outputDirectory>bin</outputDirectory>
<directory>scripts</directory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
<outputFileNameMapping>${artifact.groupId}.${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
</dependencySets>
</assembly>
2 changes: 1 addition & 1 deletion docker-images/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

java_images="java-base"
java_images="operator"
kafka_images="kafka test-client"

# Kafka versions
Expand Down
5 changes: 0 additions & 5 deletions docker-images/java-base/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ ENV JAVA_HOME /usr/lib/jvm/java
# The user is in the group 0 to have access to the mounted volumes and storage
RUN useradd -r -m -u 1001 -g 0 strimzi

# Copy scripts for starting Java apps
COPY scripts/* /bin/
ARG strimzi_version=1.0-SNAPSHOT
ENV STRIMZI_VERSION ${strimzi_version}
ENV STRIMZI_HOME=/opt/strimzi
RUN mkdir -p /opt/strimzi/bin
WORKDIR /opt/strimzi

CMD ["java", "-version"]
COPY scripts/ tmp/bin/ bin/

COPY tmp/lib/ lib/

USER 1001
32 changes: 32 additions & 0 deletions docker-images/operator/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PROJECT_NAME=operator

clean:
rm -rf lib
rm -rf tmp
rm .*.tmp

.topic-operator.tmp: ../../topic-operator/target/*-dist.zip
test -d tmp || mkdir tmp
unzip -qo ../../topic-operator/target/*-dist.zip -d tmp
touch .topic-operator.tmp

.user-operator.tmp: ../../user-operator/target/*-dist.zip
test -d tmp || mkdir tmp
unzip -qo ../../user-operator/target/*-dist.zip -d tmp
touch .user-operator.tmp

.kafka-init.tmp: ../../kafka-init/target/*-dist.zip
test -d tmp || mkdir tmp
unzip -qo ../../kafka-init/target/*-dist.zip -d tmp
touch .kafka-init.tmp

.cluster-operator.tmp: ../../cluster-operator/target/*-dist.zip
test -d tmp || mkdir tmp
unzip -qo ../../cluster-operator/target/*-dist.zip -d tmp
touch .cluster-operator.tmp

docker_build: .topic-operator.tmp .user-operator.tmp .kafka-init.tmp .cluster-operator.tmp

include ../../Makefile.docker

.PHONY: build clean release
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env bash
set -x
JAR=$1
shift

. /bin/dynamic_resources.sh
. ${STRIMZI_HOME}/bin/dynamic_resources.sh

# expand gc options based upon java version
function get_gc_opts {
Expand Down Expand Up @@ -34,4 +33,4 @@ JAVA_OPTS="${JAVA_OPTS} -Dvertx.cacheDirBase=/tmp -Djava.security.egd=file:/dev/
# Enable GC logging for memory tracking
JAVA_OPTS="${JAVA_OPTS} $(get_gc_opts)"

exec java $JAVA_OPTS -jar $JAR $@
exec java $JAVA_OPTS -classpath $JAVA_CLASSPATH $JAVA_MAIN $@
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spec:
- name: strimzi-cluster-operator
image: {{ default .Values.image.repository .Values.imageRepositoryOverride }}/{{ .Values.image.name }}:{{ default .Values.image.tag .Values.imageTagOverride }}
imagePullPolicy: {{ .Values.image.imagePullPolicy | quote }}
args:
- /opt/strimzi/bin/cluster_operator_run.sh
env:
- name: STRIMZI_NAMESPACE
{{- if .Values.watchNamespaces -}}
Expand Down
8 changes: 4 additions & 4 deletions helm-charts/strimzi-kafka-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ watchNamespaces: []

image:
repository: strimzi
name: cluster-operator
name: operator
tag: latest
imagePullPolicy: IfNotPresent
logLevel: INFO
Expand Down Expand Up @@ -36,17 +36,17 @@ kafkaConnects2i:
topicOperator:
image:
repository: strimzi
name: topic-operator
name: operator
tag: latest
userOperator:
image:
repository: strimzi
name: user-operator
name: operator
tag: latest
kafkaInit:
image:
repository: strimzi
name: kafka-init
name: operator
tag: latest
tlsSidecarZookeeper:
image:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ spec:
serviceAccountName: strimzi-cluster-operator
containers:
- name: strimzi-cluster-operator
image: strimzi/cluster-operator:latest
image: strimzi/operator:latest
imagePullPolicy: IfNotPresent
args:
- /opt/strimzi/bin/cluster_operator_run.sh
env:
- name: STRIMZI_NAMESPACE
valueFrom:
Expand Down Expand Up @@ -59,11 +61,11 @@ spec:
2.1.0=strimzi/kafka:latest-kafka-2.1.0
2.1.1=strimzi/kafka:latest-kafka-2.1.1
- name: STRIMZI_DEFAULT_TOPIC_OPERATOR_IMAGE
value: strimzi/topic-operator:latest
value: strimzi/operator:latest
- name: STRIMZI_DEFAULT_USER_OPERATOR_IMAGE
value: strimzi/user-operator:latest
value: strimzi/operator:latest
- name: STRIMZI_DEFAULT_KAFKA_INIT_IMAGE
value: strimzi/kafka-init:latest
value: strimzi/operator:latest
- name: STRIMZI_LOG_LEVEL
value: INFO
livenessProbe:
Expand Down
10 changes: 0 additions & 10 deletions kafka-init/Dockerfile

This file was deleted.

7 changes: 5 additions & 2 deletions kafka-init/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
PROJECT_NAME=kafka-init

docker_build: java_build

docker_tag:

docker_push:

all: docker_build docker_push
clean: java_clean

include ../Makefile.docker

include ../Makefile.maven

.PHONY: build clean release
Loading

0 comments on commit bf867b8

Please sign in to comment.