在Kubernetes pod使用之前,将大文件预加载到本地PersistentVolume SSD的最佳方法是什么?
目标是拥有多个pod(可以是同一pod的多个实例,或者不同),以只读模式共享同一本地SSD驱动器。需要使用大型数据集以某种方式初始化驱动器。
谷歌Local SSD docs描述了Running the local volume static provisioner
,但这种方法只创建了一个PersistedVolume,但没有初始化它。
基本上,您可以在pod中添加init
容器来初始化SSD:添加数据等。
apiVersion: v1
kind: Pod
metadata:
name: "test-ssd"
spec:
initContainers:
- name: "init"
image: "ubuntu:14.04"
command: ["/bin/init_my_ssd.ssh"]
volumeMounts:
- mountPath: "/test-ssd/"
name: "test-ssd:
containers:
- name: "shell"
image: "ubuntu:14.04"
command: ["/bin/sh", "-c"]
args: ["echo 'hello world' > /test-ssd/test.txt && sleep 1 && cat /test-ssd/test.txt"]
volumeMounts:
- mountPath: "/test-ssd/"
name: "test-ssd"
volumes:
- name: "test-ssd"
hostPath:
path: "/mnt/disks/ssd0"
nodeSelector:
cloud.google.com/gke-local-ssd: "true"