You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否执行az aks get-credentials且不更改kubectl当前上下文?

执行az aks get-credentials不改变kubectl当前上下文的方法

可以实现,只需给命令添加--no-switch-context参数即可,修改后的命令如下:

az aks get-credentials --overwrite-existing --name test-aks-cluster --resource-group test-resource-group --no-switch-context

说明:

  • 该参数会让Azure CLI仅更新${HOME}/.kube/config文件中目标AKS集群的凭据信息,不会修改kubectl的当前上下文,完全满足你在脚本中更新凭据但不影响现有任务的需求。
  • 如果你的Azure CLI版本过低没有这个参数,先执行az upgrade升级到最新版本即可使用。

内容的提问来源于stack exchange,提问作者spkane

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 01:22:01