[英]How to reference the EXTERNAL-IP from ingress-nginx-controller in a kubernetes deployment specification?
Being a novice kubernetes user, I have successfully deployed an application with ingress-nginx .作为 kubernetes 的新手用户,我已经成功地使用ingress-nginx部署了一个应用程序。 But now in my application deployment specification, I have need to reference the EXTERNAL-IP of an ingress-nginx-controller (created via
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.47.0/deploy/static/provider/cloud/deploy.yaml
).但是现在在我的应用程序部署规范中,我需要引用 ingress-nginx-controller 的 EXTERNAL-IP(通过
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.47.0/deploy/static/provider/cloud/deploy.yaml
创建kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.47.0/deploy/static/provider/cloud/deploy.yaml
)。
I tried doing the following in my deployment specification,我尝试在我的部署规范中执行以下操作,
- name: HOSTIP
valueFrom:
fieldRef:
fieldPath: status.hostIP
but that returned a wholly different IP address than the EXTERNAL-IP address value found in the table when I did kubectl get svc -n ingress-nginx
.但这返回的 IP 地址与我执行
kubectl get svc -n ingress-nginx
时在表中找到的 EXTERNAL-IP 地址值完全不同。
Is there a way to reference the ingress-nginx-controller EXTERNAL-IP value using the valueFrom
syntax or is that not possible?有没有办法使用
valueFrom
语法来引用 ingress-nginx-controller EXTERNAL-IP 值,还是不可能? And if not, what might be another way to let the deployed pod get at the EXTERNAL-IP value of the ingress-nginx-controller?如果没有,还有什么方法可以让部署的 pod 获取 ingress-nginx-controller 的 EXTERNAL-IP 值?
You cant do that using valueFrom
because of The downward API limitations.由于向下的 API限制,您不能使用
valueFrom
做到这valueFrom
。 PLease check this answer for more details.请检查此答案以获取更多详细信息。 Prodided last year with all the needed links.
去年提供了所有需要的链接。
You can store this value in the configmap and regularly update with the script for example.例如,您可以将此值存储在 configmap 中并使用脚本定期更新。 Check Kubernetes - Pass Public IP of Load Balance as Environment Variable into Pod for already prepared script.
检查Kubernetes - 将负载平衡的公共 IP 作为环境变量传递到 Pod 中以获取已准备好的脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.