cudouny
cudouny

Reputation: 124

How to update /etc/services for k8s pod / Docker container

I need to update my /etc/services file with adding some extra line to it. But I could not find any straight answers to this. In k8s there is an option to add hostAliases for /etc/hosts by editing deployment object but no options to update /etc/services

As an option, I could mount my own file but this is a too brutal way to do this IMO.

Thanks in advance!

Upvotes: 2

Views: 903

Answers (1)

Fritz Duchardt
Fritz Duchardt

Reputation: 11860

Replacing your /etc/services with a mounted ConfigMap would have the merit of being able to make updates while your Pods are running.

If you don't want to use that technique, you can use a PostStart Lifecycle Hook to add lines whenever your Pods start or restart:

lifecycle:
  postStart:
    exec:
      command: ["/bin/sh", "-c", "echo '[new-line]' >> /etc/services"]  

Upvotes: 3

Related Questions