创建 Bookinfo 示例应用程序

在安装好 Servicemesh Operator 并创建 Istio Service Mesh Control Plane 后

1、创建用来部署应用程序的命名空间

$ oc new-project bookinfo

2、在 创建 ServicemeshControlplane 的命名空间下创建 Istio Service Mesh Member Roll

  1. 导航到安装的 Operators。
  2. 点项目 菜单,从列表中选择部署 ServiceMeshControlPlane 资源的项目,如 istio-system。
  3. 点选择 Servicemesh 。
  4. 选择 Istio Service Mesh Member Roll 选项卡。
  5. 创建 ServiceMeshMemberRoll。
  6. 如下所示,在Member 中添加部署应用的项目,例如bookinfoOpenshift 服务网格部署 Bookinfo 应用_服务网格

或者编辑 Yaml 创建:

apiVersion: maistra.io/v1
kind: ServiceMeshMemberRoll
metadata:
  name: default
spec:
  members:
  - bookinfo

3、 运行以下命令,以验证 ServiceMeshMemberRoll 是否已成功创建。

$ oc get smmr -n istio-system -o wide
NAME      READY   STATUS       AGE     MEMBERS
default   1/1     Configured   2m44s   ["bookinfo"]

4、通过应用 bookinfo.yaml 文件在 bookinfo 项目中部署 Bookinfo:

$ $ oc apply -n info -f https://raw.githubusercontent.com/Maistra/istio/maistra-2.1/samples/bookinfo/platform/kube/bookinfo.yaml

您应该看到类似如下的输出:

service/details created
serviceaccount/bookinfo-details created
deployment.apps/details-v1 created
service/ratings created
serviceaccount/bookinfo-ratings created
deployment.apps/ratings-v1 created
service/reviews created
serviceaccount/bookinfo-reviews created
deployment.apps/reviews-v1 created
deployment.apps/reviews-v2 created
deployment.apps/reviews-v3 created
service/productpage created
serviceaccount/bookinfo-productpage created
deployment.apps/productpage-v1 created

5、 通过应用 bookinfo-gateway.yaml 文件创建入站网关 :

$ oc apply -n info -f https://raw.githubusercontent.com/Maistra/istio/maistra-2.4/samples/bookinfo/networking/bookinfo-gateway.yaml

您应该看到类似如下的输出:

gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo  created

设置 GATEWAY_URL 参数的值:

$ export GATEWAY_URL=$(oc -n istio-system get route istio-ingressgateway -o jsonpath='{.spec.host}')

添加默认目的地规则

在使用 Bookinfo 应用程序前,添加默认目的地规则。根据是否启用了 mutual TLS 验证:

如果没有启用 mutual TLS:

$ oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-2.1/samples/bookinfo/networking/destination-rule-all.yaml

如果启用了 mutual TLS:

$ oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-2.1/samples/bookinfo/networking/destination-rule-all-mtls.yaml

您应该看到类似如下的输出:

destinationrule.networking.istio.io/productpage created
destinationrule.networking.istio.io/reviews created
destinationrule.networking.istio.io/ratings created
destinationrule.networking.istio.io/details created

验证 Bookinfo 安装

验证所有 Pod 是否就绪:

$ oc get pods -n bookinfo

所有容器集的状态都应为 Running。您应该看到类似如下的输出:

NAME                              READY   STATUS    RESTARTS   AGE
details-v1-75cfbc6cd5-svx86       2/2     Running   0          149m
productpage-v1-5b9687fb75-kz5d8   2/2     Running   0          149m
ratings-v1-579dd76bbf-2rd5s       2/2     Running   0          149m
reviews-v1-7746457b7-56zm9        2/2     Running   0          149m
reviews-v2-777684cbf7-2hxdx       2/2     Running   0          149m
reviews-v3-76fd7d799-7jjvs        2/2     Running   0          149m

访问产品页面的 URL:

echo "http://$GATEWAY_URL/productpage"

Openshift 服务网格部署 Bookinfo 应用_OpenShift_02



参考 <<Redhat 文档>>