我需要映射一个本地计算机中的目录,该目录中存在一个在kubernetes集群中运行的docker容器中的目录。有人可以帮我吗?
host dir : /opt/dev/project1
kube image location: /var/logs
答案 0 :(得分:2)
您可以使用hostpath
将主机目录安装到kubernetes pod中。apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /var/logs
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /opt/dev/project1
# this field is optional
type: Directory