gpt4 book ai didi

kubectl - 当前上下文未设置 Kubectl

转载 作者:行者123 更新时间:2023-12-05 01:52:54 29 4
gpt4 key购买 nike

使用 Config View 获取以下输出。注意没有“当前上下文”

root@Bootstrap [ /etc ]# kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://192.168.10.50:6443
name: tanzu-m01
contexts:
- context:
cluster: tanzu-m01
user: tanzu-m01-admin
name: tanzu-m01-admin@tanzu-m01
current-context: ""
kind: Config
preferences: {}
users:
- name: tanzu-m01-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
- name: tkgm-mgmt01-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED

使用 kubectl set-context >> 显示修改的上下文

root@Bootstrap [ /etc ]# kubectl config set-context tanzu-m01-admin@tanzu-m01
Context "tanzu-m01-admin@tanzu-m01" modified.

但是在“kubectl config current-context”上显示当前上下文未设置

root@Bootstrap [ /etc ]# kubectl config current-context
error: current-context is not set

我错过了什么?

最佳答案

正确的命令是:

kubectl config use-context ${CONTEXT}

您可以通过以下方式确认:

kubectl config --help

set-context Set a context entry in kubeconfig
use-context Set the current-context in a kubeconfig file

kubectl config set-context 设置指定上下文的属性:

kubectl config set-context ${CONTEXT} \
--cluster=${CLUSTER} \
--user=user_${USER} \
--namespace=${NAMESPACE}

关于kubectl - 当前上下文未设置 Kubectl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71379838/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com