In Kubernetes, how to set pods' names when using replication controllers?

前端 未结 3 992
半阙折子戏
半阙折子戏 2021-02-02 12:22

I have a simple replication controller yaml file which looks like this:

apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
spec:
  replicas: 3
           


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-02 13:00

    If you're running stateless workloads, I cannot imagine why you would want to have fixed identities associated with each object if your intention is to run N replicas of a particular pod.

    There is no way to do this using a ReplicaSet/ReplicationController. When the controller creates new pods, it will have a generated name suffix after the pod name.

    If that is what you really want (fixed identity/ordinal index), the property is satisfied by the StatefulSet resource which is stable since Kubernetes v1.9. However, it also comes with additional guarantees that you probably do not need.

提交回复
热议问题