env:
- name: MY_NODE_NAME
    valueFrom:
    fieldRef:
        fieldPath: spec.nodeName                       // 节点名称
- name: MY_POD_NAME
    valueFrom:
    fieldRef:
        fieldPath: metadata.name                        // pod 名称
- name: MY_POD_NAMESPACE
    valueFrom:
    fieldRef:
        fieldPath: metadata.namespace              // 命名空间
- name: MY_POD_IP
    valueFrom:
    fieldRef:
        fieldPath: status.podIP                              // pod ip
- name: MY_POD_SERVICE_ACCOUNT
    valueFrom:
    fieldRef:
        fieldPath: spec.serviceAccountName    // serviceAccountName

转自:https://www.cnblogs.com/wh-blog/p/12233483.html
参考:https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐