4.3. 在 Istio ambient 模式中部署 Bookinfo 应用程序
您可以使用 ZTunnel 代理在 Istio ambient 模式中部署 info 示例应用程序,而无需 sidecar 注入。有关 bookinfo 应用程序的更多信息,请参阅"关于 Bookinfo 应用程序"。
先决条件
- 您已在 OpenShift Container Platform 4.15 或更高版本上部署了集群,其中包括 Istio ambient 模式所需的支持的 Kubernetes 网关 API 自定义资源定义(CRD)。
-
根据安装方法,您可以通过 Web 控制台以具有
cluster-admin角色的用户身份或使用oc login命令登录 OpenShift Container Platform 集群。 - 已安装 Red Hat OpenShift Service Mesh Operator,创建 Istio 资源,Operator 已部署 Istio。
-
您已创建了
IstioCNI资源,Operator 已部署必要的IstioCNIpod。 -
您已创建了
Ztunnel资源,Operator 已部署必要的Ztunnelpod。
流程
运行以下命令来创建
info命名空间:$ oc create namespace info运行以下命令,将
istio-discovery=enabled标签添加到info命名空间中:$ oc label namespace info istio-discovery=enabled运行以下命令应用
infoYAML 文件来部署bookinfo应用程序:$ oc apply -n info -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.26/samples/bookinfo/platform/kube/bookinfo.yaml运行以下命令应用
info-versionsYAML 文件来部署bookinfo应用程序:$ oc apply -n info -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.26/samples/bookinfo/platform/kube/bookinfo-versions.yaml输入以下命令验证
infopod 是否正在运行:$ oc -n info get pods输出示例
NAME READY STATUS RESTARTS AGE details-v1-54ffdd5947-8gk5h 1/1 Running 0 5m9s productpage-v1-d49bb79b4-cb9sl 1/1 Running 0 5m3s ratings-v1-856f65bcff-h6kkf 1/1 Running 0 5m7s reviews-v1-848b8749df-wl5br 1/1 Running 0 5m6s reviews-v2-5fdf9886c7-8xprg 1/1 Running 0 5m5s reviews-v3-bb6b8ddc7-bvcm5 1/1 Running 0 5m5s输入以下命令验证
info应用程序是否正在运行:$ oc exec "$(oc get pod -l app=ratings -n info \ -o jsonpath='{.items[0].metadata.name}')" \ -c ratings -n info \ -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"通过标记整个命名空间或单个 pod 将 info 应用程序添加到 Istio ambient mesh 中:
要在 info 命名空间中包括所有工作负载,请运行以下命令将
istio.io/dataplane-mode=ambient标签应用到bookinfo命名空间:$ oc label namespace info istio.io/dataplane-mode=ambient-
要只包含特定的工作负载,请将
istio.io/dataplane-mode=ambient标签直接应用到单个 pod。如需了解用于在网格中添加或排除工作负载的标签的更多详细信息,请参阅"添加资源"部分。
注意在 ambient mesh 中添加工作负载不需要重启或重新部署应用程序 pod。与 sidecar 模式不同,每个 pod 中的容器数量保持不变。
运行以下命令,确认 Ztunnel 代理已在 pod 网络命名空间中成功打开侦听套接字:
$ istioctl ztunnel-config workloads --namespace ztunnel输出示例
NAMESPACE POD NAME ADDRESS NODE WAYPOINT PROTOCOL info details-v1-54ffdd5947-cflng 10.131.0.69 ip-10-0-47-239.ec2.internal None HBONE info productpage-v1-d49bb79b4-8sgwx 10.128.2.80 ip-10-0-24-198.ec2.internal None HBONE info ratings-v1-856f65bcff-c6ldn 10.131.0.70 ip-10-0-47-239.ec2.internal None HBONE info reviews-v1-848b8749df-45hfd 10.131.0.72 ip-10-0-47-239.ec2.internal None HBONE info reviews-v2-5fdf9886c7-mvwft 10.128.2.78 ip-10-0-24-198.ec2.internal None HBONE info reviews-v3-bb6b8ddc7-fl8q2 10.128.2.79 ip-10-0-24-198.ec2.internal None HBONE istio-cni istio-cni-node-7hwd2 10.0.61.108 ip-10-0-61-108.ec2.internal None TCP istio-cni istio-cni-node-bfqmb 10.0.30.129 ip-10-0-30-129.ec2.internal None TCP istio-cni istio-cni-node-cv8cw 10.0.75.71 ip-10-0-75-71.ec2.internal None TCP istio-cni istio-cni-node-hj9cz 10.0.47.239 ip-10-0-47-239.ec2.internal None TCP istio-cni istio-cni-node-p8wrg 10.0.24.198 ip-10-0-24-198.ec2.internal None TCP istio-system istiod-6bd6b8664b-r74js 10.131.0.80 ip-10-0-47-239.ec2.internal None TCP ztunnel ztunnel-2w5mj 10.128.2.61 ip-10-0-24-198.ec2.internal None TCP ztunnel ztunnel-6njq8 10.129.0.131 ip-10-0-75-71.ec2.internal None TCP ztunnel ztunnel-96j7k 10.130.0.146 ip-10-0-61-108.ec2.internal None TCP ztunnel ztunnel-98mrk 10.131.0.50 ip-10-0-47-239.ec2.internal None TCP ztunnel ztunnel-jqcxn 10.128.0.98 ip-10-0-30-129.ec2.internal None TCP