PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, August 13, 2022

[FIXED] How to add a static IP to nginx-ingress installed via helm

 August 13, 2022     kubernetes, kubernetes-helm, nginx-ingress     No comments   

Issue

I would like to create an nginx-ingress that I can link to a reserved IP address. The main reason being, that I want to minimize manual steps. Currently, the infrastructure is automatically set-up with Terraform, but I cannot get nginx-ingress to use the reserved IP with it. I already have nginx-ingress working, but it creates its own IP address.

According to the nginx-ingress site (https://kubernetes.github.io/ingress-nginx/examples/static-ip/), this should be possible. First, one should create a load-balancer service:

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress-lb
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  loadBalancerIP: 34.123.12.123
  ports:
  - port: 80
    name: http
    targetPort: 80
  - port: 443
    name: https
    targetPort: 443
  selector:
    # Selects nginx-ingress-controller pods
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx

However, then one can update the IP via nginx-ingress-controller.yaml file with the --publish-service flag. However, I install this via helm:

helm install stable/nginx-ingress --name my-nginx --set rbac.create=true

How can I link the publish service to nginx-ingress-lb in my helm installation (or upgrade).


Solution

Assuming your cloud provider supports LBs with static IPs (AWS, for example, will give you a CNAME instead of an IP):

You will have to set it as a tag as the following. Once you do this, you can set your ingress annotation: kubernetes.io/ingress.class: nginx and your ingress will automatically get the same IP address.

helm install stable/nginx-ingress  --set controller.service.loadBalancerIP=XXXX,rbac.create=true


Answered By - cookiedough
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing