我有一些相当大的 UTF-8 数据文件,pod 需要在启动时加载到内存中 - 从几百 KB 到大约 50 MB。
该项目(包括 helm 图表)是开源的,但其中一些文件不是开源的 - 否则我可能只会将它们包含在图像中。我最初的想法是创建配置映射,但我的理解是 50 MB 超出了配置映射的预期大小,因此在某些情况下这可能最终会成为问题。我认为秘密也太过分了——它们不是秘密,只是不应该放在开放的互联网上。
出于性能原因,我宁愿在每个 Pod 的内存中都有一个副本,而不是使用共享缓存,但我可能是错的。至少这可能会增加比其价值更多的复杂性。
configmaps 是可行的方法吗?
从我的角度来看,最好的解决方案是使用初始化容器 https://kubernetes.io/docs/concepts/workloads/pods/init-containers/从安全存储下载文件(正如所提到的安德鲁·萨维尼赫 https://stackoverflow.com/users/284111/andrew-savinykh在评论中),添加到 pod 的卷,然后在 pod 的主容器中使用它。
请参阅example https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/#create-a-pod-that-has-an-init-container:
apiVersion: v1
kind: Pod
metadata:
name: init-demo
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: workdir
mountPath: /usr/share/nginx/html
# These containers are run during pod initialization
initContainers:
- name: install
image: busybox
command:
- wget
- "-O"
- "/work-dir/index.html"
- http://kubernetes.io
volumeMounts:
- name: workdir
mountPath: "/work-dir"
dnsPolicy: Default
volumes:
- name: workdir
emptyDir: {}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)