Reputation: 430
I want to modify particular config file from kubernetes running pod at runtime. How can I get pod name at runtime and I can modify the file from running pod and restart it to reflect the changes? I am trying this in python 3.6.
Suppose, I have two running pods. In one pod I have config.json file. In that I have
{ "server_url" : "http://127.0.0.1:8080" }
So I want to replace 127.0.0.1 to other kubernetes service's loadbalancer IP in it.
Upvotes: 0
Views: 1900
Reputation: 17623
Use downwardAPI to capture the pod name. Develop start up script to get the config file that you want to update. Populate the required values using ' sed' command and then run container process
Upvotes: 0
Reputation: 54191
Generally you would do this with an initContainer and a templating tool like envsubst or confd or Consul Templates.
Upvotes: 2