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:
hostAliases:
- ip: "10.65.82.51"
hostnames:
- "myldap.acme.com"
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.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
192.168.175.193 dxi-readserver-8559b6bff5-blhmp
# Entries added by HostAliases.
10.65.82.51 myldap.acme.com
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