key path : spec.template.spec.containers[].env[]

spec:
  template:
    spec:
      containers:
        - name: my-container
          env:
            - name: pod.ip
              valueFrom:
                fieldRef:
                  fieldPath: status.podIp
            - name: node.data
              value: "true"

POD 내의 환경변수에 pod.ip, node.data 가 설정되었음을 확인할 수 있음.

 

[moraeall@my-container ~]$ echo $pod.ip
127.0.0.1
[moraeall@my-container ~]$ echo node.ingest | awk '{print ENVIRON[$1]}'
true

 

cf. 그냥 echo ${node.ingest} 를 입력하면 bash: ${node.ingest}: bad substitution 이라는 메세지를 확인할 수 있는데, bash 는 .(dot) 을 포함한 변수 이름을 처리하지 못하기 못하기 때문에 환경변수를 확인할 수 있는 별도의 방법으로 접근해야 한다.

https://stackoverflow.com/a/52618002

+ Recent posts