istio服务网格之bookinfo
istio中文官网:https://istio.io/latest/zh/docs/setup/getting-started/
直接用dockerfile编写部署构建镜像
FROM python:3.7.7-slim COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY test-requirements.txt ./ RUN pip install --no-cache-dir -r test-requirements.txt COPY productpage.py /opt/microservices/ COPY tests/unit/* /opt/microservices/ COPY templates /opt/microservices/templates COPY static /opt/microservices/static COPY requirements.txt /opt/microservices/ ARG flood_factor ENV FLOOD_FACTOR ${flood_factor:-0} EXPOSE 9080 WORKDIR /opt/microservices RUN python -m unittest discover CMD ["python", "productpage.py", "9080"] |
部署,并在部署时增加暴露端口
kubectl label namespace default istio-injection=enabled #istio 边车代理 ,自动进行注入 kubectl edit svc productpage .... ports: - name: http port: 9080 protocol: TCP targetPort: 9080 nodePort: 30881 #增加 selector: app: productpage sessionAffinity: None type: NodePort #修改为NodePort .... 在bookinfo.yaml文件中注释reviews其他版本的资源或者部署完成后删除掉reviews其他版本的deployment |
配置流量控制发布策略,设置 60%流量访问本地容器集群,40%流量访问公有云容器集群。实现 bookinfo 的灰度发布。
apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: reviews spec: hosts: - reviews http: - route: - destination: host: reviews subset: v1 weight: 60 - destination: host: reviews subset: v2 weight: 40 |
设置熔断规则, 对 Bookinfo 其中的productpage 微服务设置熔断规则,并通过负载 fortio 测试客户端触发熔断机制进行验证。
apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: productpage namespace: default spec: host: productpage trafficPolicy: connectionPool: http: maxRequestsPerConnection: 1 http1MaxPendingRequests: 1 tcp: maxConnections: 1 |
- 点赞
- 收藏
- 关注作者
评论(0)