Kubernetes 如何在集群中执行kubectl命令
我有两个集群Kubernetes 如何在集群中执行kubectl命令,kubernetes,google-kubernetes-engine,Kubernetes,Google Kubernetes Engine,我有两个集群 NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS cassandra-cluster europe-west4-a 1.14.10-gke.36 xx.90.xx.31 n1-standard-1 1.14.10-gke.36 3 RUNNING codi
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
cassandra-cluster europe-west4-a 1.14.10-gke.36 xx.90.xx.31 n1-standard-1 1.14.10-gke.36 3 RUNNING
codingjediweb-cluster europe-west4-a 1.14.10-gke.36 uu.90.uu.182 n1-standard-1 1.14.10-gke.36 2 RUNNING
manuchadha25@cloudshell:~ (copper-frame-262317)$
我想在cassandra集群上运行以下命令。如何使cassandra集群成为当前上下文
我犯了一个错误
CASS_USER=$(kubectl --cluster gke_copper-frame-262317_europe-west4-a_cassandra-cluster get secret cluster1-superuser -o json | jq -r '.data.username' | base64 --decode)kubectl
Error from server (NotFound): secrets "cluster1-superuser" not found
我试过了,但失败了
manuchadha25@cloudshell:~ (copper-frame-262317)$ kubectl config use-context cassandra-cluster
error: no context exists with the name: "cassandra-cluster"
我必须设置get上下文,然后设置上下文如下
manuchadha25@cloudshell:~ (copper-frame-262317)$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
gke_copper-frame-262317_europe-west4-a_cassandra-cluster gke_copper-frame-262317_europe-west4-a_cassandra-cluster gke_copper-frame-262317_europe-west4-a_cassandra-cluster
* gke_copper-frame-262317_europe-west4-a_codingjediweb-cluster gke_copper-frame-262317_europe-west4-a_codingjediweb-cluster gke_copper-frame-262317_europe-west4-a_codingjediweb-cluster
manuchadha25@cloudshell:~ (copper-frame-262317)$ kubectl config use-context gke_copper-frame-262317_europe-west4-a_codingjediweb-cluster
您可以使用多个群集设置正确的上下文,如前所述:
kubectl config获取上下文#显示上下文列表
kubectl配置当前上下文#显示当前上下文
kubectl config use context my cluster name#将默认上下文设置为my cluster name
在使用multilples群集时,您始终需要知道您在哪个群集中执行命令,为了方便起见,您可以使用在$PS1
中显示当前上下文和命名空间