The problem
After installing kubernetes-CLI, run kubectl cluster-info to report an exception. Then enter kubectl cluster-info -v=8 to obtain the specific exception.
Error 1
The connection to the server :8443 was refused
Error 2
:8443 was refused – did you specify the right host or port
The details of the output of kubectl cluster-info show that Kubectl makes an HTTP request to the requesting K8S cluster, is proxy-ed to a strange port 8118, and then realizes that the socket proxy was started locally while doing the go.
Disable the proxy service, delete the environment variables of http_proxy and HTTPs_proxy, and update the environment variable K8S.
vim ~/.zshrc
#The proxy may affect Intranet access
# export http_proxy='http://127.0.0.1:8118'
# export https_proxy='http://127.0.0.1:8118'
Copy the code
#Close the agent
brew services stop privoxy
#Start the broker
brew services start privoxy
Copy the code
After careful consideration, the root cause of the problem is that the proxy software forwards the request of the terminal to the port (8118) monitored by the proxy, and then forwards the request to the VPN to achieve the effect that the terminal request can access the Internet scientifically. This is great for getting golang dependencies, but for requests that do not need to be forwarded, such as Intranet K8S, the request will fail.
Modify the privoxy configuration file and modify the forwarding rules.
Vim/usr/local/etc/privoxy/config # comments rules of the global forwards, note: This configuration is in the middle of the file # forward-socks5/127.0.0.1:1080. # add a custom forward rule listen-address 0.0.0.0:8118 forward-socks5.google.com localhost:1080 .Copy the code
Restart Privoxy and run kubectl cluster-info to verify that the K8S connection is successful.
Call it a day