Monday, June 28, 2021

ISTIO consuming Microservice using Gateway and Virtual service.

 In previous example we were able to see the version graph for our Microservice components.

http://siddharathadhumale.blogspot.com/2021/06/deploying-different-version-of.html

Also lets try to access our microservice using url i.e. DNS name and using gateway and virtualservice rather than exposing it using port-forward and accessing it using localhost.

Please follow belwo step religiously. We assume you have complete new docker and kubernetes env without installation of ISTIO.

Check istio system have svc for istio-ingressgateway and it should either be having external IP as localhost or ipaddress.
C:\Users\Siddhartha>kubectl -n istio-system get svc istio-ingressgateway

Create Namespce
C:\Users\Siddhartha>kubectl create namespace springboot-application

Label namespace with istio-injection=enabled
C:\Users\Siddhartha>kubectl label namespace springboot-application istio-injection=enabled

Check namespace is labeled properly
C:\Users\Siddhartha>kubectl get ns springboot-application –-show-labels

Apply gateway
C:\Istio-workspace>kubectl apply -f gatewayV1.yaml

Apply Virtual service
C:\Istio-workspace>kubectl apply -f virtual-serviceV1.yaml

Apply Producer-Pod-v1
C:\Istio-workspace>kubectl apply -f springboot-docker-producerV1.yaml

Apply Producer-Pod-v2
C:\Istio-workspace>kubectl apply -f springboot-docker-producerV2.yaml

Apply consumer-Pod-v1
C:\Istio-workspace>kubectl apply -f springboot-docker-consumerV1.yaml

check all containers are in running mode
C:\Istio-workspace>kubectl get all -n springboot-application -o wide

Apply kiali and other add ons
C:\Users\Siddhartha>kubectl apply -f C:\istio-1.10.1\samples\addons

Get all svc for istio-system.
C:\Istio-workspace>kubectl get svc -n istio-system

Check if the required kiali pod is ready to be exposed.
C:\Istio-workspace>kubectl get pod -n istio-system

Open the kiali ui using forward
C:\Users\Siddhartha>kubectl port-forward svc/kiali -n istio-system 20001

Check pod is ready for forwarding
C:\Istio-workspace> kubectl get all -n springboot-application -o wide

Open the Producer-Pod-v1 on browser using forward
C:\Users\Siddhartha>kubectl port-forward 8091:8091 -n springboot-application

Open the consumer-Pod-v1 on browser using forward
C:\Users\Siddhartha>kubectl port-forward 8090:8090 -n springboot-application

Loop the request to check if we are getting he flow chart on Kiali
C:\Users\Siddhartha>curl http://localhost:8090/getEmployee?%5B1-200%5D; sleep 2;

Now lets try to access the same using dns name

Make sure to enter following entries inside your host files
127.0.0.1 mysiddhuweb.example.com

Now lets run C:\Users\Siddhartha>curl http://mysiddhuweb.example.com/getEmployee?%5B1-200%5D; sleep 2;

You can download the code from here

Producer GIT
https://github.com/shdhumale/springboot-docker-producer.git
Consumer
https://github.com/shdhumale/springboot-docker-consumer-version.git
YAML Files
https://github.com/shdhumale/kialiyaml.git

No comments: