I have had some success getting the name of the pod into my container for logging purposes,
env:
- name: ID_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
however I would like to extend that by logging the deployment and replica sets. Is there a way to pass these values into the pod?
Based on some observation, the pod name appears to just be an extension of the set name, which is an extension of the deployment name. Is there a way to parse that info from the name?
There is a way, but you would have to use a kubernetes client inside your pod, and query the apiserver to list the deployment or replicaset having the same labels as the pod in which the code runs, via label-selector.
There's no way to get the ownerReference
inside the Pod using the Downward APIs: this is the list of the unique items supported.