Creating a destination rule

 DestinationRule is just a definition that establishes a binding between a subset and the labels that are defined at the service level. A subset is a named set for one or more versions of the same service. Let's take a look:

  1. Let's look at one of the destination rule reviews in 02-create-destination-rules.yaml:
# Script : 02-create-destination-rules.yaml

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: reviews
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
- name: v3
labels:
version: v3

The name of the destination rule is reviews, while the host field has the service name reviews. It has three subsets defined within it. The v1 subset has an association for label version: v1 and so on.

  1. Let's look at the reviews pods and examine the labels assigned to these pods:
$ kubectl -n istio-lab get pods -l app=reviews --show-labels
NAME READY STATUS RESTARTS AGE ---
reviews-v1-69b9dddccf-bsfps 2/2 Running 0 102m ---
reviews-v2-84c46bf56d-48ks9 2/2 Running 0 102m ---
reviews-v3-64ff5788c7-5xzbk 2/2 Running 0 102m ---

--- LABELS
--- app=reviews,pod-template-hash=69b9dddccf,version=v1
--- app=reviews,pod-template-hash=84c46bf56d,version=v2
--- app=reviews,pod-template-hash=64ff5788c7,version=v3

Notice that the three review pods have a label of version assigned to them and that the values are set to v1, v2and v3 for each pod. 

By defining the destination rule reviews, we have defined three different subsets (v1, v2and v3), which make a binding between the reviews service to different reviews pods.

  1. Create destination rules for all of the microservices within Bookinfo:
$ kubectl -n istio-lab apply -f 02-create-destination-rules.yaml
destinationrule.networking.istio.io/productpage created
destinationrule.networking.istio.io/reviews created
destinationrule.networking.istio.io/ratings created
destinationrule.networking.istio.io/details created

Defining a subset through a destination rule does nothing except define a rule. This binding comes into force when we use the subset in the VirtualService definition.

The virtual service that we created previously defined a routing relationship between a service and the Istio gateway. We will now modify the same service to pin the routing of reviews service to version v1 of the pod.

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

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