kubectl无法从其他主机工作,但可以从localhost

时间:2017-12-21 16:44:57

标签: kubernetes kubectl

发生了什么

我正在测试kubernetes 1.9.0以升级生产群集,我无法使用kubectl从其他主机访问它。

我收到了以下错误:

pods is forbidden: User \"system:anonymous\" cannot list pods in the namespace \"default\"

我尝试使用admin用户和之前使用只读角色创建的其他用户。

您期望发生什么

适用于kubernetes 1.5

如何重现(尽可能最低限度)

我用kubeadm安装了kubernetes 1.9.0。

我可以使用以下命令从master访问本地群集: kubectl --kubeconfig kubeconfig get pods

与服务器:https://127.0.0.1:6443

我在haproxy上添加了一条规则,将该端口重定向到另一个端口,但我做了一些测试:

  • 旧环境的代理配置为所有请求https://example.org/api/k8s的请求都将重定向到k8s api端点。

  • 我使用相同的配置配置了这个新环境但没有工作。 (错误:pods被禁止:User \" system:anonymous \"无法列出命名空间中的pod \"默认\")

  • 我使用新的DNS名称配置了这个新环境,并在tcp模式下代理链接端口443到6443,但无法正常工作。 (错误:pods被禁止:User \" system:anonymous \"无法列出命名空间中的pod \"默认\")

kubeconfig文件集服务器字段为:https://k8s.example.org

我们需要知道的其他事情吗?

kubeconfig文件(管理员用户的kubeconfig类似):

` API

Version: v1
clusters:
- cluster:
    certificate-authority-data: ***
    server: https://127.0.0.1:6443
    #server: https://k.example.org
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    namespace: default
    user: read_only
  name: read_only-context
current-context: read_only-context
kind: Config
preferences: {}
users:
- name: read_only
  user:
    as-user-extra: {}
    client-certificate: /etc/kubernetes/users/read_only/read_only.crt
    client-key: /etc/kubernetes/users/read_only/read_only.key
    user

name:read_only `

环境

  • Kubernetes版本(使用kubectl version):1.9.0
  • 云提供商或硬件配置:裸机(实际上是AWS上的VM)
  • OS(例如来自/ etc / os-release):Centos 7
  • 内核(例如uname -a):3.10.0-514.10.2.el7.x86_64
  • 安装工具:kubeadm
  • 其他:

0 个答案:

没有答案
相关问题