Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As said previously, you must have an Ingress controller to satisfy an Ingress. Only creating an Ingress resource has no effect. There are several input controllers, here we will use one of the most used. Let Let's go, therefore, on the installation guide of start with the installation procedure. Here we will use the Nginx Ingress Controller for Kubernetes guide as a reference. For more information, we recommend that you consult the official guide (an installation with Heml is also available on the same site).

Before continuing with step 2 of the guide, let's stop for a moment, because we need to make some small changes to the files in the folder we just cloned from the GitHub repo. The files in question are located here:

  • /kubernetes-ingress/deployments/common/nginx-config.yaml
  • /kubernetes-ingress/deployments/deployment/nginx-ingress.yaml

In the first file you only need to add the following line, which explains the FIP of the new node

We perform a download from GitHub of the folder containing the necessary for the installation of the input controller and, once finished, we move on to its entirety

Code Block
languagebash
titleGitHub repo
$ git clone https://github.com/nginxinc/kubernetes-ingress/
$ cd kubernetes-ingress/deployments
$ git checkout v1.8.1

Before continuing, let's stop for a moment, because we need to make some small changes to the files in the folder we just cloned from the GitHub repo. The files in question are located here:

  • /kubernetes-ingress/deployments/common/nginx-config.yaml
  • /kubernetes-ingress/deployments/deployment/nginx-ingress.yaml

In the first file you only need to add the following line, which explains the FIP of the new node

Code Block
languageyml
titlenginx-config.yaml
kind: ConfigMap
Code Block
languageyml
titlenginx-config.yaml
kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
  namespace: nginx-ingress
data:
.
.
.
  external-status-address: "<FIP_Node>" #----- Insert the FIP of the node between the quotes

...

and uncomment the lines, present at the end of the file, indicated below (commented by default). This last change will come in handy when we create the ingress resource component.

Code Block
Code Block
languageyml
titlenginx-ingress.yaml (2)
args:
  - -nginx-configmaps=$(POD_NAMESPACE)/nginx-config
  - -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
 # - -v=3 # Enables extensive logging. Useful for troubleshooting.
   - -report-ingress-status                                              #----- Uncommented
 # - -external-service=nginx-ingress
 #- -enable-prometheus-metrics
 #- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
  - -enable-leader-election                                              #----- Uncommented
 #- -enable-custom-resources

...

With these changes made, we can continue with the steps presented in the official Nginx guide. If all went well, we should get the input controller podinstallation procedure

Code Block
languagebash
titleInstall Ingress Controller Pod
#$ Notekubectl thatapply the Pod is present on the "ingress" node and has its own IP-f common/ns-and-sa.yaml
$ kubectl apply -f rbac/rbac.yaml
$ kubectl getapply pod -nf common/nginx-config.yaml
$ kubectl apply -f common/default-server-secret.yaml
$ kubectl apply -f deployment/nginx-ingress.yaml

At the end, if all went well, we should get the input controller pod (note that the default namespace is nginx-ingress)

Code Block
languagebash
titleIngress Controller Pod
# Note that the Pod is present on the "ingress" node and has its own IP
$ kubectl get pod -n nginx-ingress -o wide
NAMEingress -o wide
NAME                             READY   STATUS    RESTARTS   AGE   IP               NODE
nginx-ingress-68d7b4bfdd-mw479            1/1     Running READY  0 STATUS    RESTARTS   AGE  20h IP  192.168.100.13   mycentos-ing.novalocal

Ingress resource

We now present the ingress resource through a complete example, present in the directory downloaded from GitHub (/kubernetes-ingress/examples/complete-example). Let's move inside the complete-example directory and run the commands

Code Block
languagebash
titleDirectory complete-example
$ ls
cafe-ingress.yaml  cafe-secret.yaml  cafe.yaml  dashboard.png  README.md
$ kubectl apply -f cafe.yaml
$ kubectl apply -f cafe-secret.yaml

At this point we check that the Pods and the associated services have been created

             NODE
nginx-ingress-68d7b4bfdd-mw479   1/1     Running   0          20h   192.168.100.13   mycentos-ing.novalocal

Ingress resource

We now present the ingress resource through a complete example, present in the directory downloaded from GitHub (/kubernetes-ingress/examples/complete-example). Let's move inside the complete-example directory and run the commands

Code Block
languagebash
titleDirectory complete-example
$ ls
cafe-ingress.yaml  cafe-secret.yaml  cafe.yaml  dashboard.png  README.md
$ kubectl apply -f cafe.yaml
$ kubectl apply -f cafe-secret.yaml

At this point we check that the Pods and the associated services have been created

Code Block
languagebash
titleCafe Pod&Service
# Two coffee pods and three tea pods have been created, as required within the "cafe.yaml" file
$ kubectl get pod -n nginx-ingress -o wide
NAME     
Code Block
languagebash
titleCafe Pod&Service
# Two coffee pods and three tea pods have been created, as required within the "cafe.yaml" file
$ kubectl get pod -n nginx-ingress -o wide
NAME                             READY   STATUS    RESTARTS   AGE   IP               NODE
coffee-5f56ff9788-7fv8t         READY 1/1  STATUS   Running RESTARTS  0 AGE   IP      20h   10.10.231.197    mycentos  NODE
coffee-5f56ff9788-7fv8t          1/1     Running   0          20h   10.10.231.197    mycentos-1.novalocal
coffee-5f56ff9788-l5l9h          1/1     Running   0          20h   10.10.94.70      mycentos-2.novalocal
tea-69c99ff568-68bnr             1/1     Running   0          20h   10.10.94.71      mycentos-2.novalocal
tea-69c99ff568-k457k             1/1     Running   0          20h   10.10.231.198    mycentos-1.novalocal
tea-69c99ff568-pb9wc             1/1     Running   0          20h   10.10.231.199    mycentos-1.novalocal

$ kubectl get svc -n nginx-ingress
NAME             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
coffee-svc       ClusterIP   10.107.81.22     <none>        80/TCP     20h
tea-svc          ClusterIP   10.110.106.241   <none>        80/TCP     20h

...

Panel
titlecafe.example.com
Server address: 10.10.94.71:8080
Server name: tea-69c99ff568-68bnr
Date: 23/Sep/2020:13:20:22 +0000
URI: /tea
Request ID: c2c8de16a55223239bdedee5abe4a8a4
--------------------------------------------------------
Server address: 10.10.94.70:8080
Server name: coffee-5f56ff9788-l5l9h
Date: 23/Sep/2020:13:07:09 +0000
URI: /coffee
Request ID: babe3fa35d62d2dc0efa6d60a58214e3

...

-----
Server address: 10.10.94.70:8080
Server name: coffee-5f56ff9788-l5l9h
Date: 23/Sep/2020:13:07:09 +0000
URI: /coffee
Request ID: babe3fa35d62d2dc0efa6d60a58214e3

These two web pages, while very simple, assure us that the addressing mechanism works correctly.

Uninstall the Ingress Controller

All the components created in this guide share the nginx-ingress namespace, so if we want to remove everything in one go, just type

Code Block
languagebash
titleUnistall Ingress Controller
$ kubectl delete namespace nginx-ingress
namespace "nginx-ingress" deleted
# Moreover, to delete the ClusterRole and ClusterRoleBinding 
$ kubectl delete clusterrole nginx-ingress
clusterrole.rbac.authorization.k8s.io "nginx-ingress" deleted
$ kubectl delete clusterrolebinding nginx-ingress
clusterrolebinding.rbac.authorization.k8s.io "nginx-ingress" deleted