Reputation: 149
I have used some bitnami charts in my kubernetes app. In my pod, there is a file whose path is /etc/settings/test.html. I want to override the file. When I search it, I figured out that I should mount my file by creating a configmap. But how can I use the created configmap with the existed pod . Many of the examples creates a new pod and uses the created config map. But I dont want to create a new pod, I wnat to use the existed pod.
Thanks
Upvotes: 5
Views: 29254
Reputation: 41
To edit a file inside a pod you need to install vim inside the pod, run this:
apt-get update && apt-get install vim curl -y
after which you can continue with vim commands. You can also replace vim for nano if you like.
Upvotes: 4
Reputation: 20196
If not all then almost all pod specs are immutable, meaning that you can't change them without destroying the old pod and creating a new one with desired parameters. There is no way to edit pod volume list without recreating it.
The reason behind this is that pods aren't meant to be immortal. Pods meant to be temporary units that can be spawned/destroyed according to scheduler needs. In general, you need a workload object that does pod management for you (a Deployement
, StatefulSet
, Job
, or DaemonSet
, depenging on deployment strategy and application nature).
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. I advise you against both of these, because this is not permanent. Better backup the necessary data, switch deployment type to Deployment
with one replica, then go with mounting a configMap
as you read on the Internet.
Upvotes: 4