Rancher Server 上的 Kubectl 无法正常工作

Kubectl on Rancher Server not working properly

这可能是一个愚蠢的问题,但我找不到任何关于该主题的有用信息。

我正在按照本教程设置自动 CI/CD 管道: https://rancher.com/blog/2018/2018-08-07-cicd-pipeline-k8s-autodevops-rancher-and-gitlab/

我卡在令牌部分了。我收到此错误:

unable to recognize "http://x.co/rm082018": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused

kubectl 似乎配置不正确。如果我调用 kubectl version 我会得到以下输出:

Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

看来我必须将 admin.conf 文件复制到主目录中。但是,这个文件不存在,因为 kubeadm 没有安装在 rancher 服务器上。后来我尝试自己安装 kubeadm,调用 kubeadm init 并复制生成的 admin.conf 文件。

错误仍然存​​在。

所以我的问题是:

我该如何解决这个问题? 我必须解决这个问题还是可以通过其他方式获得令牌? kubectl 错误是正常行为吗,因为 Rancher 应该自己处理所有这些?

提前感谢您的回答。

kubectl 命令输出表明在您的主机上找不到 kubeconfig。您必须执行以下操作之一:

  • 在 ~/.kube/
  • 下放置一个名为 config 的 kubeconfig
  • 导出名为 KUBECONFIG 的环境变量,并将 kubeconfig 位置作为其值
  • 使用带有 --kubeconfig ... 参数的 kubectl 命令

祝黑客愉快 问候