mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
add an option to push/pull component images from a registry using kube-up
This commit is contained in:
@@ -344,8 +344,8 @@ function find-release-version() {
|
||||
if [[ -f "${KUBE_ROOT}/version" ]]; then
|
||||
KUBE_GIT_VERSION="$(cat ${KUBE_ROOT}/version)"
|
||||
fi
|
||||
if [[ -f "${KUBE_ROOT}/_output/full/kubernetes/version" ]]; then
|
||||
KUBE_GIT_VERSION="$(cat ${KUBE_ROOT}/_output/full/kubernetes/version)"
|
||||
if [[ -f "${KUBE_ROOT}/_output/release-stage/full/kubernetes/version" ]]; then
|
||||
KUBE_GIT_VERSION="$(cat ${KUBE_ROOT}/_output/release-stage/full/kubernetes/version)"
|
||||
fi
|
||||
|
||||
if [[ -z "${KUBE_GIT_VERSION}" ]]; then
|
||||
@@ -353,3 +353,44 @@ function find-release-version() {
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function stage-images() {
|
||||
find-release-version
|
||||
find-release-tars
|
||||
|
||||
KUBE_IMAGE_TAG="$(echo """${KUBE_GIT_VERSION}""" | sed 's/+/-/g')"
|
||||
|
||||
local docker_wrapped_binaries=(
|
||||
"kube-apiserver"
|
||||
"kube-controller-manager"
|
||||
"kube-scheduler"
|
||||
"kube-proxy"
|
||||
)
|
||||
|
||||
local docker_cmd=("docker")
|
||||
|
||||
if [[ "${KUBE_DOCKER_REGISTRY}" == "gcr.io/"* ]]; then
|
||||
local docker_push_cmd=("gcloud" "docker")
|
||||
fi
|
||||
|
||||
local temp_dir="$(mktemp -d -t 'kube-server-XXXX')"
|
||||
|
||||
tar xzfv "${SERVER_BINARY_TAR}" -C "${temp_dir}" &> /dev/null
|
||||
|
||||
for binary in "${docker_wrapped_binaries[@]}"; do
|
||||
local docker_tag="$(cat ${temp_dir}/kubernetes/server/bin/${binary}.docker_tag)"
|
||||
(
|
||||
"${docker_cmd[@]}" load -i "${temp_dir}/kubernetes/server/bin/${binary}.tar"
|
||||
"${docker_cmd[@]}" tag -f "gcr.io/google_containers/${binary}:${docker_tag}" "${KUBE_DOCKER_REGISTRY}/${binary}:${KUBE_IMAGE_TAG}"
|
||||
"${docker_push_cmd[@]}" push "${KUBE_DOCKER_REGISTRY}/${binary}:${KUBE_IMAGE_TAG}"
|
||||
) &> "${temp_dir}/${binary}-push.log" &
|
||||
done
|
||||
|
||||
kube::util::wait-for-jobs || {
|
||||
kube::log::error "unable to push images. see ${temp_dir}/*.log for more info."
|
||||
return 1
|
||||
}
|
||||
|
||||
rm -rf "${temp_dir}"
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user