云计算-容器云-服务网格Bookinfo

服务网格:创建 Ingress Gateway

将 Bookinfo 应用部署到 default 命名空间下,请为 Bookinfo 应用创建一个网 关,使外部可以访问 Bookinfo 应用。

上传ServiceMesh.tar.gz包

powershell 复制代码
[root@k8s-master-node1 ~]# tar -zxvf ServiceMesh.tar.gz 
[root@k8s-master-node1 ~]# cd ServiceMesh/images/
[root@k8s-master-node1 images]# docker load -i image.tar 
部署Bookinfo应用到kubernetes集群:
[root@k8s-master-node1 images]# cd /root/ServiceMesh/
[root@k8s-master-node1 ServiceMesh]# kubectl apply -f bookinfo/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
service/productpage created
serviceaccount/bookinfo-productpage created
deployment.apps/productpage-v1 created
[root@k8s-master-node1 ServiceMesh]# kubectl get pod
NAME                              READY   STATUS    RESTARTS   AGE
details-v1-79f774bdb9-kndm9       1/1     Running   0          7s
productpage-v1-6b746f74dc-bswbx   1/1     Running   0          7s
ratings-v1-b6994bb9-6hqfn         1/1     Running   0          7s
reviews-v1-545db77b95-j72x5       1/1     Running   0          7s
[root@k8s-master-node1 ServiceMesh]# vim bookinfo-gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts: 
    - "*" 
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: bookinfo
spec:
  hosts: 
  - "*"  
  gateways:
  - bookinfo-gateway
  http:
  - match: 
    - uri:
        exact: /productpage 
    - uri:
        prefix: /static
    - uri:
        exact: /login
    - uri:
        exact: /logout
    - uri:
        prefix: /api/v1/products
    route: # 定义路由转发目的地列表
    - destination:
        host: productpage
        port:
          number: 9080
[root@k8s-master-node1 ServiceMesh]# kubectl apply -f bookinfo-gateway.yaml
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created 
[root@k8s-master-node1 ServiceMesh]#kubectl get VirtualService bookinfo -o yaml
bookinfo-gateway || exact: /productpage || destination || host: productpage || number: 9080
[root@k8s-master-node1 ServiceMesh]#kubectl get gateway bookinfo-gateway -o yaml
istio: ingressgateway

服务网格:路由管理

将 Bookinfo 应用部署到 default 命名空间下,应用默认请求路由,将所有流 量路由到各个微服务的 v1 版本。然后更改请求路由 reviews,将指定比例的流量 从 reviews 的 v1 转移到 v3。

powershell 复制代码
[root@k8s-master-node1 ServiceMesh]# vim route.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews-route
spec:
  hosts: # 将流量路由到指定主机
  - reviews
  http:
  - name: "v1"
    route: # 定义路由转发目的地列表(所有http流量都会被路由到标签为version:v1的reviews服务上)
    - destination:
        host: reviews
        subset: v1
  - name: "v2"
    match:
    - uri:
        prefix: "/wpcatalog"
    - uri:
        prefix: "/consumercatalog"
    rewrite: # 定义重写HTTP URL 或 Authority headers,不能与重定向同时配置,重写操作会在转发前执行
      uri: "/newcatalog"
    route:
    - destination:
        host: reviews
        subset: v2
[root@k8s-master-node1 ServiceMesh]# kubectl apply -f route.yaml
virtualservice.networking.istio.io/reviews-route created
相关推荐
AWS官方合作商6 小时前
AWS EC2实例安全远程访问最佳实践
运维·安全·云计算·aws
数据与人工智能律师9 小时前
加密货币犯罪的涉案金额如何计算?
网络·人工智能·算法·云计算·区块链
ICT系统集成阿祥1 天前
边缘云的定义、实现与典型应用场景!与传统云计算的区别!
云计算
Johny_Zhao1 天前
Kali Linux 从入门到实战:系统详解与工具指南
网络·人工智能·网络安全·信息安全·云计算·nmap·等保测评·系统运维·itsm·网络安全等级保护二级测评
炎码工坊2 天前
云原生安全基础:Linux 文件权限管理详解
linux·安全·网络安全·云原生·云计算
炎码工坊2 天前
云原生安全之网络IP协议:从基础到实践指南
tcp/ip·安全·网络安全·云原生·云计算
humors2212 天前
阿里云合集(不定期更新)
linux·运维·服务器·阿里云·云计算·ecs
国际云,接待2 天前
阿里云国际版香港轻量云服务器:CN2 GIA加持,征服海外网络的“速度与激情”!
linux·运维·服务器·科技·ubuntu·阿里云·云计算
阿里云大数据AI技术2 天前
企业级AI搜索解决方案:阿里云AI搜索开放平台
大数据·人工智能·深度学习·搜索引擎·阿里云·云计算
从零开始学习人工智能2 天前
阿里云API RAG全流程实战:从模型调用到多模态应用的完整技术链路
阿里云·云计算