【发布时间】:2020-07-04 05:31:36
【问题描述】:
所以我有一个非常独特的情况。 问题 不应用虚拟服务路由规则。我们的集群中有一个buzzfeed sso 设置。我们想将响应头修改为即添加头。到与 uri sign_in 匹配的每个请求。 Buzzfeed sso 有自己的命名空间。 现在为了实现这一点,我创建了一个虚拟服务。 复制步骤: 我们使用这个虚拟服务规范来创建路由规则。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: sso-auth-injector
spec:
hosts:
- sso-auth
http:
- match:
- uri:
prefix: /sign_in
ignoreUriCase: true
route:
- destination:
host: sso-auth
headers:
response:
add:
foo: bar
request:
add:
hello: world
分析
Istioctk x describe 有输出 吊舱:sso-auth-58744b56cd-lwqrh.sso Pod 端口:4180(sso-auth)、15090(istio-proxy) 建议:为 Istio 遥测添加“app”标签。 建议:为 Istio 遥测添加“版本”标签。 服务:sso-auth.sso 端口:http 80/HTTP 目标 pod 端口 4180 Pod 是 PERMISSIVE(强制执行 HTTP/mTLS)并且客户端使用 HTTP 虚拟服务:sso-auth-injector.sso /sign_in 不加壳 2)Istioctl。不附加所有规则,但用于出站|80|
"routes": [
{
"match": {
"prefix": "/sign_in",
"caseSensitive": false
},
"route": {
"cluster": "outbound|80||sso-auth.sso.svc.cluster.local",
"timeout": "0s",
"retryPolicy": {
"retryOn": "connect-failure,refused-stream,unavailable,cancelled,resource-exhausted,retriable-status-codes",
"numRetries": 2,
"retryHostPredicate": [
{
"name": "envoy.retry_host_predicates.previous_hosts"
}
],
"hostSelectionRetryMaxAttempts": "5",
"retriableStatusCodes": [
503
]
},
"maxGrpcTimeout": "0s"
},
"metadata": {
"filterMetadata": {
"istio": {
"config": "/apis/networking/v1alpha3/namespaces/sso/virtual-service/sso-auth-injector"
}
}
},
"decorator": {
"operation": "sso-auth.sso.svc.cluster.local:80/sign_in*"
},
"typedPerFilterConfig": {
"mixer": {
"@type": "type.googleapis.com/istio.mixer.v1.config.client.ServiceConfig",
"disableCheckCalls": true,
"mixerAttributes": {
"attributes": {
"destination.service.host": {
"stringValue": "sso-auth.sso.svc.cluster.local"
},
"destination.service.name": {
"stringValue": "sso-auth"
},
"destination.service.namespace": {
"stringValue": "sso"
},
"destination.service.uid": {
"stringValue": "istio://sso/services/sso-auth"
}
}
},
"forwardAttributes": {
"attributes": {
"destination.service.host": {
"stringValue": "sso-auth.sso.svc.cluster.local"
},
"destination.service.name": {
"stringValue": "sso-auth"
},
"destination.service.namespace": {
"stringValue": "sso"
},
"destination.service.uid": {
"stringValue": "istio://sso/services/sso-auth"
}
}
}
}
},
"requestHeadersToAdd": [
{
"header": {
"key": "hello",
"value": "world"
},
"append": true
}
],
"responseHeadersToAdd": [
{
"header": {
"key": "foo",
"value": "bar"
},
"append": true
}
]
}
]
},
问题/疑问
这些规则不生效。每个请求都传递给服务,但不修改标头。 路由规则不应该适用于入站请求而不是出站请求(如生成的配置所示)。
【问题讨论】:
标签: header virtual mesh istio gateway