Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

Kubernetes – kubectl proxy 让外部网络访问K8S api-service

查看K8s集群信息

[root@k8s-master ~]# kubectl cluster-info
Kubernetes master is running at https://192.168.1.8:6443
KubeDNS is running at https://192.168.1.8:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

使用kubectl proxy命令就可以使API server监听在本地的8001端口上:

$ kubectl proxy
Starting to serve on 127.0.0.1:8001

如果想通过其它主机指定端口访问就需要指定监听的地址:

$ kubectl proxy --address=0.0.0.0 --port=8009
Starting to serve on [::]:8009

此时通过curl访问会出现未认证的提示:

$ curl -X GET -L http://k8s-master:8009/
<h3>Unauthorized</h3>

设置API server接收所有主机的请求:

$ kubectl proxy --address='0.0.0.0' --accept-hosts='^*$' --port=8009
Starting to serve on [::]:8009

访问正常:

$ curl -X GET -L http://k8s-master:8009/
{
  "paths": [
    "/api",
    "/api/v1",
    ...
  ]
}
上一篇 Centos 7系统下Kubeadm方式搭建k8s集群
下一篇 Kubernetes通过yaml创建命名空间