Skip to content

Instantly share code, notes, and snippets.

@nashmaniac
Created May 9, 2020 02:09
Show Gist options
  • Save nashmaniac/1dd43ec81e1d92c798003e5dc6f2e791 to your computer and use it in GitHub Desktop.
Save nashmaniac/1dd43ec81e1d92c798003e5dc6f2e791 to your computer and use it in GitHub Desktop.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: user-virtual-service #self explanatory
namespace: traffic-management #self explanatory
spec:
hosts: # a virtual service can redirect requests for multiple hosts. this is more of a filtering hosts
- user.traffic-management.retailvoice.xyz
gateways: # a virtual service can also received requests from multiple gateway
- traffic-management/ingressgateway # always safe to access with namespaces
http:
# it actually saying when I get any requests for user.microservice.retailvoice.xyz,
# just redirect it to user-service.traffic-management.svc.cluster.local on port 8000
# if only one port configuration present in user-service.traffic-management.svc.cluster.local then
# you can omit the port configuration portion
- route:
- destination:
host: user-service.traffic-management.svc.cluster.local # this format is safe. But if virtual service and cluster ip service are in same namespace only service name user-service would be enough
subset: version1
weight: 90
- destination:
host: user-service.traffic-management.svc.cluster.local # this format is safe. But if virtual service and cluster ip service are in same namespace only service name user-service would be enough
subset: version2
weight: 10
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: user-destination-rule #self explanatory
namespace: traffic-management #self explanatory
spec:
host: user-service.traffic-management.svc.cluster.local # for which incoming service it will be triggered.
subsets:
- name: version1 # custom name
labels:
version: v1 # version label we used in our deployment
- name: version2
labels:
version: v2 # version label we used in our deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment