这是主机上的目录:
├── deploy.yaml
└── foobar
└── foo.sh
和deploy.yaml文件的内容:
apiVersion: apps/v1
kind: Deployment
metadata:
name: foobar-deployment
spec:
replicas: 1
selector:
matchLabels:
app: foobar-app
template:
metadata:
labels:
app: foobar-app
spec:
containers:
- name: foobar-container
image: nginx
#command: ["sh", "-c", ""/foobar/foo.sh""]
volumeMounts:
- name: foobar-volume
mountPath: /foobar
volumes:
- name: foobar-volume
hostPath:
path: /home/n/projects/minikube-test/foobar
当我执行到容器中时,我看到foobar目录,但不是foo.sh。
k exec -it foobar-deployment-8459bf6d8f-mlprq -- ls -lart foobar
total 8
drwxr-xr-x 2 root root 4096 Jun 17 02:37 .
drwxr-xr-x 1 root root 4096 Jun 17 03:14 ..
我错过了什么?谢谢你
1条答案
按热度按时间doinxwow1#
这样做奏效了:首先,将主机目录装载到VM上的某个位置:
接下来,修改deploy.yaml文件: