Hassan Shaitou
Hassan Shaitou

Reputation: 71

Editing Files In a Pods In Kubernetes

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

Answers (1)

Eugene Chow
Eugene Chow

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

Related Questions