备考ICA----Istio实验14---出向流量管控Egress Gateways实验

备考ICA----Istio实验14—出向流量管控Egress Gateways实验

1. 发布测试用 pod

kubectl apply -f istio/samples/sleep/sleep.yaml
kubectl get pods -l app=sleep

在这里插入图片描述

2. ServiceEntry

创建一个ServiceEntry允许流量访问edition.cnn.com
egressgw/edition-ServiceEntry.yaml

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: cnn
spec:
  hosts:
  - edition.cnn.com
  ports:
  - number: 80
    name: http-port
    protocol: HTTP
  - number: 443
    name: https
    protocol: HTTPS
  resolution: DNS

部署ServiceEntry

kubectl apply -f egressgw/edition-ServiceEntry.yaml

访问测试

kubectl exec deploy/sleep -- curl -sSL -o /dev/null \
-D - http://edition.cnn.com/politics

在这里插入图片描述
检查egress的日志

kubectl logs -l istio=egressgateway -c istio-proxy -n istio-system | tail

在这里插入图片描述
此时流量是从pod上的envoy直出到公网的.

kubectl logs sleep-7656cf8794-xwqww -c istio-proxy  | tail

在这里插入图片描述

3.将流量导向egress

3.1 定义出口网关规则

为 edition.cnn.com 创建一个出口,端口 80,并为定向到出口网关的流量创建一个目标规则
egressgw/cnn-egressgateway.yaml

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: istio-egressgateway
spec:
  selector:
    istio: egressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - edition.cnn.com
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: egressgateway-for-cnn
spec:
  host: istio-egressgateway.istio-system.svc.cluster.local
  subsets:
  - name: cnn

部署

kubectl apply -f egressgw/cnn-egressgateway.yaml 

3.2 配置egress规则

配置路由规则,将流量从边车导向到 Egress Gateway,再从 Egress Gateway 导向到外部服务
egressgw/direct-cnn-through-egress-gateway.yaml

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: direct-cnn-through-egress-gateway
spec:
  hosts:
  - edition.cnn.com
  gateways:
  - istio-egressgateway
  - mesh
  http:
  - match:
    - gateways:
      - mesh
      port: 80
    route:
    - destination:
        host: istio-egressgateway.istio-system.svc.cluster.local
        subset: cnn
        port:
          number: 80
      weight: 100
  - match:
    - gateways:
      - istio-egressgateway
      port: 80
    route:
    - destination:
        host: edition.cnn.com
        port:
          number: 80
      weight: 100

部署

kubectl apply -f egressgw/direct-cnn-through-egress-gateway.yaml

3.3 再次测试访问

kubectl exec deploy/sleep -- curl -sSL \
-o /dev/null -D - http://edition.cnn.com/politics

在这里插入图片描述
看上去和之前一样,再看下sleep的envoy日志,本次的流量也从envoy sidecar上出去了

kubectl logs sleep-7656cf8794-xwqww -c istio-proxy  | tail

在这里插入图片描述
再看egress的envoy上的日志,之前那次是没有经过egress的,这次流量明显是从egress出去的

kubectl logs -l istio=egressgateway -c istio-proxy -n istio-system | tail

在这里插入图片描述
我们已经将出向的流量配置成由Egress转发
至此备考ICA----Istio实验14—出向流量管控Egress Gateways实验完成

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-30 07:02:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-30 07:02:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-30 07:02:03       87 阅读
  4. Python语言-面向对象

    2024-03-30 07:02:03       96 阅读

热门阅读

  1. 怎么使用vuex的数据和方法

    2024-03-30 07:02:03       36 阅读
  2. 使用VHDL实现俄罗斯方块游戏设计

    2024-03-30 07:02:03       44 阅读
  3. PyTorch中的flatten+transpose函数说明

    2024-03-30 07:02:03       46 阅读
  4. 使用Dom4j解析多层级XML为Map对象

    2024-03-30 07:02:03       39 阅读
  5. 【threejs】计算矩阵、网格等总面积

    2024-03-30 07:02:03       46 阅读
  6. spark DataFrame通过JDBC读写数据库(MySQL示例)

    2024-03-30 07:02:03       36 阅读
  7. npm包发布

    2024-03-30 07:02:03       40 阅读
  8. Node.js常用命令详解

    2024-03-30 07:02:03       40 阅读
  9. 在axios中设置方法防止http重复请求

    2024-03-30 07:02:03       37 阅读
  10. SqlSugar快速入门

    2024-03-30 07:02:03       42 阅读
  11. qt之windows库编译

    2024-03-30 07:02:03       47 阅读
  12. MYSQL分区

    2024-03-30 07:02:03       38 阅读