"Sidecar"指的是Kubernetes容器中的容器 [英] "Sidecar" containers in Kubernetes pods

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

问题描述

我想要一个包含两个组件的多容器吊舱:

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

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

这似乎很符合Pod的设计理念,如中所述Kubernetes文档,但我相信,只要运行"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.

我该如何实现?

推荐答案

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

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该走了".边车在看到该文件时将退出.

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.

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

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