Merge pull request #20398 from mfanjie/mfanjie-patch-1

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-02-09 22:55:18 -08:00
commit fc3316ee1b
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

@ -22,6 +22,10 @@ MAINTAINER Joe Beda <jbeda@google.com>
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

@ -189,7 +189,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}"
@ -233,6 +237,18 @@ function kube::build::is_osx() {
[[ "$(uname)" == "Darwin" ]]
}
function kube::build::update_dockerfile() {
if kube::build::is_osx; then
sed_opts=("-i ''")
else
sed_opts=(-i)
fi
sed ${sed_opts[@]} "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" ${build_context_dir}/Dockerfile
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTP_PROXY#${KUBE_BUILD_HTTP_PROXY:-\"\"}#" ${build_context_dir}/Dockerfile
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTPS_PROXY#${KUBE_BUILD_HTTPS_PROXY:-\"\"}#" ${build_context_dir}/Dockerfile
sed ${sed_opts[@]} "s#KUBE_BUILD_NO_PROXY#${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."
@ -502,11 +518,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'