In Openshift when writing $HOSTNAME
I do not get the Hostname/Pod name. However doing echo $HOSTNAME
, then the pod name is returned.
I need to use $HOSTNAME in my Deployment.yaml as seen below but it does not work and I wonder how come $HOSTNAME
doesn't exist?
kind: Deployment
apiVersion: apps/v1
metadata:
namespace: my-namespace
labels:
app: my-service
spec:
selector:
matchLabels:
...
template:
metadata:
...
spec:
containers:
- name: my-service
image: 'myservice.myrepo.com/my-service:latest'
env:
- name: USERS
value: >-
-javaagent:/opt/project/javaagent.jar
-Users.exist=true
-Users.first=John
-Users.specialone=$(HOSTNAME)
...
I tried using $(echo $HOSTNAME)
in deployment yaml but it does not work.
I believe there is also ways to achieve this result but i.e. Python commands to get the $HOSTNAME but I wish for a more simplified method.