# Elastic Agents on Openshift cluster agent name set incorrectly to pod name

**URL:** <https://discuss.elastic.co/t/elastic-agents-on-openshift-cluster-agent-name-set-incorrectly-to-pod-name/350964>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Tags:** elastic-stack-monitoring, infrastructure-observability\
**Created:** [January 12, 2024, 1:57pm UTC](https://discuss.elastic.co/t/elastic-agents-on-openshift-cluster-agent-name-set-incorrectly-to-pod-name/350964 "2024-01-12T13:57:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HansPeterSloot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanspetersloot/32/51132_2.png) [@HansPeterSloot](https://discuss.elastic.co/u/HansPeterSloot)\
**Post date:** [January 12, 2024, 1:57pm UTC](https://discuss.elastic.co/t/elastic-agents-on-openshift-cluster-agent-name-set-incorrectly-to-pod-name/350964/1 "2024-01-12T13:57:11Z")

</div>

Hello all

In our environment I do have multiple Openshift/Kubernetes clusters.  
We do use Observability and Security and configured multiple Fleet Policies to separate the different Operating Systems.  
In addition we also monitor other Openshift clusters and have Elastic Agents running on every node of the cluster.

In Observability Infrastructure all the Openshift nodes and other systems are shown with the correct name EXCEPT for the "local cluster" where Elasticsearch, Kibana etc are installed.  
In the latter case the name of the pod is displayed instead of the node name.

When I connect to the pod the contents of /etc/hostname are wrong  
The environment variable NODE\_NAME does have the correct value!!!

```auto
PS C:\Users\SomeUser> oc rsh elastic-agent-agent-7vpbm
sh-5.1# cat /etc/hostname
elastic-agent-agent-7vpbm
sh-5.1# env|sort|grep NODE_NAME
**NODE_NAME=cn2-prod4-kchwg-master-0**

```

Anyone a clue on how to change the installation manifests in order to have the name set correctly?

Regards Hans-Peter

---

<div class="post-metadata">

**Author:** ![yago82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yago82/32/97755_2.png) [@yago82](https://discuss.elastic.co/u/yago82)\
**Post date:** [January 12, 2024, 2:05pm UTC](https://discuss.elastic.co/t/elastic-agents-on-openshift-cluster-agent-name-set-incorrectly-to-pod-name/350964/2 "2024-01-12T14:05:15Z")

</div>

Hi,

you can modify the Elastic Agent's configuration to use the `NODE_NAME` environment variable instead of the system's hostname. This can be done by setting the `host` value in the agent's configuration to `${NODE_NAME}` .

Regards

---

<div class="post-metadata">

**Author:** ![HansPeterSloot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanspetersloot/32/51132_2.png) [@HansPeterSloot](https://discuss.elastic.co/u/HansPeterSloot)\
**Post date:** [January 12, 2024, 2:11pm UTC](https://discuss.elastic.co/t/elastic-agents-on-openshift-cluster-agent-name-set-incorrectly-to-pod-name/350964/3 "2024-01-12T14:11:33Z")

</div>

Hello Yago  
Well the Agent Pods are part of a DaemonSet which is owned by an Agent resource.  
I have not been able to find out how I can change the daemonSet specification to achieve that.

If you can help that would be very welcome.

below the daemonSet spec

Regards Hans

```auto
daemonSet:
    podTemplate:
      metadata:
        creationTimestamp: null
      spec:
        automountServiceAccountToken: true
        containers:
        - name: agent
          resources:
................
          securityContext:
            privileged: true
            runAsUser: 0
          volumeMounts:
          - mountPath: /hostfs/proc
..................
        securityContext:
......
        serviceAccountName: elastic-agent
        tolerations:
        - operator: Exists
        volumes:
        - hostPath:
..............
    updateStrategy: {}
  fleetServerRef:
    name: fleet-server

```

---

<div class="post-metadata">

**Author:** ![HansPeterSloot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanspetersloot/32/51132_2.png) [@HansPeterSloot](https://discuss.elastic.co/u/HansPeterSloot)\
**Post date:** [January 12, 2024, 2:40pm UTC](https://discuss.elastic.co/t/elastic-agents-on-openshift-cluster-agent-name-set-incorrectly-to-pod-name/350964/4 "2024-01-12T14:40:24Z")

</div>

This does not work:

```auto
  daemonSet:
    podTemplate:
      spec:
        tolerations:
        - operator: "Exists"
        serviceAccountName: elastic-agent
        automountServiceAccountToken: true
        securityContext:
          runAsUser: 0
        hostname: ${NODE_NAME}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 9, 2024, 2:40pm UTC](https://discuss.elastic.co/t/elastic-agents-on-openshift-cluster-agent-name-set-incorrectly-to-pod-name/350964/5 "2024-02-09T14:40:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
