This is an automated email from the ASF dual-hosted git repository. ndimiduk pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/hbase-kustomize.git
The following commit(s) were added to refs/heads/main by this push: new 72960a6 HBASE-27846 Introduce hadoop image (#6) 72960a6 is described below commit 72960a658811c0d195a1f2603f0f11ab33cb058e Author: Nick Dimiduk <ndimi...@apache.org> AuthorDate: Tue Jan 2 08:51:38 2024 +0100 HBASE-27846 Introduce hadoop image (#6) Signed-off-by: Peter Somogyi <psomo...@apache.org> --- dockerfiles/hadoop/Dockerfile | 65 ++++++++++++++++++++++++++ dockerfiles/hadoop/README.md | 56 +++++++++++++++++++++++ dockerfiles/hadoop/docker-bake.hcl | 71 +++++++++++++++++++++++++++++ dockerfiles/hadoop/docker-bake.override.hcl | 47 +++++++++++++++++++ dockerfiles/hadoop/test/test.bats | 27 +++++++++++ 5 files changed, 266 insertions(+) diff --git a/dockerfiles/hadoop/Dockerfile b/dockerfiles/hadoop/Dockerfile new file mode 100644 index 0000000..0d38bfe --- /dev/null +++ b/dockerfiles/hadoop/Dockerfile @@ -0,0 +1,65 @@ +# 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 BASE_IMG='apache/hadoop' +ARG BASE_TAG='3' +ARG BASE_IMG_ALPINE='alpine' +ARG BASE_IMG_TAG_ALPINE='latest' + +FROM ${BASE_IMG_ALPINE}:${BASE_IMG_TAG_ALPINE} as alpine + +## -- Stage installed_jmx_exporter -- +# A stage that prepares the JMX Exporter installation directory. The jar must be in well-known +# location so can refer to it in command yaml value. +FROM alpine AS installed_jmx_exporter +ARG JMX_PROMETHEUS_JAR_URL +ADD --link ${JMX_PROMETHEUS_JAR_URL} /tmp/jmx_prometheus_javaagent.jar + +FROM ${BASE_IMG}:${BASE_TAG} as final +ARG CORRETTO_KEY_URL +ARG CORRETTO_KEY +ARG CORRETTO_REPO_URL +ARG CORRETTO_REPO +USER root +ADD --link ${CORRETTO_KEY_URL} /tmp/ +ADD --link ${CORRETTO_REPO_URL} /etc/yum.repos.d/ + +RUN rpm --import "/tmp/${CORRETTO_KEY}" \ + && yum -y remove java-1.8.0-* \ + && yum -y update \ + && yum -y install java-17-amazon-corretto-devel \ + && yum -y clean all \ + && rm -rf /var/cache + +COPY --from=installed_jmx_exporter \ + --chown=hadoop:users \ + /tmp/jmx_prometheus_javaagent.jar /opt/hadoop/jmx_prometheus_javaagent.jar + +ENV JMX_PROMETHEUS_JAR /opt/hadoop/jmx_prometheus_javaagent.jar +ENV USER='hadoop' +USER ${USER} + +# verify the image basically works +FROM bats/bats:v1.10.0 as bats + +FROM final AS test +COPY --from=bats --chown=0755 /opt/bats ./bats +COPY dockerfiles/hadoop/test/* ./ +RUN ./bats/bin/bats *.bats diff --git a/dockerfiles/hadoop/README.md b/dockerfiles/hadoop/README.md new file mode 100644 index 0000000..06bc311 --- /dev/null +++ b/dockerfiles/hadoop/README.md @@ -0,0 +1,56 @@ +<!-- + 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/hadoop + +There is a contract that must be maintained between the container image run in the pod and the +infrastructure that launched the pod. Details like paths, users/groups, permissions, and +environment variables must align so that the deployment layer can pass runtime concerns down to +the container. + +Start with the official hadoop image and extend it from there. Note that `apache/hadoop:3` is only +published for `linux/amd64` at this time. + +## Build + +Input arguments are managed by [docker-bake.override.hcl](./docker-bake.override.hcl). + +Start by creating a buildx context that supports at least `linux/amd64` 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 dockerfiles/hadoop/docker-bake.hcl \ + --file dockerfiles/hadoop/docker-bake.override.hcl \ + --set '*.platform=linux/amd64' \ + --pull \ + --load +``` + +This exports an image to your local repository that is tagged as +`${USER}/hbase/kustomize/hadoop:latest`. diff --git a/dockerfiles/hadoop/docker-bake.hcl b/dockerfiles/hadoop/docker-bake.hcl new file mode 100644 index 0000000..98f620d --- /dev/null +++ b/dockerfiles/hadoop/docker-bake.hcl @@ -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. +# +# A convenience script for build the kuttl image. +# See hbase-kubernetes-deployment/dockerfiles/kuttl/README.md +# + +variable BASE_IMG { + default = "apache/hadoop" +} +variable BASE_TAG { + default = "3" +} +variable USER { + default = "apache" +} +variable IMAGE_TAG { + default = "latest" +} +variable IMAGE_NAME { + default = "${USER}/hbase/kustomize/hadoop" +} +variable CORRETTO_KEY_URL {} +variable CORRETTO_KEY {} +variable CORRETTO_REPO_URL {} +variable CORRETTO_REPO {} +variable JMX_PROMETHEUS_JAR_URL {} +variable JMX_PROMETHEUS_JAR {} + +group default { + targets = [ "hadoop", "hadoop-test" ] +} + +target hadoop { + dockerfile = "dockerfiles/hadoop/Dockerfile" + args = { + BASE_IMG = BASE_IMG + BASE_TAG = BASE_TAG + CORRETTO_KEY_URL = CORRETTO_KEY_URL + CORRETTO_KEY = CORRETTO_KEY + CORRETTO_REPO_URL = CORRETTO_REPO_URL + CORRETTO_REPO = CORRETTO_REPO + JMX_PROMETHEUS_JAR_URL = JMX_PROMETHEUS_JAR_URL + JMX_PROMETHEUS_JAR = JMX_PROMETHEUS_JAR + } + target = "final" + platforms = [ + # upstream image only provides linux/amd64 + "linux/amd64" + ] + tags = [ "${IMAGE_NAME}:${IMAGE_TAG}" ] +} + +target hadoop-test { + inherits = [ "hadoop" ] + target = "test" + tags = [] +} diff --git a/dockerfiles/hadoop/docker-bake.override.hcl b/dockerfiles/hadoop/docker-bake.override.hcl new file mode 100644 index 0000000..cbe27dd --- /dev/null +++ b/dockerfiles/hadoop/docker-bake.override.hcl @@ -0,0 +1,47 @@ +# 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. +# +# Externalize default values of build parameters and document how to retrieve them. +# + +function "basename" { + params = [a] + result = split("/", a)[length(split("/", a)) - 1] +} + +variable CORRETTO_KEY_URL { + default = "https://yum.corretto.aws/corretto.key" +} + +variable CORRETTO_KEY { + default = "${basename(CORRETTO_KEY_URL)}" +} + +variable CORRETTO_REPO_URL { + default = "https://yum.corretto.aws/corretto.repo" +} + +variable CORRETTO_REPO { + default = "${basename(CORRETTO_REPO_URL)}" +} + +variable JMX_PROMETHEUS_JAR_URL { + default = "https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.16.1/jmx_prometheus_javaagent-0.16.1.jar" +} + +variable JMX_PROMETHEUS_JAR { + default = "${basename(JMX_PROMETHEUS_JAR_URL)}" +} diff --git a/dockerfiles/hadoop/test/test.bats b/dockerfiles/hadoop/test/test.bats new file mode 100644 index 0000000..a24c12d --- /dev/null +++ b/dockerfiles/hadoop/test/test.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats +# 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. + +@test "hadoop command on path" { + hadoop version +} + +@test "hadoop checknative runs" { + hadoop checknative +} + +@test "hdfs command on path" { + hdfs datanode --help +}