Skip to content

12_Ingress_Lab

deepak gupta edited this page Feb 9, 2022 · 12 revisions

K8s | Ingress Lab

Problem Statement:-

In this lab, we will use ingress to map our internal services to the domain and use a fanout to access our backend. We will have below rules in our ingress:

  • -ems.k8slearning.io -> Frontend By the end of this lab, you will have ingress in place to manage external access.

What you will not have is advanced deployment features such as:

  • Ensuring that if your application is ready to function then only k8s sends requests to it.
  • If your application has become non-responsive k8s will restart it.
  • You can control which nodes your application pod will get deployed.

So we are going to use value "tony-stark" in our case. You must change it according to you

Important:- We are assuming that you guys have already created the Deployment and Services. If not, please refer here for Deployment and Service. Make sure you only create Deployment and Service not Replicasets.

Enable Ingress Minikube

We have to install the ingress in minikube, but it is pretty much straight-forward.

minikube start --vm=true
minikube addons enable ingress

Frontend

We have to create ingress manifest for frontend with name frontend-ingress.yaml

apiVersion: networking.k8s.io/v1beta1 # for versions before 1.14 use extensions/v1beta1
kind: Ingress
metadata:
  name: frontend-ingress
spec:
  rules:
  - host: tony-stark.k8slearning.io
    http:
      paths:
      - path: /
        backend:
          serviceName: empms-frontend-<name>
          servicePort: 5000

Create the frontend ingress resource.

kubectl apply -f frontend-ingress.yaml

Validate the ingress

kubectl get ingress

Verifying the flow

For verifying the flow, we have to map the Ingress external IP with the domain name which we have provided above.

minikube ip

The output of minikube IP command:-

172.17.0.3

Add this entry in your /etc/hosts file.

172.17.0.3 tony-stark.k8slearning.io

In case of EKS, use this IP 54.191.112.254 to make /etc/hosts entry