Modify file from kubernetes pod

3/11/2019

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.

-- ImPurshu
amazon-eks
kubernetes
kubernetes-pod
python-3.x

2 Answers

3/11/2019

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

-- P Ekambaram
Source: StackOverflow

3/11/2019

Generally you would do this with an initContainer and a templating tool like envsubst or confd or Consul Templates.

-- coderanger
Source: StackOverflow