在 Kubernetes 中使用 CephFS Volume 时,可以通过在 volume 的配置中指定 monitors
参数来指定连接到哪个 Ceph 集群的 Monitor。例如:
apiVersion: v1
kind: Pod
metadata:
name: cephfs-pod
spec:
containers:
- name: cephfs-container
image: busybox
command: ["/bin/sh", "-c", "sleep 3600"]
volumeMounts:
- name: cephfs-vol
mountPath: /mnt/cephfs
volumes:
- name: cephfs-vol
cephfs:
monitors:
- "192.168.1.101"
- "192.168.1.102"
user: admin
secretRef:
name: ceph-secret
readOnly: false
path: "/my-fs"
在上述配置中,我们通过 monitors
参数指定了连接到 IP 地址为 192.168.1.101
和 192.168.1.102
的 Monitors,同时通过 path
参数指定了要挂载的 CephFS 文件系统路径为 /my-fs
。这样就可以指定挂载某一个具体的文件系统了。