Reputation: 880
downwardAPI could be used to inject pod's information into containers.
That could be done as below,
volumes:
- name: stinfo
downwardAPI:
items:
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
- path: "labels"
fieldRef:
fieldPath: metadata.labels
Now I want to inject controllers' information into containers, how could I do that?
For example, I want to know how many replicas there is for deployment/statefulset.
Any advice?
Thx.
Upvotes: 0
Views: 29
Reputation: 22884
The information you look for is dynamic so to get that you should use service account bound to your pod (for RBAC make sure it is attached and can read what you need) and make a direct API call to get current value.
Upvotes: 1