From 41ed0e1234177c7c24689f00e2a10af5c665fd07 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 15 Mar 2023 21:50:53 -0400 Subject: [PATCH] Add an image for kubectl Signed-off-by: Davanum Srinivas --- build/common.sh | 2 ++ build/server-image/kubectl/Dockerfile | 23 +++++++++++++++++++++++ hack/lib/golang.sh | 1 + 3 files changed, 26 insertions(+) create mode 100644 build/server-image/kubectl/Dockerfile diff --git a/build/common.sh b/build/common.sh index 4022ce924b8..fa650b81be0 100755 --- a/build/common.sh +++ b/build/common.sh @@ -105,6 +105,7 @@ readonly KUBE_APISERVER_BASE_IMAGE="${KUBE_APISERVER_BASE_IMAGE:-$KUBE_GORUNNER_ readonly KUBE_CONTROLLER_MANAGER_BASE_IMAGE="${KUBE_CONTROLLER_MANAGER_BASE_IMAGE:-$KUBE_GORUNNER_IMAGE}" readonly KUBE_SCHEDULER_BASE_IMAGE="${KUBE_SCHEDULER_BASE_IMAGE:-$KUBE_GORUNNER_IMAGE}" readonly KUBE_PROXY_BASE_IMAGE="${KUBE_PROXY_BASE_IMAGE:-$KUBE_BASE_IMAGE_REGISTRY/distroless-iptables:$__default_distroless_iptables_version}" +readonly KUBECTL_BASE_IMAGE="${KUBECTL_BASE_IMAGE:-$KUBE_GORUNNER_IMAGE}" # This is the image used in a multi-stage build to apply capabilities to Docker-wrapped binaries. readonly KUBE_BUILD_SETCAP_IMAGE="${KUBE_BUILD_SETCAP_IMAGE:-$KUBE_BASE_IMAGE_REGISTRY/setcap:$__default_setcap_version}" @@ -124,6 +125,7 @@ kube::build::get_docker_wrapped_binaries() { "kube-controller-manager,${KUBE_CONTROLLER_MANAGER_BASE_IMAGE}" "kube-scheduler,${KUBE_SCHEDULER_BASE_IMAGE}" "kube-proxy,${KUBE_PROXY_BASE_IMAGE}" + "kubectl,${KUBECTL_BASE_IMAGE}" ) echo "${targets[@]}" diff --git a/build/server-image/kubectl/Dockerfile b/build/server-image/kubectl/Dockerfile new file mode 100644 index 00000000000..0c93ca6a4e1 --- /dev/null +++ b/build/server-image/kubectl/Dockerfile @@ -0,0 +1,23 @@ +# Copyright 2023 The Kubernetes Authors. +# +# Licensed 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. + +# Dockerfile used for the kubectl image. + +ARG BASEIMAGE +ARG BINARY + + +FROM "${BASEIMAGE}" +COPY ${BINARY} /bin/ +ENTRYPOINT ["/bin/kubectl"] diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index d7fccf1211c..223e78dc3bf 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -95,6 +95,7 @@ kube::golang::server_image_targets() { cmd/kube-controller-manager cmd/kube-scheduler cmd/kube-proxy + cmd/kubectl ) echo "${targets[@]}" }