- OpenShift
- 自动 sidecar 注入
- Sidecar 应用的专用安全上下文约束(SCC)
OpenShift
OpenShift 4.1 及以上版本使用的 nftables 与 Istio 的 proxy-init 容器不兼容。请使用 CNI 插件代替。
依照本指南对 OpenShift 集群进行配置以便安装运行 Istio。
默认情况下,OpenShift 不允许容器使用 User ID(UID) 0 来运行。通过以下命令可以让 Istio 的服务账户(Service Accounts)以 UID 0 来运行容器(如果你将 Istio 部署到其它命名空间,请注意替换 istio-system ):
$ oc adm policy add-scc-to-group anyuid system:serviceaccounts -n istio-system
现在你可以按照 CNI 的操作来安装 Istio。
安装完成后,为 ingress 网关暴露一个 OpenShift 路由。
$ oc -n istio-system expose svc/istio-ingressgateway --port=80
自动 sidecar 注入
如果你使用的是 OpenShift 4.1 或更高的版本,以下配置不是必须的,可以跳到下一章节。
要使自动注入能正常工作必须启用 Webhook 和证书签名请求(CSR)的支持。请按以下说明在集群 master 节点修改 master 配置文件。
默认情况下,master 配置文件的路径是 /etc/origin/master/master-config.yaml。
在 master 配置文件相同目录下创建文件 master-config.patch,内容如下:
admissionConfig:pluginConfig:MutatingAdmissionWebhook:configuration:apiVersion: apiserver.config.k8s.io/v1alpha1kubeConfigFile: /dev/nullkind: WebhookAdmissionValidatingAdmissionWebhook:configuration:apiVersion: apiserver.config.k8s.io/v1alpha1kubeConfigFile: /dev/nullkind: WebhookAdmission
然后在该目录下执行:
$ cp -p master-config.yaml master-config.yaml.prepatch$ oc ex config patch master-config.yaml.prepatch -p "$(cat master-config.patch)" > master-config.yaml$ master-restart api$ master-restart controllers
Sidecar 应用的专用安全上下文约束(SCC)
OpenShift 默认是不允许 Istio sidecar 注入到每个应用 Pod 中以 ID 为 1377 的用户运行的。要允许使用该 UID 运行,需要执行以下命令(注意替换 <target-namespace> 为适当的命名空间):
$ oc adm policy add-scc-to-group privileged system:serviceaccounts -n <target-namespace>$ oc adm policy add-scc-to-group anyuid system:serviceaccounts -n <target-namespace>
当需要移除应用时,请按以下操作移除权限:
$ oc adm policy remove-scc-from-group privileged system:serviceaccounts -n <target-namespace>$ oc adm policy remove-scc-from-group anyuid system:serviceaccounts -n <target-namespace>
