I am working with kubernetes. I want to mount the local(host) volume in the container.
But it doesn't mount the subdirectories inside the directory.
This is my job.yaml file.
apiVersion: v1
kind: Pod
metadata:
name: ts-engine
spec:
containers:
- image: ts_engine:latest
name: ts-engine
imagePullPolicy: Never
command: ["/bin/bash", "-c","cd workspace && ls && echo '1234'&& cd .. && ls"]
volumeMounts:
- mountPath: /workspace
name: workspace
volumes:
- name: workspace
hostPath:
path: /workspace
type: Directory
The logs for this pod are like this:
1234
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
workspace
It shows that the "workspace" directory is empty but actually it has some directories in "workspace".
Is there any idea for this situation?
The output of your "ls" command shows that you are not actually working in the directory "workspace". You are at the top level (/), and are listing the directory not its contents. In other words, your cd command isn't doing what you think.
To really be able to answer this, we would need to know more about your setup, but here is my best guess: