从另一台机器访问时,kubectl proxy 未授权
kubectl proxy unauthorized when accessing from another machine
我在开发箱的虚拟机上安装了 Kubernetes 运行ning。我想从 VM 主机查看 Kubernetes 仪表板。当我运行以下命令时:
kubectl proxy --address 0.0.0.0 --accept-hosts ^/.*
当我尝试访问仪表板时出现未经授权的错误。
我错过了什么?
--accept-hosts 访问控制用于检查 主机名,因此它不会以 /(斜杠)开头。你需要做的:
kubectl proxy --address 0.0.0.0 --accept-hosts '.*'
(确保您 shell 对 .* 进行转义,因为它可能与当前目录中的文件匹配!)
更多信息位于:https://kubernetes.io/docs/user-guide/kubectl/kubectl_proxy/
以防有人偶然发现这个问题并想限制对来宾 VM 主机的访问。
我正在使用 VirtualBox,并且我能够通过使用 localhost
和使用 SSH 隧道到来宾 VM
来仅允许从主机访问
在来宾虚拟机中
$ kubectl proxy --address='0.0.0.0' --port=8002 --accept-hosts='localhost'
在主机中,我添加了一个主机名引用到主平面的静态 IP kubemaster
$ echo "192.168.224.23 kubemaster" >> /etc/hosts
$ ssh -N -L 8001:localhost:8002 kube@kubemaster
我在开发箱的虚拟机上安装了 Kubernetes 运行ning。我想从 VM 主机查看 Kubernetes 仪表板。当我运行以下命令时:
kubectl proxy --address 0.0.0.0 --accept-hosts ^/.*
当我尝试访问仪表板时出现未经授权的错误。
我错过了什么?
--accept-hosts 访问控制用于检查 主机名,因此它不会以 /(斜杠)开头。你需要做的:
kubectl proxy --address 0.0.0.0 --accept-hosts '.*'
(确保您 shell 对 .* 进行转义,因为它可能与当前目录中的文件匹配!)
更多信息位于:https://kubernetes.io/docs/user-guide/kubectl/kubectl_proxy/
以防有人偶然发现这个问题并想限制对来宾 VM 主机的访问。
我正在使用 VirtualBox,并且我能够通过使用 localhost
和使用 SSH 隧道到来宾 VM
在来宾虚拟机中
$ kubectl proxy --address='0.0.0.0' --port=8002 --accept-hosts='localhost'
在主机中,我添加了一个主机名引用到主平面的静态 IP kubemaster
$ echo "192.168.224.23 kubemaster" >> /etc/hosts
$ ssh -N -L 8001:localhost:8002 kube@kubemaster