用领事来配置Istio-Envoy

时间:2018-04-27 15:08:21

标签: microservices mesh consul istio envoyproxy

我正在尝试使用Istio构建服务网格。目前我有一个Docker-Compose,每个都有两个REST服务和一个sidecar(Envoy)。如果向serviceA发送HTTP请求,则会将其转发给serviceB,后者返回结果。它工作正常。由于尚未实现控制平面,因此使用Envoy配置实现“网格”。配置文件如下所示:

ServiceA:

static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 80
  filter_chains:
  - filters:
    - name: envoy.http_connection_manager
      config:
        codec_type: auto
        stat_prefix: ingress_http
        route_config:
          name: local_route
          virtual_hosts:
          - name: service
            domains:
            - "*"
            routes:
            - match:
                prefix: "/abc"
              route:
                prefix_rewrite: "/v1/abc"
                host_rewrite: serviceB
                cluster: service_ner
        http_filters:
        - name: envoy.router
          config: {}
  clusters:
  - name: service_abc
    connect_timeout: 0.25s
    type: logical_dns
    dns_lookup_family: V4_ONLY
    lb_policy: round_robin
    hosts:
    - socket_address:
        address: serviceB
        port_value: 80
admin:
  access_log_path: "/dev/null"
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 8081

服务B:

static_resources:
  listeners:
  - address:
  socket_address:
    address: 0.0.0.0
    port_value: 80
  filter_chains:
  - filters:
    - name: envoy.http_connection_manager
      config:
        codec_type: auto
        stat_prefix: ingress_http
        route_config:
          name: local_route
          virtual_hosts:
          - name: service
            domains:
            - "*"
            routes:
            - match:
                prefix: "/"
              route:
                cluster: local_service
        http_filters:
        - name: envoy.router
          config: {}
  clusters:
  - name: local_service
    connect_timeout: 0.25s
    type: strict_dns
    lb_policy: round_robin
    hosts:
    - socket_address:
        address: 127.0.0.1
        port_value: 5001
admin:
  access_log_path: "/dev/null"
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 8081

现在我想实现Istio作为控制平面,我正在尝试使用Istio-Pilot替换部分配置。是否可以通过实施Istio-route规则从Envoy配置文件覆盖路由规则?例如:

apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
  name: ruleSerA
spec:
  destination:
    name: serviceA
  precedence: 2
  route:
  - labels:
      version: v1
---
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
  name: ruleSerB
spec:
  destination:
    name: serviceB
  precedence: 2
  match:
    request:
      headers:
        uri:
          prefix: /abc
  rewrite:
    uri: /v1/abc
  route:
  - labels:
      version: v1

我还需要配置什么来连接数据平面和服务平面?到目前为止,Istio-route规则根本不影响服务。

最好的问候,马丁

0 个答案:

没有答案