ClusterIP, NodePort, Load Balancer, and Ingress Controller
ClusterIP and NodePort are used to provide internal access to services within the Kubernetes cluster, while Load Balancer and Ingress Controller are used to expose services externally to the world outside the cluster.
Here is an overview of each of these components:
- ClusterIP: This is a type of service that provides a stable IP address and DNS name for a set of pods within a Kubernetes cluster. It allows other pods within the same cluster to access the service using the IP address or DNS name.
my-service
that selects all Pods with the label app: my-app
, and exposes them on port 80 using TCP. The Service is automatically assigned a ClusterIP.2. NodePort: This is a type of service that exposes a service on a port on each node in the Kubernetes cluster. It allows external traffic to access the service by targeting the IP address of any node in the cluster and the NodePort.
my-service
that selects all Pods with the label app: my-app
, and exposes them on port 80 using TCP. The Service is also exposed on a random port (by default in the range 30000-32767) on each node in the cluster.3. Load Balancer: This is a type of service that exposes a service externally using a cloud provider’s load balancer. It allows external traffic to access the service by targeting the IP address of the load balancer.
my-service
that selects all Pods with the label app: my-app
, and exposes them on port 80 using TCP. The Service is also exposed using an AWS Network Load Balancer.4. Ingress Controller: This is a type of controller that manages and routes external traffic to services running within a Kubernetes cluster based on rules defined in the Ingress resource. It acts as an API gateway for external traffic to access services within the cluster.
To create an Ingress Controller, you can install an Ingress Controller implementation such as nginx-ingress or traefik using a Helm chart or a Kubernetes deployment manifest.
For example, to install nginx-ingress using Helm, you can run the following commands:
This installs the nginx-ingress chart and creates an Ingress Controller named my-ingress. You can then define an Ingress resource that maps incoming requests to services in the cluster. For example:
mydomain.com
to the my-service
Service on port http
.This is a brief overview of ClusterIP, NodePort, Load Balancer, and Ingress Controller and to implement each service.
Please let me know if this was helpful.
Thank you for reading!!
DevOps Engineer