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"
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.
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
and my VM network is like:
Master -> 10.2.2.40
Worker1 -> 10.2.2.41
Worker2 -> 10.2.2.42
Worker3 -> 10.2.2.43
And my forward proxy is running at
Forward Proxy: 10.5.2.30
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?
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
You can add http_proxy
setting to your Docker machine in order to forward packets from the nested Pod container through the target proxy server.
For Ubuntu based operating system:
Add export http_proxy='http://<host>:<port>'
record to the file /etc/default/docker
For Centos based operating system:
Add export http_proxy='http://<host>:<port>'
record to the file /etc/sysconfig/docker
Afterwards restart Docker service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With