-
Notifications
You must be signed in to change notification settings - Fork 2
HBASE-27829 Introduce build for kuttl image, basis for dev/test environment #3
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # 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. | ||
|
|
||
| [codespell] | ||
| skip = LICENSE.txt |
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,18 @@ | ||
| # 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. | ||
| --- | ||
| MD013: | ||
| line_length: 100 |
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,21 @@ | ||
| # 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. | ||
| --- | ||
| extends: default | ||
|
|
||
| rules: | ||
| line-length: | ||
| max: 100 |
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,161 @@ | ||
| # syntax=docker/dockerfile:1.4 | ||
| # | ||
| # 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. | ||
|
|
||
| # hadolint global ignore=DL3020 | ||
|
|
||
| ARG IMG_BASE='golang' | ||
| ARG IMG_BASE_TAG='1.19-alpine' | ||
| ARG BASE_IMG_ALPINE='alpine' | ||
| ARG BASE_IMG_TAG_ALPINE='latest' | ||
| ARG YQ_IMG='mikefarah/yq' | ||
| ARG YQ_IMG_TAG='latest' | ||
|
|
||
| FROM ${BASE_IMG_ALPINE}:${BASE_IMG_TAG_ALPINE} as alpine | ||
| RUN apk add --no-cache bash~=5 | ||
|
|
||
| FROM ${YQ_IMG}:${YQ_IMG_TAG} as yq | ||
|
|
||
| ## -- Stages kubectl_${TARGETARCH} -- | ||
| # Define stages that facilitate bringing in platform-specific binaries. | ||
| FROM alpine as kubectl_amd64 | ||
| ARG KUBECTL_SHA_AMD64_URL | ||
| ARG KUBECTL_SHA_AMD64 | ||
| ARG KUBECTL_BIN_AMD64_URL | ||
| ARG KUBECTL_BIN_AMD64 | ||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
| WORKDIR /tmp | ||
| ADD --link ${KUBECTL_SHA_AMD64_URL} /tmp/ | ||
| ADD --link ${KUBECTL_BIN_AMD64_URL} /tmp/ | ||
| RUN echo "$(cat "${KUBECTL_SHA_AMD64}") ${KUBECTL_BIN_AMD64}" | sha512sum -c | ||
| ENV KUBECTL_BIN "${KUBECTL_BIN_AMD64}" | ||
|
|
||
| FROM alpine as kubectl_arm64 | ||
| ARG KUBECTL_SHA_ARM64_URL | ||
| ARG KUBECTL_SHA_ARM64 | ||
| ARG KUBECTL_BIN_ARM64_URL | ||
| ARG KUBECTL_BIN_ARM64 | ||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
| WORKDIR /tmp | ||
| ADD --link ${KUBECTL_SHA_ARM64_URL} /tmp/ | ||
| ADD --link ${KUBECTL_BIN_ARM64_URL} /tmp/ | ||
| RUN echo "$(cat "${KUBECTL_SHA_ARM64}") ${KUBECTL_BIN_ARM64}" | sha512sum -c | ||
| ENV KUBECTL_BIN "${KUBECTL_BIN_ARM64}" | ||
|
|
||
| ARG TARGETARCH | ||
| # hadolint ignore=DL3006 | ||
| FROM kubectl_${TARGETARCH} as kubectl | ||
| RUN mv "/tmp/${KUBECTL_BIN}" /tmp/kubectl \ | ||
| && chmod a+x /tmp/kubectl | ||
|
|
||
| ## -- Stages kuttl_${TARGETARCH} -- | ||
| # Define stages that facilitate bringing in platform-specific binaries. | ||
| FROM alpine as kuttl_amd64 | ||
| ARG KUTTL_CHECKSUMS_URL | ||
| ARG KUTTL_CHECKSUMS | ||
| ARG KUTTL_BIN_AMD64_URL | ||
| ARG KUTTL_BIN_AMD64 | ||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
| WORKDIR /tmp | ||
| ADD --link ${KUTTL_CHECKSUMS_URL} /tmp/ | ||
| ADD --link ${KUTTL_BIN_AMD64_URL} /tmp/ | ||
| RUN sha256sum -c <(grep "${KUTTL_BIN_AMD64}" "${KUTTL_CHECKSUMS}") | ||
| ENV KUTTL_BIN "${KUTTL_BIN_AMD64}" | ||
|
|
||
| FROM alpine as kuttl_arm64 | ||
| ARG KUTTL_CHECKSUMS_URL | ||
| ARG KUTTL_CHECKSUMS | ||
| ARG KUTTL_BIN_ARM64_URL | ||
| ARG KUTTL_BIN_ARM64 | ||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
| WORKDIR /tmp | ||
| ADD --link ${KUTTL_CHECKSUMS_URL} /tmp/ | ||
| ADD --link ${KUTTL_BIN_ARM64_URL} /tmp/ | ||
| RUN sha256sum -c <(grep "${KUTTL_BIN_ARM64}" "${KUTTL_CHECKSUMS}") | ||
| ENV KUTTL_BIN "${KUTTL_BIN_ARM64}" | ||
|
|
||
| ARG TARGETARCH | ||
| # hadolint ignore=DL3006 | ||
| FROM kuttl_${TARGETARCH} as kuttl | ||
| RUN mv "/tmp/${KUTTL_BIN}" /tmp/kubectl-kuttl \ | ||
| && chmod a+x /tmp/kubectl-kuttl | ||
|
|
||
| ## -- Stages kustomize_${TARGETARCH} -- | ||
| # Define stages that facilitate bringing in platform-specific binaries. | ||
| FROM alpine as kustomize_amd64 | ||
| ARG KUSTOMIZE_CHECKSUMS_URL | ||
| ARG KUSTOMIZE_CHECKSUMS | ||
| ARG KUSTOMIZE_BIN_AMD64_TGZ_URL | ||
| ARG KUSTOMIZE_BIN_AMD64_TGZ | ||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
| WORKDIR /tmp | ||
| ADD --link ${KUSTOMIZE_CHECKSUMS_URL} /tmp/ | ||
| ADD --link ${KUSTOMIZE_BIN_AMD64_TGZ_URL} /tmp/ | ||
| RUN sha256sum -c <(grep "${KUSTOMIZE_BIN_AMD64_TGZ}" "${KUSTOMIZE_CHECKSUMS}") | ||
| ENV KUSTOMIZE_BIN_TGZ "${KUSTOMIZE_BIN_AMD64_TGZ}" | ||
|
|
||
| FROM alpine as kustomize_arm64 | ||
| ARG KUSTOMIZE_CHECKSUMS_URL | ||
| ARG KUSTOMIZE_CHECKSUMS | ||
| ARG KUSTOMIZE_BIN_ARM64_TGZ_URL | ||
| ARG KUSTOMIZE_BIN_ARM64_TGZ | ||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
| WORKDIR /tmp | ||
| ADD --link ${KUSTOMIZE_CHECKSUMS_URL} /tmp/ | ||
| ADD --link ${KUSTOMIZE_BIN_ARM64_TGZ_URL} /tmp/ | ||
| RUN sha256sum -c <(grep "${KUSTOMIZE_BIN_ARM64_TGZ}" "${KUSTOMIZE_CHECKSUMS}") | ||
| ENV KUSTOMIZE_BIN_TGZ "${KUSTOMIZE_BIN_ARM64_TGZ}" | ||
|
|
||
| ARG TARGETARCH | ||
| # hadolint ignore=DL3006 | ||
| FROM kustomize_${TARGETARCH} as kustomize | ||
| RUN tar xzf "/tmp/${KUSTOMIZE_BIN_TGZ}" \ | ||
| && chmod a+x /tmp/kustomize | ||
|
|
||
| FROM ${IMG_BASE}:${IMG_BASE_TAG} as final | ||
| ARG IMG_BASE | ||
| ARG IMG_BASE_TAG | ||
|
|
||
| COPY --from=yq /usr/bin/yq /usr/bin/yq | ||
| COPY --from=kubectl /tmp/kubectl /usr/local/bin/ | ||
| COPY --from=kuttl /tmp/kubectl-kuttl /usr/local/bin/ | ||
| COPY --from=kustomize /tmp/kustomize /usr/local/bin/ | ||
| COPY dockerfiles/kuttl/entrypoint.sh /bin/ | ||
|
|
||
| # nonroot user as defined in https://github.com/GoogleContainerTools/distroless | ||
| ENV NON_ROOT_USER=nonroot | ||
| ENV NON_ROOT_USER_ID=65532 | ||
| ENV NON_ROOT_USER_HOME=/home/nonroot | ||
|
|
||
| # hadolint ignore=DL3018 | ||
| RUN apk add --update --no-cache \ | ||
| bash~=5 \ | ||
| docker-cli \ | ||
| && adduser -D -u "${NON_ROOT_USER_ID}" -h "${NON_ROOT_USER_HOME}" "${NON_ROOT_USER}" | ||
|
|
||
| # replicate the test-related bits generated by `kubebuilder` into its Makefile. | ||
| ENV GOBIN="${GOPATH}/bin" | ||
| ENV ENVTEST_K8S_VERSION='1.23.x' | ||
| RUN chmod a+x /bin/entrypoint.sh \ | ||
| && go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
| WORKDIR "${NON_ROOT_USER_HOME}" | ||
| USER "${NON_ROOT_USER}" | ||
| RUN "${GOBIN}/setup-envtest" use "${ENVTEST_K8S_VERSION}" | ||
| # disable downloading remote content henceforth | ||
| ENV ENVTEST_INSTALLED_ONLY=true | ||
|
|
||
| ENTRYPOINT ["/bin/entrypoint.sh"] |
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,71 @@ | ||
| <!-- | ||
| 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. | ||
| --> | ||
|
|
||
| # dockerfiles/kuttl | ||
|
|
||
| This directory builds a docker image containing everything required to run `kubectl-kuttl`. It | ||
| includes all the dependencies to run in "mocked control plane" mode as well as targeting a full | ||
| cluster. 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](./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: | ||
|
|
||
| ```shell | ||
| docker buildx bake \ | ||
| --file src/main/docker/docker-bake.hcl \ | ||
| --file src/main/docker/docker-bake.override.hcl \ | ||
| --pull \ | ||
| --load \ | ||
| --set '*.platform=linux/arm64' | ||
| ``` | ||
|
|
||
| This exports an image to your local repository that is tagged as `${USER}/hbase/kustomize/kuttl:latest`. | ||
|
|
||
| ## Usage | ||
|
|
||
| The image is configured with `kuttl` as the entrypoint. | ||
|
|
||
| ```shell | ||
| docker container run --rm -it ${USER}/hbase/kustomize/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/kustomize/kuttl:latest \ | ||
| --config tests/kuttl-test-small.yaml | ||
| ``` | ||
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.