Reputation: 71
I am trying to edit a file in my pod from my local machine using kubectl exec, but it is not working!
Example: Suppose I am working on Ubuntu and having a pod named "Pod1", I want to edit a file named /lists inside Pod1. I am doing this kubectl exec Pod1 cat /lists >> "HELLO" but it is not working, please how to solve this kind of problem!
Upvotes: 0
Views: 8673
Reputation: 1706
You can't cat
a local file over. One way is to store the file in a BASH variable first before sending it over
lists=$(cat /lists); kubectl exec Pod1 "echo $lists >> HELLO"
But this isn't a great way either. Are you attempting to debug the app or to automate some process by writing to a file this way? If it's the latter, may I suggest using a ConfigMap instead?
Upvotes: 3