【问题标题】:Unable to Change Kubectl Context to my Google Kubernetes Cluster无法将 Kubectl 上下文更改为我的 Google Kubernetes 集群
【发布时间】:2020-02-02 06:42:20
【问题描述】:

我通过 Cloud Console 创建了一个 Google Kubernetes Engine 集群。现在我想使用本地机器上的kubectl 连接到它。 几周前我用过

gcloud container clusters get-credentials cents-ideas --zone europe-west3-a --project cents-ideas

由 Cloud Console 提供。

运行此命令后的输出为:

Fetching cluster endpoint and auth data.
kubeconfig entry generated for cents-ideas.

但集群既不在kubectl config get-contexts 中,也不设置为kubectl config current-context。我很困惑,因为这个命令过去可以工作并且没有什么不同。


我的kubectl version

Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-01-18T23:30:10Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-01-18T23:22:30Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"}

gcloud version

Google Cloud SDK 278.0.0
alpha 2020.01.24
beta 2020.01.24
bq 2.0.52
core 2020.01.24
gsutil 4.47
kubectl 2020.01.24

cat ~/.kube/config

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <LONG HASH>
    server: https://35.234.108.15
  name: gke_cents-ideas_europe-west3-a_cents-ideas
contexts:
- context:
    cluster: gke_cents-ideas_europe-west3-a_cents-ideas
    user: gke_cents-ideas_europe-west3-a_cents-ideas
  name: gke_cents-ideas_europe-west3-a_cents-ideas
current-context: gke_cents-ideas_europe-west3-a_cents-ideas
kind: Config
preferences: {}
users:
- name: gke_cents-ideas_europe-west3-a_cents-ideas
  user:
    auth-provider:
      config:
        access-token: <SOME TOKEN>
        cmd-args: config config-helper --format=json
        cmd-path: /snap/google-cloud-sdk/115/bin/gcloud
        expiry: "2020-02-02T09:45:19Z"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp

kubectl get nodes的输出

NAME         STATUS   ROLES    AGE   VERSION
flolubuntu   Ready    <none>   42d   v1.17.2

【问题讨论】:

  • 你能运行cat ~/.kube/config吗?输出是什么?
  • 我已经添加了:)
  • 对我来说看起来不错.. kubectl get nodes 输出是什么?
  • 我已经添加了它......但我只是退回了我的机器......当它几周前曾经工作时,它显示了 gke 节点
  • 只是检查一下,你可以运行echo $KUBECONFIG

标签: kubernetes google-cloud-platform google-kubernetes-engine kubectl


【解决方案1】:

我安装了microk8s。删除它并安装 snap install kubectl 解决了我的问题。

【讨论】:

  • 有道理,很高兴你找到问题
猜你喜欢
  • 2018-12-28
  • 2019-10-11
  • 2018-09-19
  • 2016-08-29
  • 2018-04-15
  • 2018-08-22
  • 2021-05-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多