以下是我的kubernetes版本详情:
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:57:05Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:52:01Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
kubectl cluster-info 提供以下输出
Kubernetes master is running at http://localhost:8080
kubectl --server = localhost:8080 让pod正常工作:
NAME READY STATUS RESTARTS AGE
nginx-3449338310-sc54z 1/1 Running 0 3d
nginx-3449338310-sfql2 1/1 Running 0 3d
nginx-controller-0hq0n 1/1 Running 0 2h
nginx-controller-sc0nc 1/1 Running 0 2h
但是,当通过IP地址访问时,这不起作用: kubectl --server = 10.10.65.151:8080
The connection to the server 10.10.65.151:8080 was refused - did you specify the right host or port?
这是我的kube-config:
apiVersion: v1
kind: Config
clusters:
- name: kubernetes
cluster:
certificate-authority: /etc/kubernetes/pki/ca.crt
server: http://10.10.65.151:8080
users:
- name: kubeuser
user:
client-certificate: /etc/kubernetes/pki/kube-master.crt
client-key: /etc/kubernetes/pki/kube-master.key
contexts:
- context:
cluster: kubernetes
user: kubeuser
name: kubeuser-context
current-context: kubeuser-context
尝试从远程计算机访问api-server时遇到同样的错误。我可以知道缺少什么吗?
答案 0 :(得分:0)
您正在尝试连接群集IP,这只是内部的。
使用主机的IP
答案 1 :(得分:0)
我必须向kube-apiserver服务提供以下参数,以便能够使用IP地址访问api服务器。
--insecure-bind-address=0.0.0.0
现在我可以使用主机的IP地址访问api。