Installing Nginx Ingress on OVHcloud Managed Kubernetes

Find out how to install Nginx Ingress on OVHcloud Managed Kubernetes

Last updated 31st August, 2021.

In this tutorial we are going to guide you with the setup of Nginx Ingress on your OVHcloud Managed Kubernetes Service.

Before you begin

This tutorial presupposes that you already have a working OVHcloud Managed Kubernetes cluster, and some basic knowledge of how to operate it. If you want to know more on those topics, please look at the OVHcloud Managed Kubernetes Service Quickstart.

You also need to have Helm installer on your workstation and your cluster, please refer to the How to install Helm on OVHcloud Managed Kubernetes Service tutorial.

Installing the Nginx Ingress Controller Helm chart

For this tutorial we are using the Nginx Ingress Controller Helm chart found on its own Helm repository.

The chart is fully configurable, but here we are using the default configuration.

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm -n ingress-nginx install ingress-nginx ingress-nginx/ingress-nginx --create-namespace

The install process will begin:

$ helm -n ingress-nginx install ingress-nginx ingress-nginx/ingress-nginx --create-namespace
NAME: ingress-nginx
LAST DEPLOYED: Thu Jan 28 11:45:21 2021
NAMESPACE: ingress-nginx
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:

At the end of the install, as usual with most helm charts, you get the configuration information and some tips to test your nginx-ingress but the YAML provided is based on old API version (extensions/v1beta1), the newest version is:

NOTES:
The nginx-ingress controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace ingress-nginx get services -o wide -w ingress-nginx-controller'

An example Ingress that makes use of the controller:

  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    annotations:
      kubernetes.io/ingress.class: nginx
    name: example
    namespace: foo
  spec:
    rules:
      - host: www.example.com
        http:
          paths:
            - backend:
                service:
                  name: exampleService
                  port: 80
              path: /
    # This section is only required if TLS is to be enabled for the Ingress
    tls:
        - hosts:
            - www.example.com
          secretName: example-tls

If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:

  apiVersion: v1
  kind: Secret
  metadata:
    name: example-tls
    namespace: foo
  data:
    tls.crt: <base64 encoded cert>
    tls.key: <base64 encoded key>
  type: kubernetes.io/tls

As the LoadBalancer creation is asynchronous, and the provisioning of the load balancer can take several minutes, you will surely get a &lt;pending> EXTERNAL-IP.

If you try again in a few minutes you should get an EXTERNAL-IP:

$ kubectl -n ingress-nginx ingress-nginx-controller
NAME                                      TYPE           CLUSTER-IP    EXTERNAL-IP    PORT(S)                      AGE
winning-lizard-nginx-ingress-controller   LoadBalancer   10.3.106.37   152.42.42.42   80:30782/TCP,443:30619/TCP   6m

You can then access your nginx-ingress at http://[YOUR_LOAD_BALANCER_IP] via HTTP or https://[YOUR_LOAD_BALANCER_IP] via HTTPS.

In order to test your nginx-ingress, you can for example install a Wordpress on your cluster, and then create a YAML file for the Ingress that uses the controller:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: ingress
  namespace: default
spec:
  rules:
    - host: [YOUR_LOAD_BALANCER_IP]
      http:
        paths:
          - backend:
              service:
                name: [YOUR_WORDPRESS_SERVICE_NAME]
                port: 80
            path: /

Don't forget to replace [YOUR_LOAD_BALANCER_IP] and [YOUR_WORDPRESS_SERVICE_NAME].

Apply the file:

kubectl apply -f ./ingress.yml

And the Ingress is created.

$ kubectl apply -f ./ingress.yml 
ingress.extensions/ingress created

So now if you point your browser to http://[YOUR_LOAD_BALANCER_IP], you will see your Wordpress:

Wordpress using Ingress


Did you find this guide useful?

Please feel free to give any suggestions in order to improve this documentation.

Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.

Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.

Thank you. Your feedback has been received.


These guides might also interest you...

OVHcloud Community

Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.

Discuss with the OVHcloud community