Ingress is used to map external URLs to k8s cluster services, PODS are accessible within the cluster
To expose the Pods outside the cluster, we are using the service concept
ClusterIP
NodePort
LoadBalancer
Services are accessible only within the cluster. so we need to run ingress to Route the traffic from outside to the services
Step 1: Setting up Ingress
# Clone the repo from GIt
$ git clone https://github.com/rjthapaa/kubernetes_ingress.git
$ cd kubernetes-ingress
# create namespace and service-account
$ kubectl apply -f common/ns-and-sa.yaml
$ cat common/ns-and-sa.yaml
# Create RBAC and configmap
$ kubectl apply -f common/
# Deploy ingress controller
- We have 2 options to deploy ingress controller
Deployment
DaemonSet
$ kubectl apply -f daemon-set/nginx-ingress.yaml
# Get ingress pods using namespace
$ kubectl get all -n nginx-ingress
# Create LBR service
$ kubectl apply -f service/loadbalancer-aws-elb.yaml
Note : It will generate LBS DNS for Ingress controller
LoadBalancer is created in the Aws console
Now we can map the DNS name of LoadBalancer to the route 53 domain.
All the customer requests come to the Domain from the domain ingress enroute the traffic is based on the particular service.
Step 2: Create an Ingress with path-based routing with two applications
$ vi javawebapp.yaml
$ vi mavenwebapp.yaml
$ vi ingress.yaml
Link for yaml code
$ kubectl apply -f javawebapp.yaml
$ kubectl apply -f mavenwebapp.yaml
$ kubectl apply -f ingress.yaml
$ kubectl get pods
Check if the pods are running fine
Access the application with domainname followed by application