Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 23 additions & 10 deletions dev-support/jenkins/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,29 @@
FROM hadolint/hadolint:latest-debian as hadolint

FROM maven:3.8-jdk-8

# hadolint ignore=DL3008
RUN apt-get -q update && apt-get -q install --no-install-recommends -y \
binutils \
git \
rsync \
shellcheck \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=SC1091
RUN install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
&& chmod a+r /etc/apt/keyrings/docker.gpg \
&& echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get -q update \
&& apt-get -q install --no-install-recommends -y \
binutils=* \
ca-certificates=* \
curl=* \
docker-buildx-plugin=* \
docker-ce-cli=* \
git=* \
gnupg=* \
rsync=* \
shellcheck=* \
wget=* \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=hadolint /bin/hadolint /bin/hadolint

Expand Down
4 changes: 3 additions & 1 deletion dev-support/jenkins/jenkins_precommit_github_yetus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ YETUS_ARGS+=("--tests-filter=test4tests")
# Dockerfile since we don't want to use the auto-pulled version.
YETUS_ARGS+=("--docker")
YETUS_ARGS+=("--dockerfile=${DOCKERFILE}")
# enabled docker-in-docker so that we can build container images
YETUS_ARGS+=("--dockerind=true")
YETUS_ARGS+=("--mvn-custom-repos")
YETUS_ARGS+=("--java-home=${SET_JAVA_HOME}")
# effectively treat dev-support as a custom maven module
Expand All @@ -127,4 +129,4 @@ YETUS_ARGS+=("--proclimit=5000")
echo "Launching yetus with command line:"
echo "${TESTPATCHBIN} ${YETUS_ARGS[*]}"

/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!--
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.
-->

# hbase-kubernetes-testing-image

This directory builds a docker image containing everything required to run `kubectl-kuttl` in
"mocked control plane" mode. This image is used as the basis for both dev and test environments.

## Build

Building the docker image locally is a little picky because there's lots of input arguments. These
are managed via the [docker-bake.override.hcl](./src/main/docker/docker-bake.override.hcl).

Start by creating a buildx context that supports (optionally) multi-platform images. If you've
created this context previously, it's enough to ensure that it's active via `docker buildx ls`.

```shell
$ docker buildx create \
--driver docker-container \
--platform linux/amd64,linux/arm64 \
--use \
--bootstrap
```

Finally, build the image using `maven package`, or manually, using,

```shell
$ docker buildx bake \
--file src/main/docker/docker-bake.hcl \
--file src/main/docker/docker-bake.override.hcl \
--pull \
--load
```

This exports an image to your local repository that is tagged as `${USER}/hbase/operator-tools/kuttl:latest`.

## Usage

The image is configured with `kuttle` as the entrypoint.

```shell
$ docker container run --rm -it ${USER}/hbase/operator-tools/kuttl:latest --help

```

Running tests in the image requires mounting the workspace into the container image and passing
appropriate parameters to `kuttl`. For example, run the "small" tests like this:

```shell
$ docker container run \
--mount type=bind,source=$(pwd),target=/workspace \
--workdir /workspace \
${USER}/hbase/operator-tools/kuttl:latest \
--config tests/kuttl-test-small.yaml
```
126 changes: 126 additions & 0 deletions hbase-kubernetes-deployment/hbase-kubernetes-testing-image/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
/**
* 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.
*/
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>hbase-kubernetes-deployment</artifactId>
<groupId>org.apache.hbase.operator.tools</groupId>
<version>${revision}</version>
<relativePath>..</relativePath>
</parent>

<artifactId>hbase-kubernetes-testing-image</artifactId>
<name>Apache HBase - Kubernetes Testing Image</name>
<description>A container image to facilitate testing of Kubernetes Deployment.</description>
<packaging>pom</packaging>

<properties>
<container_image.platforms>linux/amd64</container_image.platforms>
</properties>

<dependencies />

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best alternative I can find to using exec:exec is the docker-maven-plugin. It has some nice features but ultimately also requires having docker installed on the build host and makes it more difficult to execute the image build from native docker tools.

<configuration>
<useMavenLogger>true</useMavenLogger>
</configuration>
<executions>
<execution>
<id>docker-buildx-bake-print</id>
<goals>
<goal>exec</goal>
</goals>
<phase>package</phase>
<configuration>
<executable>/usr/bin/env</executable>
<arguments>
<argument>sh</argument>
<argument>-c</argument>
<argument>
2>&amp;1 \
docker buildx bake \
--print \
--file src/main/docker/docker-bake.hcl \
--file src/main/docker/docker-bake.override.hcl
</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>docker-buildx-bake</id>
<goals>
<goal>exec</goal>
</goals>
<phase>package</phase>
<configuration>
<executable>/usr/bin/env</executable>
<arguments>
<argument>sh</argument>
<argument>-c</argument>
<argument>
2>&amp;1 \
docker buildx bake \
--progress plain \
--pull \
--load \
--set *.platform=${container_image.platforms} \
--file src/main/docker/docker-bake.hcl \
--file src/main/docker/docker-bake.override.hcl
</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>amd64</id>
<activation>
<os>
<arch>x86_64</arch>
</os>
</activation>
<properties>
<container_image.platforms>linux/amd64</container_image.platforms>
</properties>
</profile>
<profile>
<id>arm64</id>
<activation>
<os>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<container_image.platforms>linux/arm64</container_image.platforms>
</properties>
</profile>
</profiles>
</project>
Loading