[英]how can i assign my host ip address into kubernetes configmap?
I assigned my host IP address in the config map. Yaml But my host IP address always changes How can I assign my host MAC address or any possible solution?我在配置 map 中分配了我的主机 IP 地址。 Yaml 但是我的主机 IP 地址总是变化 我如何分配我的主机 MAC 地址或任何可能的解决方案?
apiVersion: v1
kind: ConfigMap
metadata:
name: app-configmap
data:
display: 10.0.10.123:0.0
You can't put "the host" IP address into a ConfigMap.您不能将“主机”IP 地址放入 ConfigMap。 Consider a cluster with multiple nodes and multiple replicas of your Deployment: you could have three identical Pods running, all mounting the same ConfigMap, but all running on different hosts.
考虑一个具有多个节点和 Deployment 的多个副本的集群:您可以运行三个相同的 Pod,它们都安装相同的 ConfigMap,但都在不同的主机上运行。
If you do need the host's IP address for some reason, you can use the downward API to get it:如果你因为某些原因确实需要主机的IP地址,你可以使用向下的API来获取:
# In your pod spec, not a ConfigMap
env:
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
Again, though, note that each replica could be running on a different node, so this is only useful if you can guarantee some resource is running on every node (maybe a Kube.netes DaemonSet is launching it).不过,请再次注意,每个副本都可以在不同的节点上运行,因此这仅在您可以保证某些资源在每个节点上运行时才有用(可能是 Kube.netes DaemonSet 正在启动它)。 That configuration suggests an X Window System display server address, and typically this would be located outside the cluster, not on the nodes actually running the pods.
该配置建议 X Window 系统显示服务器地址,通常这将位于集群外部,而不是实际运行 pod 的节点上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.