istio destination rule subset don't really work
Istio destination rule routes to a service. Then the service uses selector to match against running pods that has certain labels for example, app=version.
When a request comes in, it goes around in a round robin fashion (depending on the weight configure) it goes to hit individual pods.
So the subset is quite meaningless - really confusing as shown below.
If i really wanted to change the routing behavior, all i need to do is change the deployment->spec->selector->matchLabels->version: v3 to something else. This will make it hidden from service's selector.
If you change the app: reviews to review-3 it is elusive to the service and won't be picked up and route stops.
This is my service configuration
apiVersion: v1
kind: Service
metadata:
name: reviews
labels:
app: reviews
service: reviews
spec:
ports:
- port: 9080
name: http
selector:
app: reviews
Some additional notes:
Service selector uses pods label to decide what to managed.
if you have 3 labels defined in your service selector, then it all needs to match to the pod
for example, if your selector has (selector not the service label - as many people tend to get confused with)
- app: v1
- version: v1
- owner: v1
then your pod label should have all these 3 defined before it can form a 'route'
In order for istio to work, we have to be very careful with spec->ports->name as it has to be http or http-web or http-config. It must start with http.
Destination rule commented out as shown below but the routing still goes to all 3 rating reviews.
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
# trafficPolicy:
# loadBalancer:
# simple: LEAST_REQUEST
Comments