特征流量分派
背景¶
在懒加载的方案中,默认会将首次请求的流量(找不到路由的流量)兜底至gs
但在实际落地过程中并不是所有流量都要兜底至gs, 也并不是兜底路由必须走global-sidecar
方案¶
通过envoyfilter方式,将流量转发至特定的 cluster
使用¶
在slimeboot中配置dispatches, 将域名是www.163.com
*.svc.cluster.local
(?:[^.])+
流量转发到_GLOBAL_SIDECAR
配置 passthroughByDefault,将兜底流量改成PASSTHROUGH
其中domains内容等同于envoy rds中的domain,支持前缀、后缀、精确
如果需要复杂的匹配规则,可以使用domainRegex
apiVersion: config.netease.com/v1alpha1
kind: SlimeBoot
metadata:
name: lazyload
namespace: mesh-operator
spec:
image:
pullPolicy: Always
repository: docker.io/slimeio/slime-lazyload
tag: v0.9.0
namespace: mesh-operator
istioNamespace: istio-system
module:
- name: lazyload
kind: lazyload
enable: true
general:
passthroughByDefault: true
dispatches:
- name: fake
domains:
- "www.163.com"
- "*.svc.cluster.local"
cluster: _GLOBAL_SIDECAR # dispatch特性,特殊标识,标识gs
- domainRegex: ^(?:[^.])+$
cluster: _GLOBAL_SIDECAR
autoPort: true
autoFence: true
defaultFence: true
wormholePort: # replace to your application service ports, and extend the list in case of multi ports
- "9080"
globalSidecarMode: cluster # the mode of global-sidecar
metricSourceType: accesslog # indicate the metric source
global:
log:
logLevel: info
slimeNamespace: mesh-operator
resources:
requests:
cpu: 300m
memory: 300Mi
limits:
cpu: 600m
memory: 600Mi
component:
globalSidecar:
enable: true
sidecarInject:
enable: true # should be true
mode: pod
labels: # optional, used for sidecarInject.mode = pod
sidecar.istio.io/inject: "true"
resources:
requests:
cpu: 200m
memory: 200Mi
limits:
cpu: 400m
memory: 400Mi
image:
repository: docker.io/slimeio/slime-global-sidecar
tag: v0.9.0
probePort: 20000