Kubernetes Pod动态环境变量 [英] Kubernetes Pod Dynamic Environment Variables

查看:116
本文介绍了Kubernetes Pod动态环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够将自定义环境变量分配给Pod的每个副本.一个变量应该是一些随机的uuid,另一个是唯一的数字.如何实现?我希望继续对副本使用部署".如果开箱即用不可行,如何通过定制复制控制器/控制器管理器来实现?有钩子可以实现这一目标吗?

I need to be able to assign custom environment variables to each replica of a pod. One variable should be some random uuid, another unique number. How is it possible to achieve? I'd prefer continue using "Deployment"s with replicas. If this is not feasible out of the box, how can it be achieved by customizing replication controller/controller manager? Are there hooks available to achieve this?

推荐答案

您可以使用向下的API将pod的metadata.uid作为envvar注入,每个env都是唯一的

You can use the downward API to inject the metadata.uid of the pod as an envvar, which is unique per pod

这篇关于Kubernetes Pod动态环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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