简体   繁体   English

如何在 kubernetes 部署规范中从 ingress-nginx-controller 引用 EXTERNAL-IP?

[英]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 值?

  1. 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.去年提供了所有需要的链接。

  2. 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.

相关问题 在 AWS EKS 上安装 Nginx 入口 Controller 后,外部 ip 在控制器服务上仍然挂起 - external-ip remains pending on controller-service after installation of Nginx Ingress Controller on AWS EKS 更新 ingress-nginx-controller ConfigMap 以将客户端 IP 传递给后端服务 - Updating ingress-nginx-controller ConfigMap to Pass Client IP to Backend Service GKE中的Kubernetes-Nginx Ingress部署-分配给Ingress资源的公共IP - Kubernetes in GKE - Nginx Ingress deployment - Public IP assigned to Ingress resource 如何将客户端 IP 地址从 CloudFlare 转发到 Kubernetes NGINX 入口 Z594C1005906E01EC1C1ZAB? - How to forward client IP address from CloudFlare to Kubernetes NGINX ingress controller? How to append Nginx IP to X-Forwarded-For in Kubernetes Nginx Ingress Controller - How to append Nginx IP to X-Forwarded-For in Kubernetes Nginx Ingress Controller 具有集群 ip 服务和默认 nginx 的 kubernetes 入口控制器无法按预期工作 - kubernetes ingress controller with cluster ip service and default nginx not working as expected Ingress资源与Kubernetes上的NGINX入口控制器 - Ingress resource vs NGINX ingress controller on Kubernetes kubernetes nginx 入口控制器错误 - kubernetes nginx ingress controller error Kibana与Kubernetes中的nginx入口控制器 - Kibana with nginx ingress controller in Kubernetes 入口 Nginx 与 Nginx 部署在 kubernetes - Ingress Nginx vs Nginx deployment in kubernetes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM