Kubernetes Service and Ingress. Pt2
This is a continuation to my previous article published earlier, don’t worry about missing the first part, follow this link https://cloud-ops.hashnode.dev/kubernetes-service-and-ingress-pt1 .
We previously discussed creating an Nginx-ingress deployment with a single replica, however, you’re allowed to deploy as many ingress services as you want but Nginx-ingress is the most preferred amongst other ingress-controller. After creating our ingress controller, we proceed to create the ingress resources. The ingress resource is where we map the services connected to an application pod. They are rules used in setting up our ingress resources. The rules have their specific purpose which are used to;
Allow traffic based on URL
Forward traffic to a single configuration
Route traffic to the domain name itself.
The important part of an ingress resource is the rules, which is used to specify the type of traffic, be it HTTP or HTTPS, it is also used to specify the host or domain name of the web application and the path traffic is routed to when end-users try to reach our applications. It also consists of the backend rule. This rule specifies the service where traffic is routed to. Normally,end-users reach our application pods through services created, the details of service is defined in the backend section of our ingress resource rules. Here is a simple definition file of an ingress resource.
apiVersion: extensions/v1/beta1
kind: Ingress
metadata:
name: ingress-rule1
spec:
rules:
- http:
paths:
path: /google.com
backend:
serviceName: google-service
servicePort: 80
This is a simple ingress resource definition file named ingress-rule1. It controls and load-balance traffic coming and going out of /google.com. We can also create an igress resource and mount a host path using the same definition file.
apiVersion: extensions/v1/beta1
kind: Ingress
metadata:
name: ingress-rule1
spec:
rules:
- host: www.google.com
http:
paths:
path: /mail
backend:
serviceName: google-service
servicePort: 80
There is more to understanding how k8s ingress work but if you want to know or get more information on k8s ingress i will recommend you visit the official page of kubernetes ingress. Read more here kubernetes.io/docs/concepts/services-networ..