1、CNCF云原生专场徐中虎 2021年07月10日云原生服务网格安全解密About me徐中虎(hzxuzhonghu)华为云云原生开源工程师Istio Steering Committee委员Istio社区资深Maintainer,核心贡献者 Volcano项目维护者Kubernetes 核心贡献者云原生服务网格-Istio联合作者服务网格安全概述微服务安全需求:-为防御中间人攻击,流量需要加密-为了提供灵活的服务访问控制,需要双向 TLS 和细粒度的访问策略。-为了明确服务访问细节,需要AuditIstio服务网格安全目标:-默认安全:无需更改应用程序代码和基础架构,零配置-深度防御:与现有
2、安全系统集成,提供多层防御-零信任网络:在不受信任的网络上构建安全解决方案Istio安全架构Istio安全模型-Service-Service数据面通信 自动双向TLS认证,默认安全加密 工作负载身份独立,符合SPIFFEE格式:cluster.local/ns/default/sa/sleep,身份基于Kubernetes ServiceAccount-Authentication x509认证,JWT认证-Authorization 内置授权,外部授权证书管理证书Provision-SDS:动态Provision,Istio负责证书轮换-自动挂载:静态Provision,可以通过K8s S
3、ecret挂载,或者VM手动提供证书签发-Plug in CA证书-个性化CA集成(Kubernetes CSR)Authentication-自动mTLS:-支持全局、namespace级、服务级严格mTLS配置 优先级顺序:服务级 namespace级 全局apiVersion:security.istio.io/v1beta1kind:PeerAuthenticationmetadata:name:default“namespace:defaultspec:selector:matchLabels:app:foo mtls:mode:STRICTapiVersion:security.i
4、stio.io/v1beta1kind:PeerAuthenticationmetadata:name:default“namespace:istio-systemspec:mtls:mode:STRICTapiVersion:security.istio.io/v1beta1kind:PeerAuthenticationmetadata:name:default“namespace:defaultspec:mtls:mode:STRICTAuthentication-JWTapiVersion:security.istio.io/v1beta1kind:RequestAuthenticati
5、onmetadata:name:httpbin namespace:foospec:selector:matchLabels:app:httpbin jwtRules:-issuer:issuer-foo jwksUri:https:/ namespace:foospec:selector:matchLabels:app:httpbin action:ALLOW rules:-from:-source:requestPrincipals:*JWT认证往往与Authz结合使用,限制认证的请求Authorization-支持直接ALLOW or DENY CUSTOM-支持TCP、HTTP鉴权,规
6、则设置:l 支持源端:身份,namespace,IP地址l 支持目的端:Authority,端口,方法,URI路径-JWT Token 需要配合RequestAuthentication-External Auth:CUSTOMapiVersion:security.istio.io/v1beta1kind:AuthorizationPolicymetadata:name:httpbin namespace:foospec:selector:matchLabels:app:httpbin version:v1 action:ALLOW rules:-from:-source:principal
7、s:cluster.local/ns/default/sa/sleep -source:namespaces:dev to:-operation:methods:GET when:-key:request.auth.claimsiss values:https:/External AuthExternal Auth-开发External Auth 服务,支持HTTP和gRPC两种协议-AuthorizationPolicy Custom actionapiVersion:security.istio.io/v1beta1kind:AuthorizationPolicymetadata:name:ext-authz namespace:istio-systemspec:selector:matchLabels:app:istio-ingressgatewayaction:CUSTOMprovider:name:my-ext-authz-servicerules:-to:-operation:paths:/admin/*extensionProviders:-name:my-ext-authz-service envoyExtAuthzGrpc:service:ext-authz.istio-system.svc.cluster.local port:9000THANKS