-
我們部署服務的一個新版本。
-
取決於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: v1
kind: ConfigMap
metadata:
name: istio
namespace: istio-system
labels:
app: istio
service: istio
data:
mesh: |-
# disable tracing mechanism for now
enableTracing: 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 Pilot
rdsRefreshDelay: 5s
# default config for envoy sidecar
defaultConfig:
# like rdsRefreshDelay
discoveryRefreshDelay: 5s
# path to envoy executable
configPath: "/etc/istio/proxy"
binaryPath: "/usr/local/bin/envoy"
# default name for sidecar container
serviceCluster: istio-proxy
# time for envoy to wait before it shuts down all existing connections
drainDuration: 45s
parentShutdownDuration: 1m0s
# by default, REDIRECT rule for iptables is used. TPROXY can be used as well.
#interceptionMode: REDIRECT
# port for sidecar container admin panel
proxyAdminPort: 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 TLS
controlPlaneAuthPolicy: NONE
# istio-pilot listen port to report service discovery information to sidecars
discoveryAddress: istio-pilot.istio-system:15007
initContainers:
- name: istio-init
args:
- -p
- "15001"
- -u
- "1337"
- -m
- REDIRECT
- -i
- '*'
- -b
- '*'
- -d
- ""
image: istio/proxy_init:1.0.0
imagePullPolicy: IfNotPresent
resources:
limits:
memory: 128Mi
securityContext:
capabilities:
add:
- NET_ADMIN
- name: istio-proxy
command:
- "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 \
NONE
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: INSTANCE_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: ISTIO_META_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: ISTIO_META_INTERCEPTION_MODE
value: REDIRECT
image: istio/proxyv2:1.0.0
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
memory: 2048Mi
securityContext:
privileged: false
readOnlyRootFilesystem: true
runAsUser: 1337
volumeMounts:
- mountPath: /etc/istio/proxy
name: 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/
朋友會在“發現-看一看”看到你“在看”的內容