|
| 1 | +# Route Rule |
| 2 | + |
| 3 | +Instead of using CSE and route config to manage route, mesher supports Istio as a control plane to set route rule and follows the envoy API reference to manage route. This page gives the examples to show how requests are routed between micro services. |
| 4 | + |
| 5 | +## Mesher Configurations |
| 6 | + |
| 7 | +In **Consumer** router.yaml, you can set router.infra to define which router plugin mesher fetches from. The default router.infra is cse, which means the routerule comes from route config in CSE config-center. If router.infra is set to be pilot, the router.address is necessary, such as the in-cluster istio-pilot grpc address. |
| 8 | + |
| 9 | +```yaml |
| 10 | +router: |
| 11 | + infra: pilot # pilot or cse |
| 12 | + address: http://istio-pilot.istio-system:15010 |
| 13 | +``` |
| 14 | +
|
| 15 | +In **Both** consumer and provider registry configurations, the recommended one shows below. |
| 16 | +
|
| 17 | +```yaml |
| 18 | +cse: |
| 19 | + service: |
| 20 | + registry: |
| 21 | + registrator: |
| 22 | + disabled: true |
| 23 | + serviceDiscovery: |
| 24 | + type: pilot |
| 25 | + address: http://istio-pilot.istio-system:8080 |
| 26 | +``` |
| 27 | +
|
| 28 | +## Kubernetes Configurations |
| 29 | +
|
| 30 | +The provider applications of v1, v2 and v3 version could be deployed in kubernetes cluster as **Deployment** with differenent labels. The labels of version is necessary now, and you need to set env to generate nodeID in Istio system, such as **POD_NAMESPACE, POD_NAME** and **INSTANCE_IP**. |
| 31 | +
|
| 32 | +```yaml |
| 33 | +apiVersion: extensions/v1beta1 |
| 34 | +kind: Deployment |
| 35 | +metadata: |
| 36 | + labels: |
| 37 | + version: v1 |
| 38 | + app: pilot |
| 39 | + name: istioserver |
| 40 | + name: istioserver-v1 |
| 41 | + namespace: default |
| 42 | +spec: |
| 43 | + progressDeadlineSeconds: 600 |
| 44 | + replicas: 1 |
| 45 | + revisionHistoryLimit: 10 |
| 46 | + selector: |
| 47 | + matchLabels: |
| 48 | + app: pilot |
| 49 | + version: v1 |
| 50 | + name: istioserver |
| 51 | + strategy: |
| 52 | + rollingUpdate: |
| 53 | + maxSurge: 1 |
| 54 | + maxUnavailable: 1 |
| 55 | + type: RollingUpdate |
| 56 | + template: |
| 57 | + metadata: |
| 58 | + labels: |
| 59 | + app: pilot |
| 60 | + version: v1 |
| 61 | + name: istioserver |
| 62 | + spec: |
| 63 | + containers: |
| 64 | + - image: gosdk-istio-server:latest |
| 65 | + imagePullPolicy: Always |
| 66 | + name: istioserver-v1 |
| 67 | + ports: |
| 68 | + - containerPort: 8084 |
| 69 | + protocol: TCP |
| 70 | + resources: {} |
| 71 | + terminationMessagePath: /dev/termination-log |
| 72 | + terminationMessagePolicy: File |
| 73 | + env: |
| 74 | + - name: CSE_SERVICE_CENTER |
| 75 | + value: http://istio-pilot.istio-system:8080 |
| 76 | + - name: POD_NAME |
| 77 | + valueFrom: |
| 78 | + fieldRef: |
| 79 | + apiVersion: v1 |
| 80 | + fieldPath: metadata.name |
| 81 | + - name: POD_NAMESPACE |
| 82 | + valueFrom: |
| 83 | + fieldRef: |
| 84 | + apiVersion: v1 |
| 85 | + fieldPath: metadata.namespace |
| 86 | + - name: INSTANCE_IP |
| 87 | + valueFrom: |
| 88 | + fieldRef: |
| 89 | + apiVersion: v1 |
| 90 | + fieldPath: status.podIP |
| 91 | + volumeMounts: |
| 92 | + - mountPath: /etc/certs/ |
| 93 | + name: istio-certs |
| 94 | + readOnly: true |
| 95 | + dnsPolicy: ClusterFirst |
| 96 | + initContainers: |
| 97 | + restartPolicy: Always |
| 98 | + schedulerName: default-scheduler |
| 99 | + securityContext: {} |
| 100 | + terminationGracePeriodSeconds: 30 |
| 101 | + volumes: |
| 102 | + - name: istio-certs |
| 103 | + secret: |
| 104 | + defaultMode: 420 |
| 105 | + optional: true |
| 106 | + secretName: istio.default |
| 107 | +``` |
| 108 | +
|
| 109 | +## Istio v1alpha3 router configurations |
| 110 | +
|
| 111 | + [Traffic-management](https://istio.io/docs/tasks/traffic-management/request-routing/) gives references and examples of Istio new router rule schema. First, subsets is defined according to labels. Then you can set route rule of differenent weight for virtual services. |
| 112 | +
|
| 113 | +```yaml |
| 114 | +apiVersion: networking.istio.io/v1alpha3 |
| 115 | +kind: DestinationRule |
| 116 | +metadata: |
| 117 | + name: istioserver |
| 118 | +spec: |
| 119 | + host: istioserver |
| 120 | + subsets: |
| 121 | + - name: v1 |
| 122 | + labels: |
| 123 | + version: v1 |
| 124 | + - name: v2 |
| 125 | + labels: |
| 126 | + version: v2 |
| 127 | + - name: v3 |
| 128 | + labels: |
| 129 | + version: v3 |
| 130 | +``` |
| 131 | +
|
| 132 | +> **NOTICE: The subsets only support labels of version to distinguish differenent virtual services, this constrains will canceled later.** |
| 133 | +
|
| 134 | +```yaml |
| 135 | +apiVersion: networking.istio.io/v1alpha3 |
| 136 | +kind: VirtualService |
| 137 | +metadata: |
| 138 | + name: istioserver |
| 139 | +spec: |
| 140 | + hosts: |
| 141 | + - istioserver |
| 142 | + http: |
| 143 | + - route: |
| 144 | + - destination: |
| 145 | + host: istioserver |
| 146 | + subset: v1 |
| 147 | + weight: 25 |
| 148 | + - destination: |
| 149 | + host: istioserver |
| 150 | + subset: v2 |
| 151 | + weight: 25 |
| 152 | + - destination: |
| 153 | + host: istioserver |
| 154 | + subset: v3 |
| 155 | + weight: 50 |
| 156 | + |
| 157 | +``` |
0 commit comments