简体   繁体   中英

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

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 .

Is there a way to reference the ingress-nginx-controller EXTERNAL-IP value using the valueFrom syntax or is that not possible? And if not, what might be another way to let the deployed pod get at the EXTERNAL-IP value of the ingress-nginx-controller?

  1. You cant do that using valueFrom because of The downward API limitations. 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. Check Kubernetes - Pass Public IP of Load Balance as Environment Variable into Pod for already prepared script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM