Let's now add an important element to our cluster, in order to get closer and closer to creating an HA cluster.
What is Ingress?
In Kubernetes, an Ingress is a object that allows access to your Kubernetes services from outside the cluster. The ingress is made up of 2 parts: the kubernetes component that deals with directing external traffic to internal services is called the ingress controller, which obeys the rules present in the ingress resources. So, you configure access by creating a collection of rules, written in a file, that define which inbound connections reach which services. Without the use of the ingress, all the cluster services, to which one wishes to access from the outside, must be exposed to the internet. The advantage of the ingress consists, in fact, in exposing a single access point externally, which will take care of routing the traffic within the cluster.
Ingress installation
Prerequisites
First we added a new node to the cluster, which will take care of routing incoming requests to the appropriate services. So we created a new VM (Launch and manage instances) with a low-medium flavor, as it should only act as an ingress, and joined it to cluster (Building the cluster). We then assigned to the node, through a label, the "role" of ingress with the command
# Enter the node name and label. The optional "--overwrite" flag is used in case the value is already present $ kubectl label node <node_name> kubernetes.io/role=<label_value> [--overwrite]
The addition of the label will be used later, to indicate on which node to install the input controller Pod. The same operation can also be performed on the other nodes, in order to obtain
# Note the "ROLES" column $ kubectl get node NAME STATUS ROLES AGE VERSION mycentos-0.novalocal Ready master 70d v1.19.1 mycentos-1.novalocal Ready worker 69d v1.19.1 mycentos-2.novalocal Ready worker 69d v1.19.1 mycentos-ing.novalocal Ready ingress 4d19h v1.19.1
Ingress Controller