k8s中环境变量
1,可以通过Dowmard API将pod的IP,名称和pod所在的namespace注入到容器的环境变量中:
env: - name: pod_name valueFrom: fieldRef: fieldPath: metadata.name - name: pod_namespace valueFrom: fieldRef: fieldPath: metadata.namespace
2,将容器资源信息注入到环境变量:
env: - name: cpu_request valueFrom: resourceFieldRef: containerName: test_container resource: requests.cpu