英文:
Volume only for init containers
问题
An init container prepares data for the "regular" container. It needs quite a lot of scratch space to download/preprocess the data, space that is no longer needed after the init container finishes.
当前为Pod挂载的卷具有足够的空间来执行初始化过程,并且在大多数Pod的生命周期中不使用该空间。是否有一种方法可以创建一个Volume
,仅在初始化容器的生命周期内存在,并在其完成后销毁?该Pod(即主容器)的生存周期较长(几天),而初始化容器及其临时空间的生存周期较短(几分钟)。
英文:
An init container prepares data for the "regular" container. It needs quite a lot of scratch space to download/preprocess the data, space that is no longer needed after the init container finishes.
Currently the volumes mounted for the pod have enough space for the init process, and the space is not used for most of the pod's lifetime. Is there a way to have a Volume
that exists only for the lifetime of the init container, and is destroyed after it's done? The pod (i.e. main container) is long-lived (days) and the init container and its scratch space are short lives (minutes).
答案1
得分: 0
一个卷与一个 Pod 相关联,而不是与特定容器相关联。如果您在 Pod 中配置了一个卷,它将存在于 Pod 的生命周期内。
也许您可以考虑以下其中一个选项?
-
使用对象存储代替(类似 S3 的存储),因为它不会被“挂载”到文件系统上,可以与 Pod 的生命周期分开。
这是否可行取决于对象存储服务的可用性以及您正在使用的特定工具/应用程序。
-
在单独的临时 Pod 中执行初始化,也就是一个 Job。在您的应用程序 Pod 中包含逻辑,直到初始化完成才阻塞。
像 Helm 和 ArgoCD 这样的工具具有在更新部署时自动提交 Job 的能力。
英文:
A volume is tied to a Pod, not to a particular container. If you've configured a volume in your Pod it will exist for the lifetime of the Pod.
Maybe you can investigate one of these options?
-
Use object storage instead (S3-alike storage), because that doesn't get "mounted" on the filesystem and can have a lifecycle separate from that of your Pod.
Whether or not this is an option depends both on the availability of an object storage service as well as the particular tools/applications you're using.
-
Perform your initialization in a separate, ephemeral Pod -- aka a Job. Include logic in your application Pod that blocks until the initialization is complete.
Tools like Helm and ArgoCD have the ability to automatically submit a Job when you update your deployment.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论