Hi,
By using --label when running a pod :
kubectl run my-shell --labels:…
Im’ not able to retrieve this label via docker inspect on containers of this pod.
“Only” labels found here are of these kinds :
annotation.kubernetes.io
io.kubernetes…
In another hand , this label is well retrieved via kubectl describe pod …
Thx for help.
As far as I understand them labels are metadata for the objects in Kubernetes and are stored in ETCD and do not carry over to Docker.
1 Like
Hi,
Thx for answer
Is there anyway to add labels at same level as these ones ?
annotation.kubernetes.io
io.kubernetes…
cos we are to see them in docker inspection .
J…P.
I am not familiar with anyway to do that. I don’t even believe the annotations you pass to the spec are carried over to Docker as they are k8s specific and not really meant for Docker.
There is an open issue in the k8s github that’s tracking this though, you may want to look at it.
Hi,
Thx for infos.
I’ve added a comment in GitHub.
J.P.
----- Mail d’origine -----
1 Like
Hi,
I’ve found a way to retrieve metadata defined at Kubernetes deployment level within the containers :
By adding these lines ( env: ) in the containers part of the deployment file .yaml :
spec:
replicas: 1
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: Service_1
spec:
containers:
- image: 19562019/centos-ribo1
name: pod-1
resources: {}
env:
-
- name: APPLI_AGGREGATE_1*
-
value: "ITOPS_1"*
-
- name: APPLI_AGGREGATE_2*
-
value: "ITOPS_2"*
restartPolicy: Always
status: {}
then a docker inspect of the containers created by this deployment shows following env variables :
Env": [
“APPLI_AGGREGATE_1=ITOPS_1”,
“APPLI_AGGREGATE_2=ITOPS_2”,
Not too bad …
Using environment variables injection seems the only way (up to now) .
J.P.
1 Like
Cool, that’s a nice little work around.