Kubernetes:将Pod ID和部署ID发送到Docker [英] Kubernetes: Send a Pod Id and Deployment Id to Docker

查看:936
本文介绍了Kubernetes:将Pod ID和部署ID发送到Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一个集群,其中包含一些Docker容器的Kubernetes部署, 每个广告系列一个.每个部署都非常频繁地扩展.

Consider a cluster with a few Kubernetes deployments of Docker containers, one per each campaign. Each deployment scales quite frequently.

出于记录目的,我希望每个Pod写入主机上的单独目录,其中包括其唯一的Pod ID和共享的部署ID,例如:

For logging purposes, I want each pod to write to a separate directory on the host, which includes both its unique Pod Id and the shared deployment id, e.g.:

 /var/logs/campaigns/campaign1/pod1/
 /var/logs/campaigns/campaign1/pod2/
 /var/logs/campaigns/campaign2/pod3/
 /var/logs/campaigns/campaign2/pod4/

这样,任何窗格都无法访问另一个广告系列或另一个窗格的日志.附带说明,我使用 FileBeat 从基本目录中收集日志并发送将它们添加到 ElasticSearch .

This way no pod can access logs of another campaign or another pod. As a side note, I use FileBeat to collect the logs from the base directory and send them to ElasticSearch.

Kubernetes如何将Pod ID和Deployment ID传递给Docker,以便它可以在包含这些值的主机上创建并挂载目录?

How can Kubernetes pass the Pod Id and Deployment Id to Docker so that it can create and mount a directory on the host containing these values?

推荐答案

对于部署,您不需要在kube中进行任何操作,您所需要做的就是在部署清单中定义适当的ENV变量(即与部署名称相同).

For deployment you do not need anything inside kube, all you need to do is define proper ENV variable in your deployment manifest (ie. identical to deployment name).

对于Pod,有一个向下API .

这篇关于Kubernetes:将Pod ID和部署ID发送到Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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