将混合器策略应用于特定服务



我有一个混音器策略和适配器,它将在我传递的令牌中查找auth_key,但它适用于我默认命名空间中的所有 Pod。我需要能够访问默认命名空间中的两个 pod 才能登录,并被授予允许我通过此规则的标头。那么我可以列出我要应用此规则的 pod 的名称,而不是将其应用于所有 pod 吗?

# handler for adapter mygrpcadapter
apiVersion: "config.istio.io/v1alpha2"
kind: handler
metadata:
 name: h1
 namespace: istio-system
spec:
 adapter: mygrpcadapter
 connection:
#   address: "[::]:44225"
   address: "mygrpcadapterservice:44225"
   #address: "35.184.34.117:44225"
 params:
   auth_key: "Bearer"
---
apiVersion: "config.istio.io/v1alpha2"
kind: instance
metadata:
 name: icheck
 namespace: istio-system
spec:
 template: authorization
 params:
   subject:
     properties:
       custom_token_header:  request.headers["authorization"]
---
# rule to dispatch to handler h1
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
 name: r1
 namespace: istio-system
spec:
 actions:
 - handler: h1.istio-system
   instances:
   - icheck
---
Istio Mixer 规则

具有 match 属性,您可以使用它通过匹配 Istio Mixer 属性来指定在何处应用规则。

例如,从 Istio 文档中:

match(destination.service.host, "ratings.*( 选择任何请求 定位名称以"评级"开头的服务

最新更新