In kubernetes How can I use metadata name from Replication Controller inside my pod? Lets say I want to pass :
name: sparkworker1-rc
To my pods so I can use it as a parameter for log file, for example:
- name: "JAVA_OPTS"
value: "-DMY_RC_NAME=$(MY_RC_NAME)"
But instead of getting "sparkworker1-rc" I get the name of the pod that is running sparkworker1-rc-(name_of_the_pod).
This is my YAML:
kind: ReplicationController
apiVersion: v1
metadata:
name: sparkworker1-rc
spec:
replicas: 1
selector:
component: spark-worker1
template:
metadata:
labels:
component: spark-worker1
annotations:
pod.beta.kubernetes.io/hostname: worker1
Does anyone knows how I can get the RC name and NOT the pod name?
Not sure we can access the metadata value inside the container. other option is you can pass metadata as environment variable.
like this.
env:
- name: METADATANAME
value: sparkworker1-rc