通过kubernetes部署创建Pod名称时,为什么在其名称后面附加5个随机字母数字字符? [英] Why do pod names have 5 random alphanumeric characters appended to their name when created through a kubernetes deployment?

查看:76
本文介绍了通过kubernetes部署创建Pod名称时,为什么在其名称后面附加5个随机字母数字字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在通过kubernetes部署创建Pod名称时,其名称后面会附加5个随机字母数字字符?是否有可能摆脱它们,使豆荚名称不变?我经常删除和创建部署,并且希望Pod名称不要更改.

Why do pod names have 5 random alphanumeric characters appended to their name when created through a kubernetes deployment? Is it possible to get rid of them so that the pods names don't change? I am frequently deleting and creating deployments and would prefer that pod names don't change.

更新:我想使用相同的名称,因为我不断删除/重新创建相同的部署,如果名称不变,那么我可以快速重用旧命令以执行到/查看容器的日志.

Update: I would like to have the same name because I am constantly deleting/recreating the same deployment and if the name doesn't change, then I can quickly reuse old commands to exec into/see the logs of the containers.

推荐答案

这是部署的工作原理,每次吊舱死亡时,ReplcaSet都会使用不同的名称创建吊舱以匹配所需的状态,并附加吊舱名称上的随机数以为其赋予唯一的名称.

This is how deployments works, every time pod dies, ReplcaSet create pod with different name to match desired state and random number attached to pod name to give them unique names.

部署对象无法实现任何目标,因为它们旨在用于无状态应用程序.当您想保留应用程序的状态(名称)时,使用StatefulSet当然可以实现.

Whatever you are trying to achieve is not possible with deployment object as they are intended for stateless applications. As you want to preserve state( name) of application this is certainly possible with StatefulSet.

因此,如果您使用StatefulSet对象管理副本,则将使用特定的名称约定(例如e)创建每个Pod. G. POD_NAME-1,POD_NAME-2等i. e.索引将附加到窗格名称.同样,当吊舱死亡时,将使用相同的名称创建新吊舱.

So if you use StatefulSet object to manage replicas, every pod will be created with certain name convention, e. g. POD_NAME-1, POD_NAME-2 etc i. e. Index will be appeneded to pod name. Also when pod dies, new pod will created with same name.

您想要实现的是StatefulSet的理想用例.去吧.

Ao you want to achieve is ideal use case of StatefulSet. Go for it.

这篇关于通过kubernetes部署创建Pod名称时,为什么在其名称后面附加5个随机字母数字字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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