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


1) Edit a deployment

For example dxi-readserver:

kubectl edit deployment dxi-readserver -ndxi

NOTE: replace dxi with your correct namespace

2) Add the required entries to the HostAliases field in PodSpec

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 dxi-readserver-8559b6bff5-blhmp

# Entries added by HostAliases.



Below is a real example of a problem and illustrate how updating the /etc/host of a pod can be useful:
Not able to login to the DX operational inteligence

Additional Information