在 kubernetes 运行时访问标签
Access labels during runtime in kubernetes
我的应用程序有没有办法在运行时访问分配给 pod/服务的标签?
是通过客户端 API 还是通过 ENV / 将变量传递给 docker 容器?
Downward API is designed to automatically expose information about the pod's configuration to the pod using environment variables. As of Kubernetes 1.0 is only exposes the pod's name and namespace. Adding labels to the Downward API is being discussed in #560 但目前尚未实施。
与此同时,您的应用程序可以查询 Kubernetes apiserver 并检查其配置以确定设置了哪些标签。
我的应用程序有没有办法在运行时访问分配给 pod/服务的标签?
是通过客户端 API 还是通过 ENV / 将变量传递给 docker 容器?
Downward API is designed to automatically expose information about the pod's configuration to the pod using environment variables. As of Kubernetes 1.0 is only exposes the pod's name and namespace. Adding labels to the Downward API is being discussed in #560 但目前尚未实施。
与此同时,您的应用程序可以查询 Kubernetes apiserver 并检查其配置以确定设置了哪些标签。