如何使用 NodeJS 应用程序指定 master pod
How to dictate a master pod with NodeJS app
我正在尝试 运行 我的 NodeJS 应用程序在 EKS 中的部署,其中 ReplicaSet 指示 3 pods 应该是应用程序的 运行。但是,我试图使一些逻辑专用于 Pods 之一,称其为应用程序的“主”版本。
是否可以 a) 将不同的环境(例如 IS_MASTER 传递给该 pod,或者以其他方式从应用程序内部告诉它 运行ning 在“主 pod”上而不多个部署?
您可以使用 StatefulSets
为每个 pods 设置一个粘性标识
https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
引用文档
Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling.
Pods 将拥有给定 N 个副本的主机名 foo-{0..N-1}
,您可以对主机进行某种检查,例如如果主机名是 foo-0
那么它就是主机。
我正在尝试 运行 我的 NodeJS 应用程序在 EKS 中的部署,其中 ReplicaSet 指示 3 pods 应该是应用程序的 运行。但是,我试图使一些逻辑专用于 Pods 之一,称其为应用程序的“主”版本。
是否可以 a) 将不同的环境(例如 IS_MASTER 传递给该 pod,或者以其他方式从应用程序内部告诉它 运行ning 在“主 pod”上而不多个部署?
您可以使用 StatefulSets
为每个 pods 设置一个粘性标识https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
引用文档
Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling.
Pods 将拥有给定 N 个副本的主机名 foo-{0..N-1}
,您可以对主机进行某种检查,例如如果主机名是 foo-0
那么它就是主机。