mirror of https://github.com/istio/istio.io.git
[zh-cn] sync cni customize-installation sidecar-injection getting-started (#14071)
Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
parent
e8aee74b65
commit
85156fd577
|
@ -10,21 +10,23 @@ owner: istio/wg-networking-maintainers
|
|||
test: yes
|
||||
---
|
||||
|
||||
按照此流程利用 Istio 容器网络接口([CNI](https://github.com/containernetworking/cni#cni---the-container-network-interface))来安装、配置和使用 Istio 网格。
|
||||
按照此流程利用 Istio 容器网络接口([CNI](https://github.com/containernetworking/cni#cni---the-container-network-interface))
|
||||
来安装、配置和使用 Istio 网格。
|
||||
|
||||
默认情况下,Istio 会在网格中部署的 Pod 上注入一个 `initContainer`:`istio-init`。
|
||||
`istio-init` 容器会将 Pod 的网络流量劫持到 Istio Sidecar 代理上。
|
||||
这需要用户或部署 Pod 的 Service Account 具有足够的部署
|
||||
[`NET_ADMIN` 容器](https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container)的 Kubernetes RBAC 权限。
|
||||
Istio 用户权限的提升,对于某些组织的安全政策来说,可能是难以接受的。
|
||||
Istio CNI 插件就是一个能够替代 `istio-init` 容器来实现相同的网络功能但却不需要 Istio 用户申请额外的 Kubernetes RBAC 授权的方案。
|
||||
[`NET_ADMIN` 容器](https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container)的
|
||||
Kubernetes RBAC 权限。Istio 用户权限的提升,对于某些组织的安全政策来说,可能是难以接受的。
|
||||
Istio CNI 插件就是一个能够替代 `istio-init` 容器来实现相同的网络功能但却不需要 Istio
|
||||
用户申请额外的 Kubernetes RBAC 授权的方案。
|
||||
|
||||
Istio CNI 插件会在 Kubernetes Pod 生命周期的网络设置阶段完成 Istio 网格的 Pod 流量转发设置工作,
|
||||
Istio CNI 插件会在 Kubernetes Pod 生命周期的网络设置阶段完成 Istio 网格 Pod 流量转发设置的工作,
|
||||
因此用户在部署 Pod 到 Istio 网格中时,不再需要配置 [`NET_ADMIN` 功能需求](/zh/docs/ops/deployment/requirements/)了。
|
||||
Istio CNI 插件代替了 `istio-init` 容器所实现的功能。
|
||||
|
||||
{{< tip >}}
|
||||
注意: Istio CNI 插件作为一个链接的 CNI 插件运行,它被设计为与另一个 CNI 插件一起使用,
|
||||
注意:Istio CNI 插件作为一个链接的 CNI 插件运行,它被设计为与另一个 CNI 插件一起使用,
|
||||
如 [PTP](https://www.cni.dev/plugins/current/main/ptp/) 或 [Calico](https://docs.projectcalico.org)。
|
||||
详情请参见[与其他CNI插件的兼容性](#compatibility-with-other-cni-plugins)。
|
||||
{{< /tip >}}
|
||||
|
@ -80,7 +82,8 @@ $ helm install istio-cni istio/cni -n kube-system --wait
|
|||
{{< /tabset >}}
|
||||
|
||||
这将部署 `istio-cni-node` DaemonSet 到集群中,将 Istio CNI 插件可执行文件安装到每个节点上并为此插件设置必要的配置。
|
||||
CNI DaemonSet 使用 [`system-node-critical`](https://kubernetes.io/zh-cn/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/) `PriorityClass` 来运行。
|
||||
CNI DaemonSet 使用 [`system-node-critical`](https://kubernetes.io/zh-cn/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/)
|
||||
`PriorityClass` 来运行。
|
||||
|
||||
{{< image width="60%" link="./cni.svg" caption="Istio CNI" >}}
|
||||
|
||||
|
@ -243,9 +246,9 @@ Istio CNI 插件可能会导致与任何应用 `initContainers` 的网络连通
|
|||
即发送到配置的 IP/端口的应用流量将绕过 Istio Sidecar。
|
||||
{{< /warning >}}
|
||||
|
||||
### 和其它 CNI 插件的兼容性{#compatibility-with-other-CNI-plugins}
|
||||
### 和其它 CNI 插件的兼容性 {#compatibility-with-other-CNI-plugins}
|
||||
|
||||
Istio CNI 插件维护着与当前需要 `NET_ADMIN` 和 `NET_RAW` 能力的 `istio-init` 容器相同的 CNI 插件集。
|
||||
Istio CNI 插件维护着与当前需要 `NET_ADMIN` 和 `NET_RAW` 权能的 `istio-init` 容器相同的 CNI 插件集。
|
||||
|
||||
Istio CNI 插件作为一个链式 CNI 插件存在。也就是说它的配置会作为一个新的配置列表元素被加入到现存 CNI 插件配置中。
|
||||
参考 [CNI 规范](https://github.com/containernetworking/cni/blob/master/SPEC.md#network-configuration-lists)中的更多细节。
|
||||
|
|
|
@ -34,31 +34,33 @@ $ istioctl install -f samples/operator/pilot-k8s.yaml
|
|||
{{< /text >}}
|
||||
|
||||
{{< tip >}}
|
||||
为了向后兼容,以前的 [Helm 安装选项](https://archive.istio.io/v1.4/docs/reference/config/installation-options/),除了 Kubernetes 资源设置之外,均被完整的支持。
|
||||
为了在命令行设置他们,在选项名前面加上 "`values.`"。
|
||||
为了向后兼容,以前的 [Helm 安装选项](https://archive.istio.io/v1.4/docs/reference/config/installation-options/),
|
||||
除了 Kubernetes 资源设置之外,均被完整的支持。为了在命令行设置他们,在选项名前面加上 "`values.`"。
|
||||
例如,下面的命令覆盖了 Helm 配置选项 `pilot.traceSampling`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ istioctl install --set values.pilot.traceSampling=0.1
|
||||
{{< /text >}}
|
||||
|
||||
Helm 值也可以在 `IstioOperator` CR(YAML 文件)中设置,就像[使用 Helm API 定制 Istio 设置](#customize-settings-using-the-helm) 中描述的那样。
|
||||
Helm 值也可以在 `IstioOperator` CR(YAML 文件)中设置,就像[使用 Helm API 定制 Istio 设置](#customize-settings-using-the-helm)
|
||||
中描述的那样。
|
||||
|
||||
如果您需要配置 Kubernetes 资源方面的设置,请用[定制 Kubernetes 设置](#customize-k-settings)中介绍的 `IstioOperator` API。
|
||||
如果您需要配置 Kubernetes 资源方面的设置,请用[定制 Kubernetes 设置](#customize-k-settings)中介绍的
|
||||
`IstioOperator` API。
|
||||
{{< /tip >}}
|
||||
|
||||
### 识别 Istio 组件 {#identify-an-component}
|
||||
|
||||
`IstioOperator` API 定义的组件如下面表格所示:
|
||||
|
||||
| 组件 |
|
||||
| ------------|
|
||||
`base` |
|
||||
`pilot` |
|
||||
| 组件 |
|
||||
| ----------------|
|
||||
`base` |
|
||||
`pilot` |
|
||||
`ingressGateways` |
|
||||
`egressGateways` |
|
||||
`cni` |
|
||||
`istiodRemote` |
|
||||
`egressGateways` |
|
||||
`cni` |
|
||||
`istiodRemote` |
|
||||
|
||||
针对每一个组件的配置内容通过 `components.<component name>` 下的 API 中提供。
|
||||
例如,要用 API 改变(改为 false)`pilot` 组件的 `enabled` 设置,
|
||||
|
@ -81,8 +83,8 @@ spec:
|
|||
|
||||
`IstioOperator` API 支持以一致性的方式定制每一个组件的 Kubernetes 设置。
|
||||
|
||||
每个组件都有一个 [`KubernetesResourceSpec`](/zh/docs/reference/config/istio.operator.v1alpha1/#KubernetesResourcesSpec),它允许修改如下设置。
|
||||
使用此列表标识要定制的设置:
|
||||
每个组件都有一个 [`KubernetesResourceSpec`](/zh/docs/reference/config/istio.operator.v1alpha1/#KubernetesResourcesSpec),
|
||||
它允许修改如下设置。使用此列表标识要定制的设置:
|
||||
|
||||
1. [Resources](https://kubernetes.io/zh-cn/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container)
|
||||
1. [Readiness probes](https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/)
|
||||
|
@ -101,7 +103,8 @@ spec:
|
|||
1. [Env](https://kubernetes.io/zh-cn/docs/tasks/inject-data-application/define-environment-variable-container/)
|
||||
1. [Pod security context](https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod)
|
||||
|
||||
所有这些 Kubernetes 设置均使用 Kubernetes API 定义,因此可以参考 [Kubernetes 文档](https://kubernetes.io/zh-cn/docs/concepts/)
|
||||
所有这些 Kubernetes 设置均使用 Kubernetes API 定义,因此可以参考
|
||||
[Kubernetes 文档](https://kubernetes.io/zh-cn/docs/concepts/)
|
||||
|
||||
下面覆盖文件的例子调整 Pilot 的资源限制和 Pod 水平伸缩的设置:
|
||||
|
||||
|
@ -129,7 +132,9 @@ $ istioctl install -f samples/operator/pilot-k8s.yaml
|
|||
|
||||
### 使用 Helm API 定制 Istio 设置 {#customize-settings-using-the-helm}
|
||||
|
||||
`IstioOperator` API 使用 `values` 字段为 [Helm API](https://archive.istio.io/v1.4/docs/reference/config/installation-options/) 保留了一个透传接口。
|
||||
`IstioOperator` API 使用 `values` 字段为
|
||||
[Helm API](https://archive.istio.io/v1.4/docs/reference/config/installation-options/)
|
||||
保留了一个透传接口。
|
||||
|
||||
下面的 YAML 文件通过 Helm API 来配置 global 和 Pilot 的设置:
|
||||
|
||||
|
@ -148,11 +153,11 @@ spec:
|
|||
Istio 社区推荐使用 `IstioOperator` API,因为它更一致、更有效、
|
||||
且遵循[社区毕业流程](https://github.com/istio/community/blob/master/FEATURE-LIFECYCLE-CHECKLIST.md#feature-lifecycle-checklist)。
|
||||
|
||||
### 配置网关 {#configure-gateways}
|
||||
### 配置网关 {#configure-gateways}
|
||||
|
||||
网关因为支持定义多个入站、出站网关,所以它是一种特殊类型的组件。
|
||||
在 [`IstioOperator` API](/zh/docs/reference/config/istio.operator.v1alpha1/) 中,网关被定义为列表类型。
|
||||
`default` 配置档会安装一个名为 `istio-ingressgateway` 的入站网关。
|
||||
在 [`IstioOperator` API](/zh/docs/reference/config/istio.operator.v1alpha1/) 中,
|
||||
网关被定义为列表类型。`default` 配置档会安装一个名为 `istio-ingressgateway` 的入站网关。
|
||||
您可以检查这个网关的默认值:
|
||||
|
||||
{{< text bash >}}
|
||||
|
@ -253,7 +258,9 @@ $ istioctl manifest generate --manifests mycharts/ -f manifests/profiles/custom1
|
|||
### 为输出清单打补丁 {#patching-the-output-manifest}
|
||||
|
||||
传递给 `istioctl` 的 `IstioOperator` CR,用于生成输出清单,该清单包含将应用到集群的 Kubernetes 资源。
|
||||
在输出的清单已经生成但没有应用之时,此清单可以通过 `IstioOperator` [覆盖](/zh/docs/reference/config/istio.operator.v1alpha1/#K8sObjectOverlay) API 深度定制以增加、修改或删除资源。
|
||||
在输出的清单已经生成但没有应用之时,此清单可以通过 `IstioOperator`
|
||||
[覆盖](/zh/docs/reference/config/istio.operator.v1alpha1/#K8sObjectOverlay)
|
||||
API 深度定制以增加、修改或删除资源。
|
||||
|
||||
下面例子覆盖文件(`patch.yaml`)展示输出清单补丁这种类型可以做什么:
|
||||
|
||||
|
@ -273,21 +280,21 @@ spec:
|
|||
- kind: Deployment
|
||||
name: istiod
|
||||
patches:
|
||||
# Select list item by value
|
||||
# 按值选择列表项
|
||||
- path: spec.template.spec.containers.[name:discovery].args.[30m]
|
||||
value: "60m" # overridden from 30m
|
||||
# Select list item by key:value
|
||||
# 按 key:value 选择列表项
|
||||
- path: spec.template.spec.containers.[name:discovery].ports.[containerPort:8080].containerPort
|
||||
value: 1234
|
||||
# Override with object (note | on value: first line)
|
||||
# 用对象覆盖(注意 | 值:第一行)
|
||||
- path: spec.template.spec.containers.[name:discovery].env.[name:POD_NAMESPACE].valueFrom
|
||||
value: |
|
||||
fieldRef:
|
||||
apiVersion: v2
|
||||
fieldPath: metadata.myPath
|
||||
# Deletion of list item
|
||||
# 删除列表项
|
||||
- path: spec.template.spec.containers.[name:discovery].env.[name:REVISION]
|
||||
# Deletion of map item
|
||||
# 删除 map 项
|
||||
- path: spec.template.spec.containers.[name:discovery].securityContext
|
||||
- kind: Service
|
||||
name: istiod
|
||||
|
@ -336,5 +343,6 @@ spec:
|
|||
|
||||
### 列出选中的项目目录 {#list-item-path-selection}
|
||||
|
||||
`istioctl --set` 参数和 `IstioOperator` CR 中的 `k8s.overlays` 字段,两者均支持由 `[index]`、`[value]` 或 `[key:value]` 选中的列表项。
|
||||
--set 参数也为资源中缺少的路径创建所有的中间节点。
|
||||
`istioctl --set` 参数和 `IstioOperator` CR 中的 `k8s.overlays` 字段,
|
||||
两者均支持由 `[index]`、`[value]` 或 `[key:value]` 选中的列表项。--set
|
||||
参数也为资源中缺少的路径创建所有的中间节点。
|
||||
|
|
|
@ -84,7 +84,7 @@ $ kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \
|
|||
$ export PATH=$PWD/bin:$PATH
|
||||
{{< /text >}}
|
||||
|
||||
## 安装 Istio {#install}
|
||||
## 安装 Istio {#install}
|
||||
|
||||
1. 本次安装使用 `demo` [配置文件](/zh/docs/setup/additional-setup/config-profiles/)。
|
||||
这个配置文件包含了便于测试的一组默认值,当然您可以使用其他配置文件用于生产或性能测试。
|
||||
|
@ -95,8 +95,8 @@ $ kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \
|
|||
更多细节请参阅[平台指示说明](/zh/docs/setup/platform-setup/)。
|
||||
{{< /warning >}}
|
||||
|
||||
与 [Istio Gateways](/zh/docs/concepts/traffic-management/#gateways) 不同,
|
||||
创建 [Kubernetes Gateways](https://gateway-api.sigs.k8s.io/api-types/gateway/)
|
||||
与 [Istio Gateway](/zh/docs/concepts/traffic-management/#gateways) 不同,
|
||||
创建 [Kubernetes Gateway](https://gateway-api.sigs.k8s.io/api-types/gateway/)
|
||||
将默认[部署关联的网关代理服务](/zh/docs/tasks/traffic-management/ingress/gateway-api/#automated-deployment)。
|
||||
因为本例不会使用这些服务,所以将禁用默认的 Istio 网关服务,
|
||||
这些默认服务通常是作为 `demo` 配置文件的一部分被安装的。
|
||||
|
@ -115,7 +115,7 @@ $ kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \
|
|||
namespace/default labeled
|
||||
{{< /text >}}
|
||||
|
||||
## 部署样例应用{#bookinfo}
|
||||
## 部署样例应用 {#bookinfo}
|
||||
|
||||
1. 部署 [`Bookinfo` 样例应用](/zh/docs/examples/bookinfo/):
|
||||
|
||||
|
@ -174,7 +174,7 @@ $ kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \
|
|||
<title>Simple Bookstore App</title>
|
||||
{{< /text >}}
|
||||
|
||||
## 打开应用并允许对外流量{#ip}
|
||||
## 打开应用并允许对外流量 {#ip}
|
||||
|
||||
Bookinfo 应用已被部署但还不能从外部进行访问。
|
||||
要使其能够被访问,您需要创建 Ingress Gateway,将路径映射到网格边缘处的某个路由。
|
||||
|
@ -202,7 +202,7 @@ Bookinfo 应用已被部署但还不能从外部进行访问。
|
|||
✔ No validation issues found when analyzing namespace: default.
|
||||
{{< /text >}}
|
||||
|
||||
### 确定 Ingress IP 和端口{#determing-ingress-ip-and-ports}
|
||||
### 确定 Ingress IP 和端口 {#determing-ingress-ip-and-ports}
|
||||
|
||||
1. 设置访问网关的 `INGRESS_HOST` 和 `INGRESS_PORT` 变量:
|
||||
|
||||
|
@ -226,7 +226,7 @@ Bookinfo 应用已被部署但还不能从外部进行访问。
|
|||
169.48.8.37:80
|
||||
{{< /text >}}
|
||||
|
||||
### 验证外部访问{#confirm}
|
||||
### 验证外部访问 {#confirm}
|
||||
|
||||
通过浏览器查看 Bookinfo 产品页面,确认能从集群外访问 Bookinfo 应用。
|
||||
|
||||
|
@ -238,7 +238,7 @@ Bookinfo 应用已被部署但还不能从外部进行访问。
|
|||
|
||||
1. 将上一条命令的输出粘贴到您的 Web 浏览器中,确认 Bookinfo 产品页面显示正常。
|
||||
|
||||
## 查看仪表板{#dashboard}
|
||||
## 查看仪表板 {#dashboard}
|
||||
|
||||
Istio 集成了[几种](/zh/docs/ops/integrations)不同的遥测应用。
|
||||
这些可以帮助您了解服务网格的结构,能够显示网格的拓扑,还能分析网格的健康状况。
|
||||
|
@ -268,7 +268,7 @@ Istio 集成了[几种](/zh/docs/ops/integrations)不同的遥测应用。
|
|||
$ istioctl dashboard kiali
|
||||
{{< /text >}}
|
||||
|
||||
1. 在左侧导航菜单中,从 _Namespace_ 下拉菜单中选择 _Graph_,选择 _default_。
|
||||
1. 在左侧导航菜单中,从 **Namespace** 下拉菜单中选择 **Graph**,选择 **default**。
|
||||
|
||||
{{< tip >}}
|
||||
{{< boilerplate trace-generation >}}
|
||||
|
@ -279,7 +279,7 @@ Istio 集成了[几种](/zh/docs/ops/integrations)不同的遥测应用。
|
|||
|
||||
{{< image link="./kiali-example2.png" caption="Kiali Dashboard" >}}
|
||||
|
||||
## 下一步{#next-steps}
|
||||
## 下一步 {#next-steps}
|
||||
|
||||
恭喜完成了评估安装!
|
||||
|
||||
|
@ -300,11 +300,11 @@ Istio 集成了[几种](/zh/docs/ops/integrations)不同的遥测应用。
|
|||
- [Pod 要求](/zh/docs/ops/deployment/requirements/)
|
||||
- [常规安装指示](/zh/docs/setup/)
|
||||
|
||||
## 加入 Istio 社区{#join-istio-community}
|
||||
## 加入 Istio 社区 {#join-istio-community}
|
||||
|
||||
欢迎您加入 [Istio 社区](/zh/get-involved/)提问和给出反馈。
|
||||
|
||||
## 卸载{#uninstall}
|
||||
## 卸载 {#uninstall}
|
||||
|
||||
要删除 `Bookinfo` 样例应用及其配置,请参阅
|
||||
[`Bookinfo` 清理](/zh/docs/examples/bookinfo/#cleanup)。
|
||||
|
@ -332,7 +332,7 @@ $ kubectl label namespace default istio-injection-
|
|||
|
||||
如果您安装了 Kubernetes Gateway API CRD 并且现在想要删除它们,请运行以下命令之一:
|
||||
|
||||
- 如果您运行的任何任务需要 **实验版本** 的 CRD:
|
||||
- 如果您运行的任何任务需要**实验版本**的 CRD:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref={{< k8s_gateway_api_version >}}" | kubectl delete -f -
|
||||
|
|
|
@ -43,7 +43,7 @@ Pod 所属命名空间的 Istio Sidecar 注入器自动注入。
|
|||
|
||||
#### 部署应用 {#deploying-an-app}
|
||||
|
||||
部署 sleep 应用。验证 Deployment 和 Pod 只有一个容器。
|
||||
部署 sleep 应用,验证 Deployment 和 Pod 只有一个容器。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f @samples/sleep/sleep.yaml@
|
||||
|
@ -117,18 +117,18 @@ sleep-776b7bcdcd-gmvnr 1/1 Running 0 2s
|
|||
在上面例子中,您在命名空间层级启用和禁用了注入。
|
||||
注入也可以通过配置 Pod 上的 `sidecar.istio.io/inject` 标签,在每个 Pod 的基础上进行控制。
|
||||
|
||||
| 资源 | 标签 | 启用的值 | 禁用的值 |
|
||||
| -------- | ----- | ------------- | -------------- |
|
||||
| Namespace | `istio-injection` | `enabled` | `disabled` |
|
||||
| Pod | `sidecar.istio.io/inject` | `"true"` | `"false"` |
|
||||
| 资源 | 标签 | 启用的值 | 禁用的值 |
|
||||
| -------- | ------------------------- | ------------- | -------------- |
|
||||
| Namespace | `istio-injection` | `enabled` | `disabled` |
|
||||
| Pod | `sidecar.istio.io/inject` | `"true"` | `"false"` |
|
||||
|
||||
如果您正在使用[控制平面修订版](/zh/docs/setup/upgrade/canary/),将通过匹配 `istio.io/rev`
|
||||
标签来转为使用特定修订版的标签。例如,对于名为 `canary` 的修订版:
|
||||
|
||||
| 资源 | 启用的标签 | 禁用的标签 |
|
||||
| -------- | ------------- | -------------- |
|
||||
| Namespace | `istio.io/rev=canary` | `istio-injection=disabled` |
|
||||
| Pod | `istio.io/rev=canary` | `sidecar.istio.io/inject="false"` |
|
||||
| 资源 | 启用的标签 | 禁用的标签 |
|
||||
| --------- | --------------------- | --------------------------------- |
|
||||
| Namespace | `istio.io/rev=canary` | `istio-injection=disabled` |
|
||||
| Pod | `istio.io/rev=canary` | `sidecar.istio.io/inject="false"` |
|
||||
|
||||
如果 `istio-injection` 标签和 `istio.io/rev` 标签在同一个命名空间中,则优先使用 `istio-injection` 标签。
|
||||
|
||||
|
@ -260,7 +260,7 @@ spec:
|
|||
allowPrivilegeEscalation: false
|
||||
{{< /text >}}
|
||||
|
||||
### 自定义模板(试验特性){#custom-templates-experimental}
|
||||
### 自定义模板(试验特性) {#custom-templates-experimental}
|
||||
|
||||
{{< warning >}}
|
||||
此功能为试验特性功能,可随时更改或删除。
|
||||
|
|
Loading…
Reference in New Issue