Sai Ram
Sai Ram

Reputation: 1

Openshift : Retrieve Pod Name while deploying to update the same in App Dynamics for Metrics

I am trying to deploy my app in Openshift. Let's say service name : abc

In openshift, pod gets deployed as "abc-RandomString1-RandomString2"

Now App Dynamics agent installation is done during app startup.

So I want to know if I can retrieve the RandomString1, RandomString2 into the deployment params, so that I can use the names dynamically for Metrics

Upvotes: 0

Views: 21

Answers (1)

hiroyukik
hiroyukik

Reputation: 816

This is just an idea. If you want to get the pod name in your pod. You can use the Downward API in your deployment.

You can set the podname as an environment variable as follows:

spec:
  template:
    spec:
      containers:
      - name: this-is-sample
        env:
        - name: MY_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name          

*1: https://kubernetes.io/docs/concepts/workloads/pods/downward-api/

Upvotes: 0

Related Questions