“边车"Kubernetes pod 中的容器 [英] "Sidecar" containers in Kubernetes pods

查看:39
本文介绍了“边车"Kubernetes pod 中的容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个包含几个组件的多容器 Pod:

I'd like a multi-container pod with a couple of components:

  • 包含构建作业的主"容器
  • 一个包含 HTTP 代理的sidecar"容器,由main"容器使用

这似乎很符合 pod 设计理念,如 中所述Kubernetes 文档,但我相信只要sidecar"运行,pod 就会保持活动状态.就我而言,主"容器不是长期存在的;一旦退出,sidecar"就应该终止.

This seems to fit well with the pod design philosophy as described in the Kubernetes documentation, but I believe so long as the "sidecar" runs, the pod is kept alive. In my case, the "main" container is not long-lived; once it exits, the "sidecar" should be terminated.

我怎样才能做到这一点?

How can I achieve this?

推荐答案

只要其中一个容器正在运行,Pod 就会运行.如果你需要他们一起退出,你必须安排sidecar死亡.我们没有主要"容器与次要"容器的生命周期概念,尽管这很有趣.

A pod is running as long as one of the containers is running. If you need them to exit together, you have to arrange that the sidecar dies. We do not have a notion of "primary" vs "secondary" containers wrt lifecycle, though that's sort of interesting.

一种选择是使用一个 emptyDir 卷并写入一个文件,告诉 sidecar时间到了".Sidecar 会在看到该文件时退出.

One option would be to use an emptyDir volume and write a file telling the sidecar "time to go". The sidecar would exit when it sees that file.

这篇关于“边车"Kubernetes pod 中的容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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