在mac本地安装minikube后使用kubectl proxy命令就可以使API server监听在本地的8001端口上:
MacBook-Mini:~ test$ kubectl proxy
Starting to serve on 127.0.0.1:8001
如果想通过其它主机访问就需要指定监听的地址:
MacBook-Mini:~ test$ kubectl proxy --address=0.0.0.0
Starting to serve on [::]:8001
此时通过curl访问会出现未认证的提示:
Air:~ test$ curl -X GET -L http://mini:8001/
<h3>Unauthorized</h3>
设置API server接收所有主机的请求:
MacBook-Mini:~ test$ kubectl proxy --address='0.0.0.0' --accept-hosts='^*$'
Starting to serve on [::]:8001
访问正常:
Air:~ test$ curl -X GET -L http://mini:8001/
{
"paths": [
"/api",
"/api/v1",
...
]
}