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.
Note: The following is an example installation. For updated installation instructions, please visit: https://kubernetes.io/docs/concepts/services-networking/ingress/
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 install ngingress ingress-nginx/ingress-nginx
The installation process will begin:
# helm install ngingress ingress-nginx/ingress-nginx
NAME: ngingress
LAST DEPLOYED: Thu Jan 28 11:45:21 2021
NAMESPACE: default
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 default get services -o wide -w ngingress-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 `<pending>` `EXTERNAL-IP`. If you try again in a few minutes you should get an `EXTERNAL-IP`:
# kubectl get services winning-lizard-nginx-ingress-controller
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
winning-lizard-nginx-ingress-controller LoadBalancer 10.3.106.37 6d6xxxx8r8.lb.c1.gra.k8s.ovh.net 80:30782/TCP,443:30619/TCP 6m
You can then access your `nginx-ingress` at `http://[YOUR_LOAD_BALANCER_URL]` via HTTP or `https://[YOUR_LOAD_BALANCER_URL]` via HTTPS. In order to test your `nginx-ingress`, I suggest you to [install a Wordpress](../installing-wordpress) on your cluster, and then create a YAML file for the Ingress that uses the controller: wzxhzdk:1 > [!primary] > Don't forget to replace `[YOUR_LOAD_BALANCER_URL]`, `[YOUR_WORDPRESS_SERVICE_NAME]` Apply the file: wzxhzdk:2 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_URL]` you will see your Wordpress: ![Wordpress using Ingress](images/installing-ingress-01.png){.thumbnail}