九 Istio:istio安全之授权( 四 )


apiVersion: security.istio.io/v1beta1 kind: AuthorizationPolicy metadata:name: allow-web-frontend-customersnamespace: default spec:selector:matchLabels:app: customersversion: v1action: ALLOWrules:- from:- source:namespaces: ["default"]source:principals: ["cluster.local/ns/default/sa/web-frontend"]将上述 YAML 保存为 allow-web-frontend-customers.yaml,并使用 kubectl apply -f allow-web-frontend-customers.yaml 创建策略 。
一旦策略被创建 , 我们将看到 Web 前端再次工作——它将获得 customers 服务的回应 。
我们使用了多个授权策略 , 明确地允许从入口到前端以及从前端到 customers 服务的调用 。使用 deny-all 策略是一个很好的开始,因为我们可以控制、管理,然后明确地允许我们希望在服务之间发生的通信 。
4.2 清理删除 Deployment、Service、VirtualService 和 Gateway:
kubectl delete sa customers-v1 web-frontend kubectl delete deploy web-frontend customers-v1 kubectl delete svc customers web-frontend kubectl delete vs customers web-frontend kubectl delete gateway gateway kubectl delete authorizationpolicy allow-ingress-frontend allow-web-frontend-customers deny-all kubectl delete pod curl

推荐阅读