Kubernetes Ingress – All you need to know!

Filed Under: Random
Kubernetes Ingress

Hello, readers! In this article, we will be focusing on Kubernetes Ingress in detail. So, let us begin! 馃檪

Recommended read – Kubernetes components

What is Kubernetes Ingress?

Kubernetes Ingress is a k8 API object that orchestrates and decides the exposure of all the external access to services defined within the cluster. That is, it routes the traffic and controls the same through the resource.

Ingress manages the external exposure and access to the services basically HTTP and HTTPS routes. It is termed useful mostly when we want to have some external HTTP(s) connections to expose it to the services or applications within the pods inside the cluster. For the same, we configure the ingress resource to the services through external DNS-wise URLs, load-balancers, etc.

Let us consider an example to understand the role and need of Ingress object.

Consider we have an application that is running on a pod within a cluster. We do have a service exposed to it. Now, we wish to connect to the application through some external URL let us say https://hello-world.com, for this without the ingress rules defined, no URLs would have access to the app through the service.

For the same, we would need to define the ingress resource and mention the URL in the resource for it to have an external access exposed.


Kubernetes Ingress Template

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-app
spec:
  rules:
  - host: "hello-world.com"
    http:
      paths:
      - pathType: Prefix
        path: "/app"
        backend:
          service:
            name: service-app
            port:
              number: 80

Here’s a list of the variables contained in the above template:

  • The metadeta.name field specifies the name of the ingress rule/resource.
  • In the HTTP rules, the host is the URL or the external domain which needs access routed to the application. If provided, the rules would be applicable to the host.
  • The paths are the associated backend defined by the service name.
  • The backend includes the backend information for exposure i.e. the service name and the defined port number to have a stable connection routed.

Using the below command, we can apply the ingress rules to the namespace:

kubectl apply -f ingress.yaml -n namespace-name

Further, we can describe and understand the ingress resource created using the below command:

kubectl get ingress ingress-name

Role of a Kubernetes Ingress Controller

In order for the ingress rules to work, we need to have an Ingress controlled deployed on the kubernetes cluster we create.

The ingress controller at the backend manages and orchestrates the ingress resources for the applications within the cluster. If the ingress controller goes down, all the externally exposed routes would stop working.


Types of k8 Ingress resources

  1. Ingress resource backend by a single k8 Service – This is the simplest form of ingress rule that binds the external policy with the single service with the default backend rules.
  2. Simple fanout: In this type of ingress, all the exposed traffic is supposed to route from a single IP address to all the services associated/backend with the ingress.
  3. Name-based virtual hosting: In this type of ingress, a single IP address is capable of routing the traffic to multiple hosts that would again be exposed to multiple services backed to the ingress.

Conclusion

By this, we have come to the end of this topic. Feel free to comment below, in case you come across any questions. For more such posts related to Kubernetes and Docker, Stay tuned with us.

Till then, Happy Learning!! 馃檪

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content