【问题标题】:Can a sidecar container of a pod detect the user of the application container and use the same?Pod 的 sidecar 容器能否检测到应用容器的用户并使用它?
【发布时间】:2020-06-04 14:40:26
【问题描述】:

我在 helm 图表的 common.tpl 文件中定义了一个 sidecar 容器。 这个 sidecar 容器包含在许多使用不同用户的 pod 中。

我想知道是否有一种方法可以在 sidecar 容器中将应用程序容器的用户定义为用户。因此,在每个 pod 中,我的应用程序和 sidecar 容器都将使用同一个用户。

我在想像下面这样的事情:

- name: sidecar_container
  image: sidecar_image:01
  imagePullPolicy: IfNotPresent
  securityContext:
    runAsUser: {{ some_variable_that_indicates_to_the_application's_container_user }}

有这样的选择吗?

【问题讨论】:

  • 你读过这个文档learn.hashicorp.com/vault/kubernetes/sidecar 吗?
  • 您是否想知道如何使用 Kubernetes 部署 yaml 文件设置动态值/变量?
  • 是的,我想将用户动态设置为与应用程序的容器用户相同。虽然我认为我应该遵循Pod级别的解决方案

标签: kubernetes kubernetes-helm kubernetes-pod security-context sidecar


【解决方案1】:

您可以在 Pod 级别定义“SecurityContext”,这意味着它将应用于 Pod 内的所有容器。

Pod security context

【讨论】:

  • 感谢您的回答,我知道这一点,我只是想知道,与其修改每个 pod 的 helm 图表,不如使用我的 sidecar 容器清单中的变量一次完成。跨度>
猜你喜欢
  • 1970-01-01
  • 2020-05-12
  • 2019-04-05
  • 2021-12-10
  • 2017-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多