主要分為幾個(gè)模塊
- 安裝
- 安全概念
- 整體安全架構(gòu)
- 源碼
1.安裝istio (windows環(huán)境)
-
windows安裝Rancher的步驟 : https://docs.rancherdesktop.io/getting-started/installation,
docker desktop開(kāi)始面向中大型企業(yè)收費(fèi): https://baijiahao.baidu.com/s?id=1709665495660071676&wfr=spider&for=pc
rancher desktop是一個(gè)開(kāi)源項(xiàng)目 :
官網(wǎng):https://rancherdesktop.io/
github代碼: https://github.com/rancher-sandbox/rancher-desktop
-
下載window版本的istio:istio-1.12.6-win.zip
-
解壓后進(jìn)入安裝istio的bin目錄下
-
驗(yàn)證istio的版本
$ ./istioctl.exe version
client version: 1.12.6
control plane version: 1.12.6
data plane version: 1.12.6 (2 proxies)
- 執(zhí)行安裝命令
$ ./istioctl.exe manifest apply --set profile=demo
This will install the Istio 1.12.6 demo profile with ["Istio core" "Istiod" "Ingress gateways" "Egress gateways"] components into the cluster. Proceed? (y/N) y
? Istio core installed
? Istiod installed
? Ingress gateways installed
? Egress gateways installed
? Installation complete
Making this installation the default for injection and validation.
Thank you for installing Istio 1.12. Please take a few minutes to tell us about your install/upgrade experience! https://forms.gle/FegQbc9UvePd4Z9z7
- 創(chuàng)建demo namespace
$ kubectl create ns demo
namespace/demo created
- 將Istio注入namespace
$ kubectl label namespace demo istio-injection=enabled
namespace/demo labeled
- 查看istio的pod
windows版本的沒(méi)有安裝kiali和prometheus, 猜測(cè)可能沒(méi)有支持
$ kubectl get pods -n istio-system
NAME READY STATUS RESTARTS AGE
istiod-f97b6b446-jmwx8 1/1 Running 0 17m
svclb-istio-ingressgateway-plw4t 0/5 Pending 0 16m
istio-egressgateway-6976f7c4bb-xjgsn 1/1 Running 0 16m
istio-ingressgateway-678984b8f6-j7skh 1/1 Running 0 16m
- 驗(yàn)證istio是否安裝成功 (驗(yàn)證成功了)
$ ./istioctl.exe verify-install -f ../manifests/profiles/demo.yaml
? Deployment: istio-ingressgateway.istio-system checked successfully
? PodDisruptionBudget: istio-ingressgateway.istio-system checked successfully
? Role: istio-ingressgateway-sds.istio-system checked successfully
? RoleBinding: istio-ingressgateway-sds.istio-system checked successfully
? Service: istio-ingressgateway.istio-system checked successfully
? ServiceAccount: istio-ingressgateway-service-account.istio-system checked successfully
? Deployment: istio-egressgateway.istio-system checked successfully
? PodDisruptionBudget: istio-egressgateway.istio-system checked successfully
? Role: istio-egressgateway-sds.istio-system checked successfully
? RoleBinding: istio-egressgateway-sds.istio-system checked successfully
? Service: istio-egressgateway.istio-system checked successfully
? ServiceAccount: istio-egressgateway-service-account.istio-system checked successfully
? ClusterRole: istiod-istio-system.istio-system checked successfully
? ClusterRole: istio-reader-istio-system.istio-system checked successfully
? ClusterRoleBinding: istio-reader-istio-system.istio-system checked successfully
? ClusterRoleBinding: istiod-istio-system.istio-system checked successfully
? ServiceAccount: istio-reader-service-account.istio-system checked successfully
? Role: istiod-istio-system.istio-system checked successfully
? RoleBinding: istiod-istio-system.istio-system checked successfully
? ServiceAccount: istiod-service-account.istio-system checked successfully
? CustomResourceDefinition: wasmplugins.extensions.istio.io.istio-system checked successfully
? CustomResourceDefinition: destinationrules.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: envoyfilters.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: gateways.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: serviceentries.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: sidecars.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: virtualservices.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: workloadentries.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: workloadgroups.networking.istio.io.istio-system checked successfully
? CustomResourceDefinition: authorizationpolicies.security.istio.io.istio-system checked successfully
? CustomResourceDefinition: peerauthentications.security.istio.io.istio-system checked successfully
? CustomResourceDefinition: requestauthentications.security.istio.io.istio-system checked successfully
? CustomResourceDefinition: telemetries.telemetry.istio.io.istio-system checked successfully
? CustomResourceDefinition: istiooperators.install.istio.io.istio-system checked successfully
? ClusterRole: istiod-clusterrole-istio-system.istio-system checked successfully
? ClusterRole: istiod-gateway-controller-istio-system.istio-system checked successfully
? ClusterRoleBinding: istiod-clusterrole-istio-system.istio-system checked successfully
? ClusterRoleBinding: istiod-gateway-controller-istio-system.istio-system checked successfully
? ConfigMap: istio.istio-system checked successfully
? Deployment: istiod.istio-system checked successfully
? ConfigMap: istio-sidecar-injector.istio-system checked successfully
? MutatingWebhookConfiguration: istio-sidecar-injector.istio-system checked successfully
? PodDisruptionBudget: istiod.istio-system checked successfully
? ClusterRole: istio-reader-clusterrole-istio-system.istio-system checked successfully
? ClusterRoleBinding: istio-reader-clusterrole-istio-system.istio-system checked successfully
? Role: istiod.istio-system checked successfully
? RoleBinding: istiod.istio-system checked successfully
? Service: istiod.istio-system checked successfully
? ServiceAccount: istiod.istio-system checked successfully
? EnvoyFilter: stats-filter-1.10.istio-system checked successfully
? EnvoyFilter: tcp-stats-filter-1.10.istio-system checked successfully
? EnvoyFilter: stats-filter-1.11.istio-system checked successfully
? EnvoyFilter: tcp-stats-filter-1.11.istio-system checked successfully
? EnvoyFilter: stats-filter-1.12.istio-system checked successfully
? EnvoyFilter: tcp-stats-filter-1.12.istio-system checked successfully
? ValidatingWebhookConfiguration: istio-validator-istio-system.istio-system checked successfully
? IstioOperator: .istio-system checked successfully
Checked 14 custom resource definitions
Checked 3 Istio Deployments
? Istio is installed and verified successfully
- 給命名空間添加標(biāo)簽,指示 Istio 在部署應(yīng)用的時(shí)候,自動(dòng)的注入 Envoy 邊車(chē)代理
$ kubectl label namespace demo istio-injection=enabled
namespace/demo labeled
- 部署bookinfo服務(wù) : https://istio.io/latest/docs/examples/bookinfo/
$ kubectl apply -f ../samples/bookinfo/platform/kube/bookinfo.yaml -n demo
service/details created
serviceaccount/bookinfo-details created
deployment.apps/details-v1 created
service/ratings created
serviceaccount/bookinfo-ratings created
deployment.apps/ratings-v1 created
service/reviews created
serviceaccount/bookinfo-reviews created
deployment.apps/reviews-v1 created
deployment.apps/reviews-v2 created
deployment.apps/reviews-v3 created
service/productpage created
serviceaccount/bookinfo-productpage created
deployment.apps/productpage-v1 created
- 部署gateway
$ kubectl apply -f ../samples/bookinfo/networking/bookinfo-gateway.yaml -n demo
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created
- 訪(fǎng)問(wèn)鏈接,驗(yàn)證是否安裝成功
http://localhost/productpage
- 工具可以分析錯(cuò)誤
問(wèn)題1:
$ ./istioctl.exe analyze
Error [IST0101] (VirtualService default/bookinfo) Referenced host not found: "productpage"
Error [IST0145] (Gateway default/bookinfo-gateway) Conflict with gateways demo/bookinfo-gateway (workload selector istio=ingressgateway, port 80, hosts *).
Error: Analyzers found issues when analyzing namespace: default.
See https://istio.io/v1.12/docs/reference/config/analysis for more information about causes and resolutions.
錯(cuò)誤碼對(duì)應(yīng)的原因:https://istio.io/v1.12/docs/reference/config/analysis/
刪除重復(fù)的CRD:
k8s刪除命令:https://blog.csdn.net/lanwp5302/article/details/87470389
$ kubectl get gateway --all-namespaces
NAMESPACE NAME AGE
demo bookinfo-gateway 28m
default bookinfo-gateway 15m
$ kubectl delete -f ../samples/bookinfo/networking/bookinfo-gateway.yaml -n demo
gateway.networking.istio.io "bookinfo-gateway" deleted
virtualservice.networking.istio.io "bookinfo" deleted
xc.lu@dst74844 MINGW64 /e/ChromeDownload/istio-1.12.6/bin
$ kubectl get gateway --all-namespaces
NAMESPACE NAME AGE
demo bookinfo-gateway 31m
問(wèn)題2:
$ ./istioctl.exe analyze -n demo
Warning [IST0140] (VirtualService demo/bookinfo) Subset in virtual service demo/productpage has no effect on ingress gateway demo/bookinfo requests
ingressgateway pending問(wèn)題 :
https://stackoverflow.com/questions/60484080/the-external-ip-of-istio-ingress-gateway-stay-pending
關(guān)閉rancher網(wǎng)關(guān) ?
- 開(kāi)啟mtls
如果需要啟用雙向 TLS,請(qǐng)執(zhí)行以下命令:
$ kubectl apply -f samples/bookinfo/networking/destination-rule-all-mtls.yaml
等待幾秒鐘,等待目標(biāo)規(guī)則生效,使用以下命令查看目標(biāo)規(guī)則:
$ kubectl get destinationrules -o yaml
apiVersion: v1
items:
- apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"networking.istio.io/v1alpha3","kind":"DestinationRule","metadata":{"annotations":{},"name":"productpage","namespace":"default"},"spec":{"host":"productpage","subsets":[{"labels":{"version":"v1"},"name":"v1"}],"trafficPolicy":{"tls":{"mode":"ISTIO_MUTUAL"}}}}
creationTimestamp: "2022-05-03T11:59:40Z"
generation: 1
name: productpage
namespace: default
resourceVersion: "37818"
uid: 117e2cc4-4f6f-4046-85cc-2db9c955056c
spec:
host: productpage
subsets:
- labels:
version: v1
name: v1
trafficPolicy:
tls:
mode: ISTIO_MUTUAL (這個(gè)代表mtls)
- 驗(yàn)證mtls
驗(yàn)證步驟參考:
- https://ultimatesecurity.pro/post/istio-mtls/
- https://zhuanlan.zhihu.com/p/290557288
-
istio排障工具
有哪些錯(cuò)誤碼:
排障工具:
https://istio.io/latest/docs/tasks/traffic-management/ingress/ingress-control/
./istioctl.exe analyze -n demo
https://istio.io/latest/docs/setup/install/istioctl/
2.安全的概念
what is istio
Simplify observability, traffic management, security, and policy with the leading service mesh.
istio = 流量管理 + 可觀測(cè)性 + 安全
https://istio.io/
零信任架構(gòu) (ZTA)
傳統(tǒng)的網(wǎng)絡(luò)安全架構(gòu)
-
基于邊界的安全架構(gòu),企業(yè)構(gòu)建網(wǎng)絡(luò)安全體系時(shí),首先尋找安全邊界,把網(wǎng)絡(luò)劃分為外網(wǎng)、內(nèi)網(wǎng)、DMZ( DeMilitarized Zone)區(qū)等不同的區(qū)域,然后在邊界上部署防火墻、入侵檢測(cè)、WAF等產(chǎn)品。有些還會(huì)設(shè)置ip白名單。
-
這種網(wǎng)絡(luò)安全架構(gòu)假設(shè)或默認(rèn)了內(nèi)網(wǎng)比外網(wǎng)更安全,在某種程度上預(yù)設(shè)了對(duì)內(nèi)網(wǎng)中的人、設(shè)備和系統(tǒng)的信任,忽視加強(qiáng)內(nèi)網(wǎng)安全措施。不法分子一旦突破企業(yè)的邊界安全防護(hù)進(jìn)入內(nèi)網(wǎng),會(huì)像進(jìn)入無(wú)人之境,將帶來(lái)嚴(yán)重的后果。
-
傳統(tǒng)的認(rèn)證,即信任、邊界防護(hù)、靜態(tài)訪(fǎng)問(wèn)控制、以網(wǎng)絡(luò)為中心。
[外鏈圖片轉(zhuǎn)存失敗,源站可能有防盜鏈機(jī)制,建議將圖片保存下來(lái)直接上傳(img-lWy7TWN1-1684323450669)(D:\Users\xc.lu\AppData\Roaming\Typora\typora-user-images\image-20220519192712017.png)]
Zero Trust Architecture
隨著云計(jì)算、大數(shù)據(jù)、物聯(lián)網(wǎng)等新技術(shù)與業(yè)務(wù)的深度融合,網(wǎng)絡(luò)安全邊界也逐漸變得更加模糊,傳統(tǒng)邊界安全防護(hù)理念面臨巨大挑戰(zhàn)。
零信任即信任度為零,“永遠(yuǎn)不信任,始終要驗(yàn)證”(Never Trust,Always Verify)。
- 以身份為中心
不論用戶(hù)、設(shè)備、應(yīng)用和接口都需要具備唯一的“ID身份”,經(jīng)過(guò)認(rèn)證、授權(quán)后才能通行。就好比在軍營(yíng)出入要出示令牌證件。
- 最低權(quán)限訪(fǎng)問(wèn)
只給用戶(hù)所需要的最小訪(fǎng)問(wèn)權(quán)限。同上,在軍營(yíng),為防止軍機(jī)泄露,將軍只會(huì)讓普通士兵掌握最基礎(chǔ)的信息。
- 微隔離單獨(dú)訪(fǎng)問(wèn)
安全邊界被分割成小區(qū)域,不同網(wǎng)絡(luò)部分保持單獨(dú)訪(fǎng)問(wèn)。比如軍營(yíng)分成多個(gè)區(qū)域,A區(qū)域的士兵如果沒(méi)有被單獨(dú)授權(quán),就無(wú)法進(jìn)入其他營(yíng)區(qū)。
ISTIO安全目標(biāo)
常見(jiàn)安全需求:
- 為了抵御中間人攻擊,需要流量加密。
- 為了提供靈活的服務(wù)訪(fǎng)問(wèn)控制,需要雙向 TLS 和細(xì)粒度的訪(fǎng)問(wèn)策略。
- 要確定誰(shuí)在什么時(shí)候做了什么,需要審計(jì)工具。
Istio 安全功能提供強(qiáng)大的身份,強(qiáng)大的策略,透明的 TLS 加密,認(rèn)證,授權(quán)和審計(jì)工具來(lái)保護(hù)你的服務(wù)和數(shù)據(jù)。Istio 安全的目標(biāo)是:
- 默認(rèn)安全:應(yīng)用程序代碼和基礎(chǔ)設(shè)施無(wú)需更改
- 深度防御:與現(xiàn)有安全系統(tǒng)集成以提供多層防御
- 零信任網(wǎng)絡(luò):在不受信任的網(wǎng)絡(luò)上構(gòu)建安全解決方案
istio & k8s
K8S
命名空間級(jí)別
指定命名空間內(nèi)的所有(或部分)服務(wù)可以被另一命名空間的所有(或部分)服務(wù)所訪(fǎng)問(wèn),需要用戶(hù)創(chuàng)建ServiceRole、ServiceRoleBinding策略來(lái)實(shí)現(xiàn)此過(guò)程。
服務(wù)級(jí)別
指定服務(wù)可以被另一個(gè)服務(wù)訪(fǎng)問(wèn),需要用戶(hù)創(chuàng)建Service Account、ServiceRole、ServiceRoleBinding策略來(lái)實(shí)現(xiàn)此過(guò)程。
istio
Istio 是獨(dú)立于平臺(tái)的,可以與 Kubernetes(或基礎(chǔ)設(shè)施)的網(wǎng)絡(luò)策略一起使用。但它更強(qiáng)大,能夠在網(wǎng)絡(luò)和應(yīng)用層面保護(hù)pod到 pod 或者服務(wù)到服務(wù)之間的通信。
Istio 的安全特性解放了開(kāi)發(fā)人員,使其只需要專(zhuān)注于應(yīng)用程序級(jí)別的安全。Istio 提供了底層的安全通信通道,并為大規(guī)模的服務(wù)通信管理認(rèn)證、授權(quán)和加密。
CA
CA是Certificate Authority的英文首字母縮寫(xiě),是證書(shū)頒發(fā)機(jī)構(gòu)的意思,CA機(jī)構(gòu)是專(zhuān)門(mén)負(fù)責(zé)發(fā)放和管理數(shù)字證書(shū)的權(quán)威機(jī)構(gòu)。而CA認(rèn)證就是為電子簽名相關(guān)各方提供真實(shí)可靠驗(yàn)證的電子認(rèn)證服務(wù)。
證書(shū)的內(nèi)容包括:電子簽證機(jī)關(guān)的信息、公鑰用戶(hù)信息、公鑰、權(quán)威機(jī)構(gòu)的簽字和有效期等等。證書(shū)的格式和驗(yàn)證方法普遍遵循X.509 國(guó)際標(biāo)準(zhǔn)。
認(rèn)證&授權(quán)
在開(kāi)發(fā)或者管理一個(gè)應(yīng)用程序的時(shí)候,我們往往會(huì)看到兩個(gè)名詞——認(rèn)證和授權(quán),在英文中,這兩個(gè)詞語(yǔ)更為相近 —— authentication 和 authorization。盡管這兩個(gè)術(shù)語(yǔ)經(jīng)常出現(xiàn)在相同的上下文中,但兩者在概念上卻有很大差別。
認(rèn)證,意味著確認(rèn)用戶(hù)或使用者的身份,而授權(quán),則意味著授予對(duì)系統(tǒng)的訪(fǎng)問(wèn)權(quán)限。簡(jiǎn)單來(lái)說(shuō),認(rèn)證是驗(yàn)證用戶(hù)身份的過(guò)程,而授權(quán)是驗(yàn)證用戶(hù)有權(quán)訪(fǎng)問(wèn)的過(guò)程。
https://istio.io/latest/docs/tasks/security/
3.整體安全架構(gòu):
組件
- Citadel:用于負(fù)責(zé)密鑰和證書(shū)的管理,在創(chuàng)建服務(wù)時(shí)會(huì)將密鑰及證書(shū)下發(fā)至對(duì)應(yīng)的Envoy代理中;
- Pilot:用于接收用戶(hù)定義的安全策略并將其整理下發(fā)至服務(wù)旁的Envoy代理中;
- Envoy:用于存儲(chǔ)Citadel下發(fā)的密鑰和證書(shū),保障服務(wù)間的數(shù)據(jù)傳輸安全;
[外鏈圖片轉(zhuǎn)存失敗,源站可能有防盜鏈機(jī)制,建議將圖片保存下來(lái)直接上傳(img-G4Bbt14X-1684323452140)(null)]
Citadel認(rèn)證授權(quán)過(guò)程
- Kubernetes某集群節(jié)點(diǎn)新部署了服務(wù)A和服務(wù)B,此時(shí)集群中有兩個(gè)Pod被啟動(dòng),每個(gè)Pod由Envoy代理容器和Service容器構(gòu)成,在啟動(dòng)過(guò)程中Istio的Citadel組件會(huì)將密鑰及證書(shū)依次下發(fā)至每個(gè)Pod中的Envoy代理容器中,以保證后續(xù)服務(wù)A、B之間的安全通信。
- 用戶(hù)通過(guò)Rules API下發(fā)安全策略至Pilot組件,Pilot組件通過(guò)Pilot-discovery進(jìn)程整理安全策略中Kubernetes服務(wù)注冊(cè)和配置信息并以Envoy API方式暴露給Envoy。
- Pod A、B中的Envoy代理會(huì)通過(guò)Envoy xDS API方式定時(shí)去Pilot拉取安全策略配置信息,并將信息保存至Envoy代理容器中。
- 當(dāng)服務(wù)A訪(fǎng)問(wèn)服務(wù)B時(shí),會(huì)調(diào)用各自Envoy容器中的證書(shū)及密鑰實(shí)現(xiàn)服務(wù)間的安全通信,同時(shí)Envoy容器還會(huì)根據(jù)用戶(hù)下發(fā)的安全策略進(jìn)行更細(xì)粒度的訪(fǎng)問(wèn)控制。
身份:
[外鏈圖片轉(zhuǎn)存失敗,源站可能有防盜鏈機(jī)制,建議將圖片保存下來(lái)直接上傳(img-nIwVy4gB-1684323451735)(null)]
SDS :
Istio 供應(yīng)身份是通過(guò) secret discovery service(SDS)來(lái)實(shí)現(xiàn)的,具體流程如下:
- istiod 提供 gRPC 服務(wù)以接受證書(shū)簽名請(qǐng)求(CSRs)。
- 當(dāng)工作負(fù)載啟動(dòng)時(shí),Envoy 通過(guò)秘密發(fā)現(xiàn)服務(wù)(SDS)API 向同容器內(nèi)的 istio-agent 發(fā)送證書(shū)和密鑰請(qǐng)求。
- 在收到 SDS 請(qǐng)求后,istio-agent 創(chuàng)建私鑰和 CSR,然后將 CSR 及其憑據(jù)發(fā)送到 istiod CA 進(jìn)行簽名。
- istiod CA 驗(yàn)證 CSR 中攜帶的憑據(jù),成功驗(yàn)證后簽署 CSR 以生成證書(shū)。
- Istio-agent 通過(guò) Envoy SDS API 將私鑰和從 Istio CA 收到的證書(shū)發(fā)送給 Envoy。
- Istio-agent 會(huì)監(jiān)工作負(fù)載證書(shū)的有效期。上述 CSR 過(guò)程會(huì)周期性地重復(fù),以處理證書(shū)和密鑰輪換。
mTLS (雙向 TLS)
mTLS
當(dāng)一個(gè)工作負(fù)載使用雙向 TLS 認(rèn)證向另一個(gè)工作負(fù)載發(fā)送請(qǐng)求時(shí),該請(qǐng)求的處理方式如下:
-
Istio 將出站流量從客戶(hù)端重新路由到客戶(hù)端的本地 sidecar Envoy。
-
客戶(hù)端 Envoy 與服務(wù)器端 Envoy 開(kāi)始雙向 TLS 握手。在握手期間,客戶(hù)端 Envoy 還做了安全命名檢查,以驗(yàn)證服務(wù)器證書(shū)中顯示的服務(wù)帳戶(hù)是否被授權(quán)運(yùn)行目標(biāo)服務(wù)。
-
客戶(hù)端 Envoy 和服務(wù)器端 Envoy 建立了一個(gè)雙向的 TLS 連接,Istio 將流量從客戶(hù)端 Envoy 轉(zhuǎn)發(fā)到服務(wù)器端 Envoy。
-
授權(quán)后,服務(wù)器端 Envoy 通過(guò)本地 TCP 連接將流量轉(zhuǎn)發(fā)到服務(wù)器服務(wù)。
寬容模式(permissive mode)
Istio 雙向 TLS 具有一個(gè)寬容模式(permissive mode),即不需要授權(quán)和認(rèn)證,允許 service 同時(shí)接受純文本流量和雙向 TLS 流量。該功能有利于測(cè)試,主要用于非Istio客戶(hù)端和非 Istio 服務(wù)端間的通信,避免因權(quán)限而導(dǎo)致無(wú)法連接的情況。
舉個(gè)實(shí)際場(chǎng)景,啟用寬容模式后,服務(wù)同時(shí)接受純文本和雙向 TLS 流量。這個(gè)模式為入門(mén)提供了極大的靈活性。服務(wù)中安裝的 Istio sidecar 立即接受雙向 TLS 流量而不會(huì)打斷現(xiàn)有的純文本流量。因此,運(yùn)維人員可以逐步安裝和配置客戶(hù)端 Istio sidecars 發(fā)送雙向 TLS 流量。一旦客戶(hù)端配置完成,運(yùn)維人員便可以將服務(wù)端配置為僅 TLS 模式。
4.源碼
SPIFFE
SPIFFE 是 Istio 所采用的安全命名的規(guī)范,它也是云原生定義的一種標(biāo)準(zhǔn)化的、可移植的工作負(fù)載身份規(guī)范。
SPIFFE ID 規(guī)定了形如 spiffe://<trust domain>/<workload identifier>
的 URI 格式,作為工作負(fù)載(Workload)的唯一標(biāo)識(shí)。
Istio 使用形如 spiffe://<trust_domain>/ns/<namespace>/sa/<service_account>
格式的 SPIFFE ID 作為安全命名,注入到 X.509 證書(shū)的 subjectAltName 擴(kuò)展中。其中“trust domain”參數(shù)通過(guò) Istiod 環(huán)境變量 TRUST_DOMAIN
注入,用于在多集群環(huán)境中交互。
spiffe://cluster.local/ns/<pod namespace>/sa/<pod service account>
type Identity struct {
TrustDomain string
Namespace string
ServiceAccount string
}
SDS(秘鑰發(fā)現(xiàn)服務(wù))
SDS 帶來(lái)的最大的好處就是簡(jiǎn)化證書(shū)管理。要是沒(méi)有該功能的話(huà),我們就必須使用 Kubernetes 中的 secret 資源創(chuàng)建證書(shū),然后把證書(shū)掛載到代理容器中。如果證書(shū)過(guò)期,還需要更新 secret 和需要重新部署代理容器。使用 SDS,中央 SDS 服務(wù)器將證書(shū)推送到所有 Envoy 實(shí)例上。如果證書(shū)過(guò)期,服務(wù)器只需將新證書(shū)推送到 Envoy 實(shí)例,Envoy 可以立即使用新證書(shū)而無(wú)需重新部署。
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-448377.html
SDS server 需要實(shí)現(xiàn) SecretDiscoveryService 這個(gè) gRPC 服務(wù)。遵循與其他 xDS 相同的協(xié)議。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-448377.html
啟動(dòng)流程:
cmd.go
func newDiscoveryCommand()
server.go
func NewServer(args *PilotArgs, initFuncs ...func(*Server))
func (s *Server) initSecureDiscoveryService(args *PilotArgs)
ads.go
func (s *DiscoveryServer) Stream(stream DiscoveryStream) error
func (s *DiscoveryServer) processRequest(req *discovery.DiscoveryRequest, con *Connection) error
func (s *DiscoveryServer) pushXds(con *Connection, push *model.PushContext,
w *model.WatchedResource, req *model.PushRequest) error
sdsservice.go
func (s *sdsservice) Generate(_ *model.Proxy, _ *model.PushContext, w *model.WatchedResource,
updates *model.PushRequest)
func (s *sdsservice) generate(resourceNames []string)
agent.go
func (a *Agent) Run(ctx context.Context)
secretcache.go
func (sc *SecretManagerClient) GenerateSecret(resourceName string) (secret *security.SecretItem, err error)
參考文檔
- https://cloudnative.to/blog/istio-zero-trust-source-code-reading/
- https://cloudnative.to/blog/istio-security-best-practices/
- https://ultimatesecurity.pro/post/istio-mtls/
- https://istio.io/latest/
- https://jimmysong.io/istio-handbook/
- http://www.voycn.com/article/istioxdsxieyijiexi
到了這里,關(guān)于Istio零信任安全架構(gòu)設(shè)計(jì)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!