update proxy settings for kubernetes build.

This commit is contained in:
fmeng 2016-02-04 17:38:07 +08:00
parent 9d9864486b
commit ef42dad78e
3 changed files with 33 additions and 14 deletions

View File

@ -73,17 +73,19 @@ When building final release tars, they are first staged into `_output/release-st
## Proxy Settings
If you are behind a proxy, you need to edit `build/build-image/Dockerfile` and add proxy settings to execute command in that container correctly.
If you are behind a proxy, you need to export proxy settings for kubernetes build, the following environment variables should be defined.
example:
```
export KUBE_BUILD_HTTP_PROXY=http://username:password@proxyaddr:proxyport
export KUBE_BUILD_HTTPS_PROXY=http://username:password@proxyaddr:proxyport
```
`ENV http_proxy http://username:password@proxyaddr:proxyport`
Optionally, you can specify addresses of no proxy for kubernetes build, for example
`ENV https_proxy http://username:password@proxyaddr:proxyport`
Besides, to avoid integration test touch the proxy while connecting to local etcd service, you need to set
`ENV no_proxy 127.0.0.1`
```
export KUBE_BUILD_NO_PROXY=127.0.0.1
```
If you are using sudo to make kubernetes build for example make quick-release, you need run `sudo -E make quick-release` to pass the environment variables.
## TODOs

View File

@ -24,6 +24,10 @@ MAINTAINER Joe Beda <jbeda@google.com>
ENV GOARM 5
ENV GOOS linux
ENV GOARCH amd64
ENV http_proxy KUBE_BUILD_HTTP_PROXY
ENV https_proxy KUBE_BUILD_HTTPS_PROXY
ENV no_proxy KUBE_BUILD_NO_PROXY
# work around 64MB tmpfs size in Docker 1.6
ENV TMPDIR /tmp.k8s

View File

@ -159,7 +159,11 @@ function kube::build::prepare_docker_machine() {
kube::log::status "docker-machine was found."
docker-machine inspect "${DOCKER_MACHINE_NAME}" >/dev/null || {
kube::log::status "Creating a machine to build Kubernetes"
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" "${DOCKER_MACHINE_NAME}" > /dev/null || {
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \
--engine-env HTTP_PROXY="${KUBE_BUILD_HTTP_PROXY:-}" \
--engine-env HTTPS_PROXY="${KUBE_BUILD_HTTPS_PROXY:-}" \
--engine-env NO_PROXY="${KUBE_BUILD_NO_PROXY:-127.0.0.1}" \
"${DOCKER_MACHINE_NAME}" > /dev/null || {
kube::log::error "Something went wrong creating a machine."
kube::log::error "Try the following: "
kube::log::error "docker-machine create -d ${DOCKER_MACHINE_DRIVER} ${DOCKER_MACHINE_NAME}"
@ -203,6 +207,18 @@ function kube::build::is_osx() {
[[ "$(uname)" == "Darwin" ]]
}
function kube::build::update_dockerfile() {
if kube::build::is_osx; then
sed_arg=\"\"
else
sed_arg=""
fi
sed -i $sed_arg "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" ${build_context_dir}/Dockerfile
sed -i $sed_arg "s#KUBE_BUILD_HTTP_PROXY#"`echo ${KUBE_BUILD_HTTP_PROXY:-\"\"}`"#" ${build_context_dir}/Dockerfile
sed -i $sed_arg "s#KUBE_BUILD_HTTPS_PROXY#"`echo ${KUBE_BUILD_HTTPS_PROXY:-\"\"}`"#" ${build_context_dir}/Dockerfile
sed -i $sed_arg "s#KUBE_BUILD_NO_PROXY#"`echo ${KUBE_BUILD_NO_PROXY:-127.0.0.1}`"#" ${build_context_dir}/Dockerfile
}
function kube::build::ensure_docker_in_path() {
if [[ -z "$(which docker)" ]]; then
kube::log::error "Can't find 'docker' in PATH, please fix and retry."
@ -472,11 +488,8 @@ function kube::build::build_image() {
kube::version::save_version_vars "${build_context_dir}/kube-version-defs"
cp build/build-image/Dockerfile ${build_context_dir}/Dockerfile
if kube::build::is_osx; then
sed -i "" "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" ${build_context_dir}/Dockerfile
else
sed -i "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" ${build_context_dir}/Dockerfile
fi
kube::build::update_dockerfile
# We don't want to force-pull this image because it's based on a local image
# (see kube::build::build_image_cross), not upstream.
kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${build_context_dir}" 'false'