k8s 通过环境变量获取Pod信息

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    // 这个不清楚,还没学习到

官方链接:https://kubernetes.io/zh/docs/tasks/inject-data-application/environment-variable-expose-pod-information/

posted @ 2020-01-25 22:02  whyfate  阅读(9243)  评论(0编辑  收藏  举报