简体   繁体   English

如何将我的主机 ip 地址分配给 kube.netes configmap?

[英]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.

相关问题 如何在Kubernetes中为容器分配外部IP地址? - How to assign an external IP address to a container in Kubernetes? 如何使用非特定于 Kubernetes API 的主机的 IP 地址来设置 Kubernetes DNS? - How can one set up Kubernetes DNS using an IP address that is not host specific to the Kubernetes API? 如何修复API从我的AWS Kubernetes pod中看到的IP地址 - How can I fix the IP address an API sees from my AWS Kubernetes pods 如何使用我的 IP 地址或本地 DNs 使我的 kubernetes 仪表板在我的本地网络中可访问 - How can i make my kubernetes dashboard accessible in my local network using my IP address or a local DNs 如何在kubernetes中从ConfigMap填充图像值? - How can I populate image value from ConfigMap in kubernetes? 如何将多个 configmap 放在 kubernetes 的同一挂载路径中? - How can I put multi configmap in the same mount path in kubernetes? 如何在 Kubernetes ConfigMap 中存储二进制文件? - How can I store a binary file in a Kubernetes ConfigMap? 如何在 Kube.netes 中获取动态密钥的 configmap 值 - How can I get configmap value where the key is dynamic in Kubernetes Kubernetes:如何将 static IP 地址或主机名分配给节点和 POD - Kubernetes : How to assign static IP address or HostName to node and POD 如何使用 Terraform 为 Kubernetes 入口分配静态 IP 地址? - How to assign a static ip address to an Kubernetes ingress using Terraform?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM