简体   繁体   English

Kubernetes:每个Pod发送自定义参数

[英]Kubernetes: send custom parameters per pod

I'm testing with a kubernetes cluster, and it's been marvelous to work with. 我正在使用kubernetes集群进行测试,并且与之合作确实很棒。 But I got the following scenario: 但是我有以下情况:

I need to pass to each pod a custom value(s) just for that pod. 我需要为每个吊舱传递一个自定义值。

Let's say, I got deployment 1, and I define some env vars to that deployment, the env vars will go to each pod and that's good, but what I need is to send custom values that may go to a specific pod(like "to the third pod that I may create, send this"). 假设我有部署1,并且为该部署定义了一些env var,env var将进入每个pod,这很好,但是我需要发送可能会传递给特定pod的自定义值(例如“我可以创建的第三个广告连播,发送此邮件”)。

This is what I got now: 这就是我现在得到的:

在此处输入图片说明

Then, what I need is something like this: 然后,我需要的是这样的东西:

在此处输入图片说明

Is there any artifact/feature I could use? 我可以使用任何工件/功能吗? It does not have to be an env var, it may be a configmap value, or anything. 它不必是env var,它可以是configmap值或其他任何值。 thanks in advance 提前致谢

Pods in a deployment are homogenous. 部署中的豆荚是同质的。 If you want to set up a set of pods that are distinct from one another, you might want to use StatefulSet, which gives each pod an index you could use within the pod to select relevant config params 如果要设置一组彼此不同的Pod,则可能要使用StatefulSet,它为每个Pod提供了一个索引,您可以在Pod中使用该索引来选择相关的配置参数

The real question here is how do you know what you want to put in particular pod in the first place. 真正的问题是,您如何首先知道要在特定吊舱中放置的物品。 You could probably achieve something like this writing a custom initialiser for your pods. 您可能会实现类似这样的工作,为您的Pod编写自定义初始化程序。 You could also have an init container prefetching information from central coordinator. 您还可以使用一个初始化容器来从中央协调器中预取信息。 To propose a solution, you need to figure it out in a "not a snowflake" way. 要提出解决方案,您需要以一种“不是雪花”的方式解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM