Skip to content

Commit d433632

Browse files
author
mfanjie
committed
add proxy settings for vagrant
1 parent fea6b0d commit d433632

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Vagrantfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ $vm_master_mem = (ENV['KUBERNETES_MASTER_MEMORY'] || ENV['KUBERNETES_MEMORY'] ||
108108
$vm_node_mem = (ENV['KUBERNETES_NODE_MEMORY'] || ENV['KUBERNETES_MEMORY'] || 1024).to_i
109109

110110
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
111+
if Vagrant.has_plugin?("vagrant-proxyconf")
112+
$http_proxy = ENV['KUBERNETES_HTTP_PROXY'] || ""
113+
$https_proxy = ENV['KUBERNETES_HTTPS_PROXY'] || ""
114+
$no_proxy = ENV['KUBERNETES_NO_PROXY'] || "127.0.0.1"
115+
config.proxy.http = $http_proxy
116+
config.proxy.https = $https_proxy
117+
config.proxy.no_proxy = $no_proxy
118+
end
111119
def setvmboxandurl(config, provider)
112120
if ENV['KUBERNETES_BOX_NAME'] then
113121
config.vm.box = ENV['KUBERNETES_BOX_NAME']

build/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ When building final release tars, they are first staged into `_output/release-st
7676
If you are behind a proxy, you need to export proxy settings for kubernetes build, the following environment variables should be defined.
7777

7878
```
79-
export KUBE_BUILD_HTTP_PROXY=http://username:password@proxyaddr:proxyport
80-
export KUBE_BUILD_HTTPS_PROXY=http://username:password@proxyaddr:proxyport
79+
export KUBERNETES_HTTP_PROXY=http://username:password@proxyaddr:proxyport
80+
export KUBERNETES_HTTPS_PROXY=https://username:password@proxyaddr:proxyport
8181
```
8282

8383
Optionally, you can specify addresses of no proxy for kubernetes build, for example
8484

8585
```
86-
export KUBE_BUILD_NO_PROXY=127.0.0.1
86+
export KUBERNETES_NO_PROXY=127.0.0.1
8787
```
88+
8889
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.
8990

9091
## TODOs

build/build-image/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
# This file creates a standard build environment for building Kubernetes
1616
FROM gcr.io/google_containers/kube-cross:KUBE_BUILD_IMAGE_CROSS_TAG
1717

18-
ENV http_proxy=KUBE_BUILD_HTTP_PROXY \
19-
https_proxy=KUBE_BUILD_HTTPS_PROXY \
20-
no_proxy=KUBE_BUILD_NO_PROXY
21-
2218
# Mark this as a kube-build container
2319
RUN touch /kube-build-image
2420

build/common.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ function kube::build::prepare_docker_machine() {
193193
docker-machine inspect "${DOCKER_MACHINE_NAME}" >/dev/null || {
194194
kube::log::status "Creating a machine to build Kubernetes"
195195
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \
196-
--engine-env HTTP_PROXY="${KUBE_BUILD_HTTP_PROXY:-}" \
197-
--engine-env HTTPS_PROXY="${KUBE_BUILD_HTTPS_PROXY:-}" \
198-
--engine-env NO_PROXY="${KUBE_BUILD_NO_PROXY:-127.0.0.1}" \
196+
--engine-env HTTP_PROXY="${KUBERNETES_HTTP_PROXY:-}" \
197+
--engine-env HTTPS_PROXY="${KUBERNETES_HTTPS_PROXY:-}" \
198+
--engine-env NO_PROXY="${KUBERNETES_NO_PROXY:-127.0.0.1}" \
199199
"${DOCKER_MACHINE_NAME}" > /dev/null || {
200200
kube::log::error "Something went wrong creating a machine."
201201
kube::log::error "Try the following: "
@@ -242,14 +242,11 @@ function kube::build::is_osx() {
242242

243243
function kube::build::update_dockerfile() {
244244
if kube::build::is_osx; then
245-
sed_opts=("-i ''")
245+
sed_opts=(-i '')
246246
else
247247
sed_opts=(-i)
248248
fi
249-
sed ${sed_opts[@]} "s/KUBE_BUILD_IMAGE_CROSS_TAG/${KUBE_BUILD_IMAGE_CROSS_TAG}/" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
250-
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTP_PROXY#${KUBE_BUILD_HTTP_PROXY:-\"\"}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
251-
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTPS_PROXY#${KUBE_BUILD_HTTPS_PROXY:-\"\"}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
252-
sed ${sed_opts[@]} "s#KUBE_BUILD_NO_PROXY#${KUBE_BUILD_NO_PROXY:-127.0.0.1}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
249+
sed "${sed_opts[@]}" "s/KUBE_BUILD_IMAGE_CROSS_TAG/${KUBE_BUILD_IMAGE_CROSS_TAG}/" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
253250
}
254251

255252
function kube::build::ensure_docker_in_path() {

0 commit comments

Comments
 (0)