[英]Unable to Change Kubectl Context to my Google Kubernetes Cluster
我已經通過 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
我安裝了microk8s
。 刪除它並安裝snap install kubectl
解決了我的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.