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

 

posted @ 2022-06-13 17:19  ppjj  阅读(976)  评论(0编辑  收藏  举报