In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article describes how Pods can obtain information about containers and nodes on which they are running (kubernetes since 1.7).
1. Compile busybox-env.yaml file
apiVersion: v1kind: Podmetadata: name: busybox-envspec: containers: - name: busybox-container image: busybox command: - sleep - "3600" env: - name: MY_NODE_NAME #Get node name valueFrom: fieldRef: fieldPath: spec.nodeName - name: MY_POD_NAME #Get pod name valueFrom: fieldRef: fieldPath: metadata.name - name: MY_POD_NAMESPACE #Get pod namespace valueFrom: fieldRef: fieldPath: metadata.namespace - name: MY_POD_IP #Get pod IP valueFrom: fieldRef: fieldPath: status.podIP
2. Apply yaml
$ kubectl apply -f busybox-env.yaml
3. Go inside the container to see if the variable exists
$ kubectl exec -it busybox-env sh$ env | egrep "MY_POD"MY_POD_NAMESPACE=defaultMY_POD_IP=10.23.2.1MY_POD_NAME=busybox-env$ env | egrep "MY_NODE"MY_NODE_NAME=k8s-node01
You can see that the variables are already loaded into the container environment variables
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.