Skip to content

Commit bf867b8

Browse files
authored
Single operator image (strimzi#1431)
1 parent 9d628b5 commit bf867b8

35 files changed

+270
-185
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ master.html
3131

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

34+
docker-images/operator/.*.tmp
35+
docker-images/operator/tmp/**
36+
3437
# Connect plugin (tests)
3538
systemtest/*.tar.gz
3639
systemtest/my-plugins/

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ifneq ($(RELEASE_VERSION),latest)
1111
GITHUB_VERSION = $(RELEASE_VERSION)
1212
endif
1313

14-
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
14+
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
1515
DOCKER_TARGETS=docker_build docker_push docker_tag
1616

1717
all: $(SUBDIRS)

api/src/main/java/io/strimzi/api/kafka/model/KafkaClusterSpec.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class KafkaClusterSpec implements UnknownPropertyPreserving, Serializable
4545
private static final long serialVersionUID = 1L;
4646

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

5050
public static final String FORBIDDEN_PREFIXES = "listeners, advertised., broker., listener., host.name, port, "
5151
+ "inter.broker.listener.name, sasl., ssl., security., password., principal.builder.class, log.dir, "

cluster-operator/Dockerfile

-10
This file was deleted.

cluster-operator/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
PROJECT_NAME=cluster-operator
22

33
docker_build: java_build
4+
5+
docker_tag:
6+
7+
docker_push:
8+
49
all: docker_build docker_push
510
clean: java_clean
611

7-
include ../Makefile.docker
8-
912
include ../Makefile.maven
1013

1114
.PHONY: build clean release

cluster-operator/pom.xml

+23-24
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@
7474
<dependency>
7575
<groupId>org.quartz-scheduler</groupId>
7676
<artifactId>quartz</artifactId>
77+
<exclusions>
78+
<!-- We just depend on the CronExpression class, not all of quartz's deps -->
79+
<exclusion>
80+
<groupId>c3p0</groupId>
81+
<artifactId>c3p0</artifactId>
82+
</exclusion>
83+
</exclusions>
7784
</dependency>
7885
<dependency>
7986
<groupId>org.apache.logging.log4j</groupId>
@@ -125,33 +132,25 @@
125132
</plugin>
126133
<plugin>
127134
<groupId>org.apache.maven.plugins</groupId>
128-
<artifactId>maven-shade-plugin</artifactId>
129-
<version>${maven.shade.version}</version>
135+
<artifactId>maven-dependency-plugin</artifactId>
130136
<executions>
131137
<execution>
138+
<id>copy-dependencies</id>
139+
<phase>package</phase>
140+
</execution>
141+
<execution>
142+
<id>set-classpath</id>
143+
<phase>package</phase>
144+
</execution>
145+
</executions>
146+
</plugin>
147+
<plugin>
148+
<groupId>org.apache.maven.plugins</groupId>
149+
<artifactId>maven-assembly-plugin</artifactId>
150+
<executions>
151+
<execution>
152+
<id>make-dist-assembly</id>
132153
<phase>package</phase>
133-
<goals>
134-
<goal>shade</goal>
135-
</goals>
136-
<configuration>
137-
<filters>
138-
<filter>
139-
<artifact>*:*</artifact>
140-
<excludes>
141-
<exclude>META-INF/*.SF</exclude>
142-
<exclude>META-INF/*.DSA</exclude>
143-
<exclude>META-INF/*.RSA</exclude>
144-
</excludes>
145-
</filter>
146-
</filters>
147-
<createDependencyReducedPom>false</createDependencyReducedPom>
148-
<transformers>
149-
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
150-
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
151-
<mainClass>io.strimzi.operator.cluster.Main</mainClass>
152-
</transformer>
153-
</transformers>
154-
</configuration>
155154
</execution>
156155
</executions>
157156
</plugin>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
export JAVA_CLASSPATH=lib/[email protected]@[email protected]@:@project.dist.classpath@
3+
export JAVA_MAIN=io.strimzi.operator.cluster.Main
4+
exec ${STRIMZI_HOME}/bin/launch_java.sh

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/EntityTopicOperator.java

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ protected List<Container> getContainers(ImagePullPolicy imagePullPolicy) {
218218
return singletonList(new ContainerBuilder()
219219
.withName(TOPIC_OPERATOR_CONTAINER_NAME)
220220
.withImage(getImage())
221+
.withArgs("/opt/strimzi/bin/topic_operator_run.sh")
221222
.withEnv(getEnvVars())
222223
.withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP")))
223224
.withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout))

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/EntityUserOperator.java

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ protected List<Container> getContainers(ImagePullPolicy imagePullPolicy) {
209209
return singletonList(new ContainerBuilder()
210210
.withName(USER_OPERATOR_CONTAINER_NAME)
211211
.withImage(getImage())
212+
.withArgs("/opt/strimzi/bin/user_operator_run.sh")
212213
.withEnv(getEnvVars())
213214
.withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP")))
214215
.withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout))

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java

+1
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ protected List<Container> getInitContainers(ImagePullPolicy imagePullPolicy) {
838838
Container initContainer = new ContainerBuilder()
839839
.withName(INIT_NAME)
840840
.withImage(initImage)
841+
.withArgs("/opt/strimzi/bin/kafka_init_run.sh")
841842
.withResources(resources)
842843
.withEnv(varList)
843844
.withVolumeMounts(createVolumeMount(INIT_VOLUME_NAME, INIT_VOLUME_MOUNT))

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/TopicOperator.java

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ protected List<Container> getContainers(ImagePullPolicy imagePullPolicy) {
265265
Container container = new ContainerBuilder()
266266
.withName(TOPIC_OPERATOR_NAME)
267267
.withImage(getImage())
268+
.withArgs("/opt/strimzi/bin/topic-operator-run.sh")
268269
.withEnv(getEnvVars())
269270
.withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP")))
270271
.withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout))

dist.xml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<assembly
2+
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
5+
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
6+
<id>dist</id>
7+
<formats>
8+
<format>zip</format>
9+
</formats>
10+
<includeBaseDirectory>false</includeBaseDirectory>
11+
<fileSets>
12+
<fileSet>
13+
<filtered>true</filtered>
14+
<outputDirectory>bin</outputDirectory>
15+
<directory>scripts</directory>
16+
</fileSet>
17+
</fileSets>
18+
<dependencySets>
19+
<dependencySet>
20+
<outputDirectory>lib</outputDirectory>
21+
<unpack>false</unpack>
22+
<scope>runtime</scope>
23+
<outputFileNameMapping>${artifact.groupId}.${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
24+
</dependencySet>
25+
</dependencySets>
26+
</assembly>

docker-images/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
java_images="java-base"
4+
java_images="operator"
55
kafka_images="kafka test-client"
66

77
# Kafka versions

docker-images/java-base/Makefile

-5
This file was deleted.

docker-images/java-base/Dockerfile docker-images/operator/Dockerfile

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

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

16-
CMD ["java", "-version"]
19+
COPY scripts/ tmp/bin/ bin/
20+
21+
COPY tmp/lib/ lib/
22+
23+
USER 1001

docker-images/operator/Makefile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
PROJECT_NAME=operator
2+
3+
clean:
4+
rm -rf lib
5+
rm -rf tmp
6+
rm .*.tmp
7+
8+
.topic-operator.tmp: ../../topic-operator/target/*-dist.zip
9+
test -d tmp || mkdir tmp
10+
unzip -qo ../../topic-operator/target/*-dist.zip -d tmp
11+
touch .topic-operator.tmp
12+
13+
.user-operator.tmp: ../../user-operator/target/*-dist.zip
14+
test -d tmp || mkdir tmp
15+
unzip -qo ../../user-operator/target/*-dist.zip -d tmp
16+
touch .user-operator.tmp
17+
18+
.kafka-init.tmp: ../../kafka-init/target/*-dist.zip
19+
test -d tmp || mkdir tmp
20+
unzip -qo ../../kafka-init/target/*-dist.zip -d tmp
21+
touch .kafka-init.tmp
22+
23+
.cluster-operator.tmp: ../../cluster-operator/target/*-dist.zip
24+
test -d tmp || mkdir tmp
25+
unzip -qo ../../cluster-operator/target/*-dist.zip -d tmp
26+
touch .cluster-operator.tmp
27+
28+
docker_build: .topic-operator.tmp .user-operator.tmp .kafka-init.tmp .cluster-operator.tmp
29+
30+
include ../../Makefile.docker
31+
32+
.PHONY: build clean release

docker-images/java-base/scripts/launch_java.sh docker-images/operator/scripts/launch_java.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env bash
22
set -x
3-
JAR=$1
43
shift
54

6-
. /bin/dynamic_resources.sh
5+
. ${STRIMZI_HOME}/bin/dynamic_resources.sh
76

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

37-
exec java $JAVA_OPTS -jar $JAR $@
36+
exec java $JAVA_OPTS -classpath $JAVA_CLASSPATH $JAVA_MAIN $@

helm-charts/strimzi-kafka-operator/templates/050-Deployment-strimzi-cluster-operator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ spec:
2121
- name: strimzi-cluster-operator
2222
image: {{ default .Values.image.repository .Values.imageRepositoryOverride }}/{{ .Values.image.name }}:{{ default .Values.image.tag .Values.imageTagOverride }}
2323
imagePullPolicy: {{ .Values.image.imagePullPolicy | quote }}
24+
args:
25+
- /opt/strimzi/bin/cluster_operator_run.sh
2426
env:
2527
- name: STRIMZI_NAMESPACE
2628
{{- if .Values.watchNamespaces -}}

helm-charts/strimzi-kafka-operator/values.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ watchNamespaces: []
44

55
image:
66
repository: strimzi
7-
name: cluster-operator
7+
name: operator
88
tag: latest
99
imagePullPolicy: IfNotPresent
1010
logLevel: INFO
@@ -36,17 +36,17 @@ kafkaConnects2i:
3636
topicOperator:
3737
image:
3838
repository: strimzi
39-
name: topic-operator
39+
name: operator
4040
tag: latest
4141
userOperator:
4242
image:
4343
repository: strimzi
44-
name: user-operator
44+
name: operator
4545
tag: latest
4646
kafkaInit:
4747
image:
4848
repository: strimzi
49-
name: kafka-init
49+
name: operator
5050
tag: latest
5151
tlsSidecarZookeeper:
5252
image:

install/cluster-operator/050-Deployment-strimzi-cluster-operator.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ spec:
1515
serviceAccountName: strimzi-cluster-operator
1616
containers:
1717
- name: strimzi-cluster-operator
18-
image: strimzi/cluster-operator:latest
18+
image: strimzi/operator:latest
1919
imagePullPolicy: IfNotPresent
20+
args:
21+
- /opt/strimzi/bin/cluster_operator_run.sh
2022
env:
2123
- name: STRIMZI_NAMESPACE
2224
valueFrom:
@@ -59,11 +61,11 @@ spec:
5961
2.1.0=strimzi/kafka:latest-kafka-2.1.0
6062
2.1.1=strimzi/kafka:latest-kafka-2.1.1
6163
- name: STRIMZI_DEFAULT_TOPIC_OPERATOR_IMAGE
62-
value: strimzi/topic-operator:latest
64+
value: strimzi/operator:latest
6365
- name: STRIMZI_DEFAULT_USER_OPERATOR_IMAGE
64-
value: strimzi/user-operator:latest
66+
value: strimzi/operator:latest
6567
- name: STRIMZI_DEFAULT_KAFKA_INIT_IMAGE
66-
value: strimzi/kafka-init:latest
68+
value: strimzi/operator:latest
6769
- name: STRIMZI_LOG_LEVEL
6870
value: INFO
6971
livenessProbe:

kafka-init/Dockerfile

-10
This file was deleted.

kafka-init/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
PROJECT_NAME=kafka-init
22

33
docker_build: java_build
4+
5+
docker_tag:
6+
7+
docker_push:
8+
49
all: docker_build docker_push
510
clean: java_clean
611

7-
include ../Makefile.docker
8-
912
include ../Makefile.maven
1013

1114
.PHONY: build clean release

0 commit comments

Comments
 (0)