I’m trying to deploy a container in Kubernetes and at the same time copy a file from one of the persistent volumes to specific directory. The problem is that if i run the command without delay it will try to copy the file before mounting the persistent volume.
I’d like to help me with the syntax to delay the copy command few seconds until the persistent volume is mounted.
I tried to type the command field like that but the container crashes while deploying the pod.
spec:
containers:
- image: andreask81/syspass:latest
name: syspass-app
command: ["/bin/bash"]
args: ["sleep 30", "cp /var/www/html/sysPass/config/backup/config.xml /var/www/html/sysPass/config/config.xml"]
And this one also did not work and caused the pod to crash right after container creation.
command: ["/bin/bash","-c","sleep 10 && cp /var/www/html/sysPass/config/backup/config.xml /var/www/html/sysPass/config/config.xml"]
In the meanwhile, when I run the following command inside similar container directly in the shell it works.
/bin/bash -c "sleep 1" && cp /var/www/html/sysPass/config/backup/config.xml /var/www/html/sysPass/config/config.xml
Any idea how can I format the "command:" field in the YAML file to make this work?
2
Answers
In your manifest file, you didn’t add -c to the command value or at the beginning of your args. Any reason for this? Do add it and give it another go:
You also could add a bash script with commands you need and call it on yaml command value.
Keep it clean 🙂