当不同的命名空间中存在相同的名称时,更新部署失败

Update deployment fails when same name exists in separate namespaces

我使用以下命令在部署中更新映像 运行:

kubectl --cluster websites --namespace production set image 
deployment/mobile-web mobile-web=eu.gcr.io/websites/mobile-web:0.23

在我创建一个镜像生产环境的暂存命名空间之前,这一直很有效。换句话说,部署 mobile-web 同时存在于生产和暂存命名空间中。现在我得到错误:

Error from server: the server could not find the requested resource
(get deployments.extensions mobile-web)

我在这里错过了什么?或者是使用 yaml 或 JSON 文件进行更新的唯一方法,这意味着在 CI/CD 管道上需要做更多的工作?我试过设置命名空间:

kubectl config set-context production --namespace=production --cluster=websites

但无济于事。

我担心的解决方案是终止当前代理并获取新凭据并再次启动代理:

gcloud container clusters get-credentials websites kubectl proxy --port=8080

现在任一命令都按预期工作:

kubectl get deployment mobile-web --namespace=production kubectl get deployment mobile-web --namespace=staging

但是它并没有解释为什么它首先停止工作。