Skip to content

Commit da79d43

Browse files
committed
HBASE-27829 Introduce build for kuttl image, basis for dev/test environment
Drive kuttl image build from maven. Use maven exec plugin to call `docker buildx bake` as part of the module `package` phase. Allow it all to run from within Docker-in-Docker via Yetus.
1 parent f521479 commit da79d43

File tree

10 files changed

+670
-44
lines changed

10 files changed

+670
-44
lines changed

dev-support/jenkins/Dockerfile

+23-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,29 @@
2020
FROM hadolint/hadolint:latest-debian as hadolint
2121

2222
FROM maven:3.8-jdk-8
23-
24-
# hadolint ignore=DL3008
25-
RUN apt-get -q update && apt-get -q install --no-install-recommends -y \
26-
binutils \
27-
git \
28-
rsync \
29-
shellcheck \
30-
wget && \
31-
apt-get clean && \
32-
rm -rf /var/lib/apt/lists/*
23+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
24+
# hadolint ignore=SC1091
25+
RUN install -m 0755 -d /etc/apt/keyrings \
26+
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
27+
&& chmod a+r /etc/apt/keyrings/docker.gpg \
28+
&& echo \
29+
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
30+
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
31+
tee /etc/apt/sources.list.d/docker.list > /dev/null \
32+
&& apt-get -q update \
33+
&& apt-get -q install --no-install-recommends -y \
34+
binutils=* \
35+
ca-certificates=* \
36+
curl=* \
37+
docker-buildx-plugin=* \
38+
docker-ce-cli=* \
39+
git=* \
40+
gnupg=* \
41+
rsync=* \
42+
shellcheck=* \
43+
wget=* \
44+
&& apt-get clean \
45+
&& rm -rf /var/lib/apt/lists/*
3346

3447
COPY --from=hadolint /bin/hadolint /bin/hadolint
3548

dev-support/jenkins/jenkins_precommit_github_yetus.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ YETUS_ARGS+=("--tests-filter=test4tests")
111111
# Dockerfile since we don't want to use the auto-pulled version.
112112
YETUS_ARGS+=("--docker")
113113
YETUS_ARGS+=("--dockerfile=${DOCKERFILE}")
114+
# enabled docker-in-docker so that we can build container images
115+
YETUS_ARGS+=("--dockerind=true")
114116
YETUS_ARGS+=("--mvn-custom-repos")
115117
YETUS_ARGS+=("--java-home=${SET_JAVA_HOME}")
116118
# effectively treat dev-support as a custom maven module
@@ -127,4 +129,4 @@ YETUS_ARGS+=("--proclimit=5000")
127129
echo "Launching yetus with command line:"
128130
echo "${TESTPATCHBIN} ${YETUS_ARGS[*]}"
129131

130-
/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
132+
/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
# hbase-kubernetes-testing-image
20+
21+
This directory builds a docker image containing everything required to run `kubectl-kuttl` in
22+
"mocked control plane" mode. This image is used as the basis for both dev and test environments.
23+
24+
## Build
25+
26+
Building the docker image locally is a little picky because there's lots of input arguments. These
27+
are managed via the [docker-bake.override.hcl](./src/main/docker/docker-bake.override.hcl).
28+
29+
Start by creating a buildx context that supports (optionally) multi-platform images. If you've
30+
created this context previously, it's enough to ensure that it's active via `docker buildx ls`.
31+
32+
```shell
33+
$ docker buildx create \
34+
--driver docker-container \
35+
--platform linux/amd64,linux/arm64 \
36+
--use \
37+
--bootstrap
38+
```
39+
40+
Finally, build the image using `maven package`, or manually, using,
41+
42+
```shell
43+
$ docker buildx bake \
44+
--file src/main/docker/docker-bake.hcl \
45+
--file src/main/docker/docker-bake.override.hcl \
46+
--pull \
47+
--load
48+
```
49+
50+
This exports an image to your local repository that is tagged as `${USER}/hbase/operator-tools/kuttl:latest`.
51+
52+
## Usage
53+
54+
The image is configured with `kuttle` as the entrypoint.
55+
56+
```shell
57+
$ docker container run --rm -it ${USER}/hbase/operator-tools/kuttl:latest --help
58+
59+
```
60+
61+
Running tests in the image requires mounting the workspace into the container image and passing
62+
appropriate parameters to `kuttl`. For example, run the "small" tests like this:
63+
64+
```shell
65+
$ docker container run \
66+
--mount type=bind,source=$(pwd),target=/workspace \
67+
--workdir /workspace \
68+
${USER}/hbase/operator-tools/kuttl:latest \
69+
--config tests/kuttl-test-small.yaml
70+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<!--
6+
/**
7+
* Licensed to the Apache Software Foundation (ASF) under one
8+
* or more contributor license agreements. See the NOTICE file
9+
* distributed with this work for additional information
10+
* regarding copyright ownership. The ASF licenses this file
11+
* to you under the Apache License, Version 2.0 (the
12+
* "License"); you may not use this file except in compliance
13+
* with the License. You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*/
23+
-->
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<artifactId>hbase-kubernetes-deployment</artifactId>
27+
<groupId>org.apache.hbase.operator.tools</groupId>
28+
<version>${revision}</version>
29+
<relativePath>..</relativePath>
30+
</parent>
31+
32+
<artifactId>hbase-kubernetes-testing-image</artifactId>
33+
<name>Apache HBase - Kubernetes Testing Image</name>
34+
<description>A container image to facilitate testing of Kubernetes Deployment.</description>
35+
<packaging>pom</packaging>
36+
37+
<properties>
38+
<container_image.platforms>linux/amd64</container_image.platforms>
39+
</properties>
40+
41+
<dependencies />
42+
43+
<build>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.codehaus.mojo</groupId>
47+
<artifactId>exec-maven-plugin</artifactId>
48+
<configuration>
49+
<useMavenLogger>true</useMavenLogger>
50+
</configuration>
51+
<executions>
52+
<execution>
53+
<id>docker-buildx-bake-print</id>
54+
<goals>
55+
<goal>exec</goal>
56+
</goals>
57+
<phase>package</phase>
58+
<configuration>
59+
<executable>/usr/bin/env</executable>
60+
<arguments>
61+
<argument>sh</argument>
62+
<argument>-c</argument>
63+
<argument>
64+
2>&amp;1 \
65+
docker buildx bake \
66+
--print \
67+
--file src/main/docker/docker-bake.hcl \
68+
--file src/main/docker/docker-bake.override.hcl
69+
</argument>
70+
</arguments>
71+
</configuration>
72+
</execution>
73+
<execution>
74+
<id>docker-buildx-bake</id>
75+
<goals>
76+
<goal>exec</goal>
77+
</goals>
78+
<phase>package</phase>
79+
<configuration>
80+
<executable>/usr/bin/env</executable>
81+
<arguments>
82+
<argument>sh</argument>
83+
<argument>-c</argument>
84+
<argument>
85+
2>&amp;1 \
86+
docker buildx bake \
87+
--progress plain \
88+
--pull \
89+
--load \
90+
--set *.platform=${container_image.platforms} \
91+
--file src/main/docker/docker-bake.hcl \
92+
--file src/main/docker/docker-bake.override.hcl
93+
</argument>
94+
</arguments>
95+
</configuration>
96+
</execution>
97+
</executions>
98+
</plugin>
99+
</plugins>
100+
</build>
101+
102+
<profiles>
103+
<profile>
104+
<id>amd64</id>
105+
<activation>
106+
<os>
107+
<arch>x86_64</arch>
108+
</os>
109+
</activation>
110+
<properties>
111+
<container_image.platforms>linux/amd64</container_image.platforms>
112+
</properties>
113+
</profile>
114+
<profile>
115+
<id>arm64</id>
116+
<activation>
117+
<os>
118+
<arch>aarch64</arch>
119+
</os>
120+
</activation>
121+
<properties>
122+
<container_image.platforms>linux/arm64</container_image.platforms>
123+
</properties>
124+
</profile>
125+
</profiles>
126+
</project>

0 commit comments

Comments
 (0)