Updating /etc/hosts in DX O2 pods
search cancel

Updating /etc/hosts in DX O2 pods

book

Article ID: 257031

calendar_today

Updated On:

Products

DX Operational Observability

Issue/Introduction

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, adding the entries to the pod can used as a workaround

 

Environment

  • DX O2 2* OnPremise

Resolution

In Kubernetes:

1) Edit a deployment

kubectl edit deployment <dxi-deployment> -n<namespace>

         
         For example dxi-readserver:

kubectl edit deployment dxi-readserver -ndxi


2) Add the new hosts entries to the HostAliases property

For example:

hostAliases:
- ip: "192.0.2.1"
  hostnames:
  - "example.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

# Entries added by HostAliases.
192.0.2.1     example.com

In Openshift:

a) Edit the YAML of the Deployment

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

hostAliases:
    - hostnames:
           - example.com
      ip: 192.0.2.1

 Example:

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

 

Additional Information

Here is an example of updating the /etc/host to resolve an issue : Not able to login to the DX operational inteligence