How to Set up and Use Nginx Ingress - HOSSTED

How to Set up and Use Nginx Ingress

This tutorial describes how to set up and use Nginx Ingress.

The tutorial contains 3 sections:

  1. Installing Nginx Ingress Helm Package

  2. Setting Up a Wildcard DNS

  3. Creating an Ingress Resource

 

1. Installing Nginx Ingress Helm Package

1.1.  Get Name of Helm Package

helm search nginx-ingress

 

1.2. Install the Helm Package

helm install --name ingress

 

When Nginx Ingress is deployed, it will automatically be of Type LoadBalancer and request an IP from the LoadBalancer provider. After a few minutes, the state of the External IP of your new service will switch from (pending) to an IP. Note this IP for the next step.

 
2. Setting Up a Wildcard DNS
 

In your DNS create a wildcard entry or “Clone an existing zone” such as aks and set the entry to forward to the nginx-ingress service IP that you noted earlier.

 
3. Creating an Ingress Resource
 

For each individual route you will need an Ingress Resource. You can have one or multiple resources per file. In the case of JDC, one resource per file is used, and this file is in each repositories’ kubernetes folder and called ingress.yml

 

https://gitlab.linnovate.net/jdc/jdc/blob/master/kubernetes/ingress.yml

 

3.1. Single-host Ingress

 

Normally you will only need to include one host. In cases like this, you need a simple resource.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: jdc-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/proxy-body-size: 100m
spec:
  rules:
  - host: 'www2.jdc.org.il'
    http:
      paths:
      - path: /
        backend:
           serviceName: jdc-service
           servicePort: 80

 

3.2. Multi-host Ingress

 

The yml format allows for anchors which permit including portions into other places in the file. This allows for easy inclusion of multiple hostnames that reach the same service.

piVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: jdc-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/proxy-body-size: 100m
spec:
  rules:
  - host: 'www2.jdc.org.il'
    http: &jdc_service
      paths:
      - path: /
        backend:
          serviceName: jdc-service
          servicePort: 80
  - host: 'jdc.cloud.linnovate.net'
    http: *jdc_service
  - host: 'rampa.org.il'

 

3.3. Global values edit:


apiVersion: v1
data:
worker-shutdown-timeout: “1800” #example of value
kind: ConfigMap
metadata:
name: nginx-ingress-controller

Skip to content