To understand what an ingress controller is, you need to understand the following two entities: service and ingress. We’ll explain in sequence what service, ingress, and ingress controller are.
A service in Kubernetes is an abstraction used to expose an application running on a set of pods. A service provides access to those pods through a single IP address. Pods can die, be recreated, and change their internal IP addresses, but they can still be accessed through the same service IP address. A service distributes the incoming traffic to all pods within it.
Ingress is a Kubernetes object represented as a set of rules used to route external traffic (ingress) across services inside a cluster. For example, you can map the "/login" route to a specific service in your cluster. So, when a user requests "yourwebsite.com/login", the traffic will be redirected to the service that is responsible for user logins.
To route external traffic to your application, you need three components:
To fulfill ingress, you need an ingress controller.
An ingress controller is a Kubernetes tool that reads ingress objects and creates a map of services in a cluster. This article will tell you how to use the Gcore ingress controller. If you prefer to use the Nginx ingress controller, refer to the article "Install and set up the Nginx ingress controller".
Gcore provides an out-of-the-box ingress controller. Once you apply an ingress manifest, the controller creates a Gcore load balancer automatically. A load balancer is created for every single ingress object. A load balancer will serve as an entry point for all incoming traffic and then deliver it to pods based on rules specified in services and ingress objects.
So, if you have an application running in a Kubernetes cluster, you first need to provide access to its pods by creating a service and then provide access from the Internet by creating an ingress object.
1. Create a YAML file in any text or code editor:
Enter your custom values instead:
2. Run the kubectl command from the file directory:
kubectl apply -f <name of the created YAML-file>
You’ll get the output:
service/<service name> created
Congratulations! You’ve created a service of the default ClusterIP type. For more information about other types of Kubernetes services, refer to the official Kubernetes documentation.
A Gcore ingress controller is pre-installed by default, so you only need to create an ingress object.
1. Create a YAML file in any text or code editor:
Enter your custom values instead:
2. Run the kubectl command from the file directory:
kubectl apply -f <name of the created YAML-file>
You’ll get the output:
Ingress/<name of the created ingress object> created
Congratulations! You’ve created and applied an ingress object for the Gcore ingress controller. Now it will automatically create a Gcore load balancer on your behalf. It will be shown in your Control panel in the Load Balancers section.
If you want to see an IP address of the load balancer through which the traffic comes, view it in the Control panel or run the command:
kubectl get ingress <ingress name>
You’ll get the output:
The IP address is written in the ADDRESS column.
Was this article helpful?
Discover our offerings, including virtual instances starting from 3.7 euro/mo, bare metal servers, AI Infrastructure, load balancers, Managed Kubernetes, Function as a Service, and Centralized Logging solutions.