著名的bookinfo例子
一尘执、部署步驟
教程里已經(jīng)濃縮成2名命令了
# Enable sidecar auto injection
kubectl label namespace default istio-injection=enabled
# Deploy bookinfo sample
kubectl -n default apply -f sample/bookinfo
二舍哄、istio注入k8s的兩種方式
本次是采用的是k8s自動(dòng)注入的方式,即如下的第1種方式
用戶空間的 Pod 要想加入 mesh, 首先需要注入 sidecar 容器, istio 提供了 2 種方式實(shí)現(xiàn)注入:
- 自動(dòng)注入: 利用 Kubernetes Dynamic Admission Webhooks 對(duì) 新建的 pod 進(jìn)行注入: initContainer + sidecar
- 手動(dòng)注入: 使用命令
istioctl kube-inject
「注入」本質(zhì)上就是修改 Pod 的資源定義, 添加相應(yīng)的 sidecar 容器定義, 內(nèi)容包括 2 個(gè)新容器:
- 名為
istio-init
的 initContainer: 通過配置 iptables 來劫持 Pod 中的流量- 名為
istio-proxy
的 sidecar 容器: 兩個(gè)進(jìn)程 pilot-agent 和 envoy, pilot-agent 進(jìn)行初始化并啟動(dòng) envoy
下面的文章會(huì)講有
三誊锭、bookinfo文件夾
sample/bookinfo下面有3個(gè)yaml文件
- bookinfo.yaml: 定義部署了productpage表悬、3個(gè)版本的reviews、ratings丧靡、details這幾個(gè)k8s的
service/deployment - bookinfo-gateway.yaml: 定義istio的攔截規(guī)則蟆沫?
- destination-rule-all.yaml: 定義微服務(wù)間的訪問router規(guī)則?