如何为kubernetes(v1.11.2)集群设置代理设置(http_proxy变量)? [英] How to set proxy settings (http_proxy variables) for kubernetes (v1.11.2) cluster?

查看:406
本文介绍了如何为kubernetes(v1.11.2)集群设置代理设置(http_proxy变量)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个Kubernetes集群,由于组织政策,该集群由于某种原因无法建立Internet连接.现在,有些服务需要通过互联网进行通信.为了解决这个问题,我在K8s集群之外设置了一个转发代理(Squid).我的K8s集群的所有节点都可以使用转发代理访问"google.com".但是我无法使我的广告连播通过该代理进行通讯.

I have setup a Kubernetes cluster which somehow cannot have internet connectivity because of organizaion policies. Now there are some services which I need to communicate via internet. To resolve this I have setup a forward proxy (Squid) which is outside of K8s cluster. All the nodes of my K8s cluster can access "google.com" using forward proxy. But I am not able to make my pods communicate through that proxy.

我在所有主节点和工作节点上都设置了以下变量:

I have setup following variable on all the master and worker nodes:

export http_proxy="http://10.x.x.x:3128"
export https_proxy="https://10.x.x.x:3128"

我可以从主节点和工作节点卷曲google.com.但是,当我将其附加到容器中时,我注意到没有变量http_proxy和https_proxy.而且无法成功卷曲.

I am able to curl google.com from master and worker nodes. But when I attach into my container I notice that there are no variable http_proxy and https_proxy. and it cannot perform successful curl.

我的Pod和服务网络与我的VM网络不同

My pods and service network is different than my VM network

pod-network-cidr=192.167.0.0/16 
service-cidr 192.168.0.0/16 

我的VM网络就像:

Master  -> 10.2.2.40
Worker1 -> 10.2.2.41
Worker2 -> 10.2.2.42
Worker3 -> 10.2.2.43

我的转发代理正在运行

Forward Proxy: 10.5.2.30

我正在使用kubernetes v1.11.2版本.这里有什么帮助,例如我应该在哪里放置kubernetes集群的http_proxy设置,以使其对所有Pod和服务均有效?

I am using kubernetes version v1.11.2. Any help here like where should I put my http_proxy setting for kubernetes cluster to make it effective for all pods and services?

推荐答案

所以我发现要为特定容器设置代理,请在Dockerfile中设置env变量.

So I figured it out that to set the proxy for particular containers, set the env variable in Dockerfile.

ENV HTTP_PROXY http://10.x.x.x:PORT

这篇关于如何为kubernetes(v1.11.2)集群设置代理设置(http_proxy变量)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆