Search code examples
proxykuberneteskubectl

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?


Solution

  • 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/