AIOPs - Adding entries to Pod /etc/hosts
search cancel

AIOPs - Adding entries to Pod /etc/hosts


Article ID: 257031


Updated On:


DX Operational Intelligence DX Application Performance Management


Adding entries to a Pod's /etc/hosts file provides Pod-level override of hostname resolution when DNS and other options are not applicable, for example, in case of a network issue and fixing it is not immediate and adding the entries to the pod can used as a workaround



DX Platform 2x


Table of Contents

In Kubernetes:

1) Edit a deployment

For example dxi-readserver:

kubectl edit deployment dxi-readserver -ndxi

NOTE: replace dxi with your correct namespace

2) Add the new hosts entries to the HostAliases property

For example:

- ip: ""
  - ""

3) Save the deployment -- a new pod will be created

4) Verify that /etc/host has been updated

Below an example:

kubectl get pods -ndxi | grep dxi-readserver
dxi-readserver-8559b6bff5-blhmp                        1/1     Running     0          4m37s

kubectl exec -ti -ndxi dxi-readserver-8559b6bff5-blhmp sh

more /etc/hosts
# Kubernetes-managed hosts file.       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters

# Entries added by HostAliases.

In Openshift:

a) Edit the YAML of the Deployment

b) Add the New hosts entries to the HostAliases property as below for example:

    - hostnames:


c) After the pod start, you can verify the new entry in the /etc/hosts file

Here is an example of a problem illustrating how updating the /etc/host in a deployment can be useful: Not able to login to the DX operational inteligence

Additional Information