重命名Kubernetes中的部署 [英] Rename deployment in Kubernetes

查看:65
本文介绍了重命名Kubernetes中的部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我执行kubectl get deployments,我会得到:

If I do kubectl get deployments, I get:

$ kubectl get deployments
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
analytics-rethinkdb   1         1         1            1           18h
frontend              1         1         1            1           6h
queue                 1         1         1            1           6h

是否可以将部署重命名为rethinkdb?我尝试使用谷歌搜索kubectl edit analytics-rethinkdb并更改Yaml中的名称,但这会导致错误:

Is it possible to rename the deployment to rethinkdb? I have tried googling kubectl edit analytics-rethinkdb and changing the name in the yaml, but that results in an error:

$ kubectl edit deployments/analytics-rethinkdb
error: metadata.name should not be changed

我意识到我可以先kubectl delete deployments/analytics-rethinkdb然后做kubectl run analytics --image=rethinkdb --command -- rethinkdb etc etc,但是我觉得应该可以简单地重命名它,不是吗?

I realize I can just kubectl delete deployments/analytics-rethinkdb and then do kubectl run analytics --image=rethinkdb --command -- rethinkdb etc etc but I feel like it should be possible to simply rename it, no?

推荐答案

对象名称在Kubernetes中是不可变的.如果要更改名称,可以使用其他名称导出/编辑/重新创建

Object names are immutable in Kubernetes. If you want to change a name, you can export/edit/recreate with a different name

这篇关于重命名Kubernetes中的部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆