<p>I need to update my <code>/etc/services</code> 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 <strong>hostAliases</strong> for <code>/etc/hosts</code> by editing deployment object but no options to update <code>/etc/services</code></p>
<p>As an option, I could mount my own file but this is a too brutal way to do this IMO.</p>
<p>Thanks in advance!</p>

cudouny
<p>Replacing your <code>/etc/services</code> with a mounted <code>ConfigMap</code> would have the merit of being <strong>able to make updates while your Pods are running</strong>.</p>
<p>If you don't want to use that technique, you can use a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/" rel="nofollow noreferrer">PostStart Lifecycle Hook</a> to add lines whenever your Pods start or restart:</p>
<pre><code>lifecycle:
  postStart:
    exec:
      command: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;echo '[new-line]' &gt;&gt; /etc/services&quot;]  
</code></pre>
