

- 
我們部署服務的一個新版本。
 - 
取決於sidecar容器的註入型別,在配置階段新增istio-init容器和istio-agent容器(Envoy),或者手動插入到Kubernetes物體的Pod描述裡。
 - 
istio-init容器是一些指令碼,為Pod設定iptables規則。有兩種方式配置流量重定向到istio-agent容器裡:使用直接的iptables規則或者TPROXY[2]。撰寫本文時,預設使用的是重定向規則。在istio-init裡,可以配置截獲哪些流量併傳送給istio-agent。比如,為了截獲所有入站和出站流量,使用者需要將引數 -i和 -b設定為 *。使用者也可以指定截獲特定埠的流量。為了避免截獲特定子網的流量,可以使用 -x引數。
 - 
在init執行後,會啟動容器,包括pilot-agent(Envoy)。它透過GRPC連線上已經部署的Pilot,得到叢集內所有已有服務以及路由策略的資訊。根據接收到的資料,它配置叢集,將這些流量直接對映到Kubernetes集群裡的應用程式埠。重要的地方是:Envoy動態配置監聽器(IP,埠對)開始監聽。因此,當請求進入Pod,並且使用iptables規則重定向到sidecar時,Envoy已經準備好處理這些連線,並且知道將這些代理流量轉發到哪裡去。這一步裡,資訊傳送給Mixer,下文會詳細介紹。
 

- 
服務1傳送請求給服務2
 - 
在已有的服務1裡,請求重定向到sidecar
 - 
Sidecar Envoy監控到給服務2的請求,並準備所需資訊
 - 
然後它使用Report請求傳送給istio-telemetry。
 - 
Istio-telemetry決定是否將Report傳送給後臺,這裡也負責傳送請求以及請求內容。
 
apiVersion: v1kind: ConfigMapmetadata:name: istionamespace: istio-systemlabels:app: istioservice: istiodata:mesh: |-# disable tracing mechanism for nowenableTracing: false# do not specify mixer endpoints, so that sidecar containers do not send the information#mixerCheckServer: istio-policy.istio-system:15004#mixerReportServer: istio-telemetry.istio-system:15004# interval for envoy to check PilotrdsRefreshDelay: 5s# default config for envoy sidecardefaultConfig:# like rdsRefreshDelaydiscoveryRefreshDelay: 5s# path to envoy executableconfigPath: "/etc/istio/proxy"binaryPath: "/usr/local/bin/envoy"# default name for sidecar containerserviceCluster: istio-proxy# time for envoy to wait before it shuts down all existing connectionsdrainDuration: 45sparentShutdownDuration: 1m0s# by default, REDIRECT rule for iptables is used. TPROXY can be used as well.#interceptionMode: REDIRECT# port for sidecar container admin panelproxyAdminPort: 15000# address for sending traces using zipkin protocol (not used as turned off in enableTracing option)zipkinAddress: tracing-collector.tracing:9411# statsd address for envoy containers metrics# statsdUdpAddress: aggregator:8126# turn off Mutual TLScontrolPlaneAuthPolicy: NONE# istio-pilot listen port to report service discovery information to sidecarsdiscoveryAddress: istio-pilot.istio-system:15007
initContainers:- name: istio-initargs:- -p- "15001"- -u- "1337"- -m- REDIRECT- -i- '*'- -b- '*'- -d- ""image: istio/proxy_init:1.0.0imagePullPolicy: IfNotPresentresources:limits:memory: 128MisecurityContext:capabilities:add:- NET_ADMIN
- name: istio-proxycommand:- "bash"- "-c"- |exec /usr/local/bin/pilot-agent proxy sidecar \--configPath \/etc/istio/proxy \--binaryPath \/usr/local/bin/envoy \--serviceCluster \service-name \--drainDuration \45s \--parentShutdownDuration \1m0s \--discoveryAddress \istio-pilot.istio-system:15007 \--discoveryRefreshDelay \1s \--connectTimeout \10s \--proxyAdminPort \"15000" \--controlPlaneAuthPolicy \NONEenv:- name: POD_NAMEvalueFrom:fieldRef:fieldPath: metadata.name- name: POD_NAMESPACEvalueFrom:fieldRef:fieldPath: metadata.namespace- name: INSTANCE_IPvalueFrom:fieldRef:fieldPath: status.podIP- name: ISTIO_META_POD_NAMEvalueFrom:fieldRef:fieldPath: metadata.name- name: ISTIO_META_INTERCEPTION_MODEvalue: REDIRECTimage: istio/proxyv2:1.0.0imagePullPolicy: IfNotPresentresources:requests:cpu: 100mmemory: 128Milimits:memory: 2048MisecurityContext:privileged: falsereadOnlyRootFilesystem: truerunAsUser: 1337volumeMounts:- mountPath: /etc/istio/proxyname: istio-envoy
- 
CIDR Pod和Service CIDR必須在所有集群裡都是唯一的,不能重疊。
 - 
叢集間的任意Pod CIDR必須能夠訪問所有CIDR Pod。
 - 
所有Kubernetes API server都必須能夠相互訪問。
 
- 
https://istio.io/docs/concepts/
 - 
https://www.envoyproxy.io/
 - 
https://github.com/kristrev/tproxy-example/blob/master/tproxy_example.c
 - 
https://istio.io/docs/concepts/policies-and-telemetry/overview/
 - 
https://github.com/istio/istio/blob/release-1.0/install/kubernetes/helm/istio/charts/pilot/templates/deployment.yaml
 - 
https://github.com/istio/istio/tree/release-1.0/install/kubernetes/helm/istio/charts/pilot/templates
 - 
https://istio.io/docs/setup/kubernetes/multicluster-install/
 
知識星球
朋友會在“發現-看一看”看到你“在看”的內容