I am trying below command
kubectl exec -it sss-pod-four echo "hi" >> /mnt/sss/testnew.txt
But it throws error
-bash: /mnt/sss/testnew.txt: No such file or directory
What is the best way to achieve this
There are two ways to edit a file in an existing pod: either by using kubectl exec and console commands to edit the file in place, or kubectl cp to copy an already edited file into the pod.
Found a similar question here and below command works now
kubectl exec -it sss-pod-four -- bash -c "echo hi > /mnt/sss/testnew.txt"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With