Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl proxy unauthorized when accessing from another machine

I have Kubernetes running on a VM on my dev box. I want to view the Kubernetes dashboard from the VM host. When I run the following command:

kubectl proxy --address 0.0.0.0 --accept-hosts ^/.*

When I try to access the dashboard I get an unauthorized error.

What am I missing?

like image 758
Zeus82 Avatar asked Feb 07 '17 16:02

Zeus82


People also ask

How do I stop Kubectl proxy?

There is no way to stop it other than kill or ^C (if not in background).

What does Kubectl proxy does?

The proxy provides a secure connection between the cluster(API Server) and the client, this avoid you having to change all your applications to implement a security logic just to communicate to the cluster, this way, you authenticate once, and every application use this secure connection without any changes.

How do I access Kubernetes dashboard externally?

Ans: In a terminal window, enter kubectl proxy to make the Kubernetes Dashboard available. Open a browser and go to http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes–dashboard:/proxy/#!/login to display the Kubernetes Dashboard that was deployed when the cluster was created.

What port does kube-proxy use?

Like the rest of Kubernetes control plane parts, the kube-proxy is instrumented with Prometheus metrics, exposed by default in the port 10249. This metrics endpoint can be easily scraped, obtaining useful information without the need for additional scripts or exporters.


1 Answers

The --accept-hosts access control is for checking of the hostname, so it won't start with a / (slash). You need to do:

kubectl proxy --address 0.0.0.0 --accept-hosts '.*'

(Make sure you shell escape the .* as it may match files in the current directory!)

More information at: https://kubernetes.io/docs/user-guide/kubectl/kubectl_proxy/

like image 122
Janos Lenart Avatar answered Sep 25 '22 15:09

Janos Lenart