Running using Node Port

You can access a microservice through the Kubernetes service name, which is a connection from a fixed service IP address to the pod IP address. In this section, you will learn how to access a service using Node Port using the node's IP address. 

You can also view the service web page from outside the VM but within the firewall of an enterprise by using the server's IP address. This will require changing the service from ClusterIP to NodePort. Let's get started:

  1. Edit the productpage service:
$ kubectl -n istio-lab edit svc productpage
  1. Change the type from ClusterIP to NodePort.

You should have the following initially:

selector:
app: productpage
sessionAffinity: None
type: ClusterIP

Change this to the following:

selector:
app: productpage
sessionAffinity: None
type: NodePort
  1. Save the file and check the service:
$ kubectl -n istio-lab get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
details ClusterIP 10.106.179.223 <none> 9080/TCP 103m
productpage NodePort 10.100.221.255 <none> 9080:32384/TCP 103m
ratings ClusterIP 10.109.32.8 <none> 9080/TCP 103m
reviews ClusterIP 10.107.73.66 <none> 9080/TCP 103m
Or you can use the patch command to change the TYPE from ClusterIP to NodePort, as shown in the following command:

kubectl -n istio-lab patch svc productpage --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"}]'

A high port of 32384 has been assigned to the productpage service, which is mapped to port 9080. This port may be different in your case.

  1. Find out the name of the VM or master node of the Kubernetes cluster:
# kubectl get nodes
NAME STATUS ROLES AGE VERSION
osc01.servicemesh.local Ready master 5h24m v1.15.6
  1. Access the web page from a browser on Windows or macOS using http://osc01.servicemesh.local:32384. You may need to change the port as it may be different in your case.

If you receive an err_connection_refused error, make sure that you are using the port as per your environment's output.

An external IP address is assigned to the Istio Ingress gateway, which can be used to access the application (productpage). The external IP address might be coming from an external load balancer that is on the edge of the Kubernetes cluster. In the previous chapter, we simulated an external load balancer using keepalived.

Next, we'll explore the concept of the Istio destination rule, which defines metadata for traffic shifting rules based on labels that have been defined on services.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.55.14