Report this

What is the reason for this report?

How to assign an Load Balancer-IP to NGINX ingress?

Posted on May 8, 2020

Hi all

Would be nice, if someone could answer the question:

https://stackoverflow.com/questions/61677995/how-to-assign-an-external-ip-to-nginx-ingress

Thanks



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

To assign an external IP to your nginx ingress, you should create a LoadBalancer service. This LoadBalancer service will automatically create a DigitalOcean Load Balancer with an external IP address that you can use.

Here is an example of how you can create it:

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: my-nginx-service
  5. spec:
  6. type: LoadBalancer
  7. selector:
  8. app: my-nginx
  9. ports:
  10. - protocol: TCP
  11. port: 80
  12. targetPort: 80

Make sure you replace ‘my-nginx’ with the name of your nginx deployment.

Please consider that DigitalOcean Load Balancers are billable resources. You can always check the most up to date pricing at this link.

For more detailed information, you can refer here: DigitalOcean Docs: How to Configure Load Balancers.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.