要挂载Kubernetes集群中容器的文件,您需要在Pod定义中指定卷(Volumes)和容器中的挂载点(Mount Point)。
以下是一个Pod定义的例子,其中包含一个名为"example-volume"的卷,它将被挂载到容器的"/data"目录:
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: example-container
image: my-image
volumeMounts:
- name: example-volume
mountPath: /data
volumes:
- name: example-volume
hostPath:
path: /path/on/host