Kubernetes Deployment: 挂载 Node 节点目录示例
以下是一个 Kubernetes Deployment 文件示例,用于挂载 Node 节点上的目录:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mount-directory
labels:
app: mount-directory
spec:
replicas: 1
selector:
matchLabels:
app: mount-directory
template:
metadata:
labels:
app: mount-directory
spec:
containers:
- name: mount-directory
image: '<your_image>'
volumeMounts:
- name: node-directory
mountPath: /app/mounted-directory
volumes:
- name: node-directory
hostPath:
path: /node/directory
在这个示例中,我们创建了一个名为 'mount-directory' 的 Deployment。它定义了一个 Pod 模板,其中包含一个名为 'mount-directory' 的容器,使用了 '<your_image>' 镜像。容器中定义了一个名为 'node-directory' 的 VolumeMount,被挂载到容器的 '/app/mounted-directory' 路径上。
此外,我们还定义了一个名为 'node-directory' 的 Volume,它使用了 'hostPath' 类型,指定了 Node 节点上的目录路径 '/node/directory'。
您可以根据实际情况修改 Deployment 文件中的镜像名称、挂载路径和节点目录路径。
原文地址: http://www.cveoy.top/t/topic/blem 著作权归作者所有。请勿转载和采集!