• Envoy基于文件系统的EDS动态配置


    昨天写了envoy的lds、cds基于文件系统的动态配置,今天整理一下eds的基于文件系统的动态配置。

    resources:
    - "@type": type.googleapis.com/envoy.config.cluster.v3.Cluster
      connect_timeout: 1s
      name: k8s.proxy
      type: EDS
      http2_protocol_options: {}
      eds_cluster_config:
        eds_config:
          path: /root/envoy/test.endpoint.json

    首先需要将cluster的type类型改为EDS,表明该Cluster是基于EDS发现上游服务的。翻看envoy的grpc协议文件可以看出json格式内容

    message DiscoveryResponse {
      option (udpa.annotations.versioning).previous_message_type =
          "envoy.service.discovery.v3.DiscoveryResponse";
      string version_info = 1;
      repeated google.protobuf.Any resources = 2;
      bool canary = 3;
      string type_url = 4;
      string nonce = 5;
      config.core.v4alpha.ControlPlane control_plane = 6;
    }
    message ClusterLoadAssignment {
      option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.ClusterLoadAssignment";
     
      message Policy {
        option (udpa.annotations.versioning).previous_message_type =
            "envoy.api.v2.ClusterLoadAssignment.Policy";
    
       
        message DropOverload {
          option (udpa.annotations.versioning).previous_message_type =
              "envoy.api.v2.ClusterLoadAssignment.Policy.DropOverload";
    
          // Identifier for the policy specifying the drop.
          string category = 1 [(validate.rules).string = {min_len: 1}];
    
          // Percentage of traffic that should be dropped for the category.
          type.v3.FractionalPercent drop_percentage = 2;
        }
    
        reserved 1, 5;
    
        reserved "disable_overprovisioning";
        
        repeated DropOverload drop_overloads = 2;
    
        google.protobuf.UInt32Value overprovisioning_factor = 3 [(validate.rules).uint32 = {gt: 0}];
    
        google.protobuf.Duration endpoint_stale_after = 4 [(validate.rules).duration = {gt {}}];
      }
     
      string cluster_name = 1 [(validate.rules).string = {min_len: 1}];
    
      repeated LocalityLbEndpoints endpoints = 2;
      
      map<string, Endpoint> named_endpoints = 5;
    
      Policy policy = 4;
    }

    简单的EDS配置文件如下

    {
        "version_info": "1",
        "resources": [
            {
                "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment",
                "cluster_name": "k8s.proxy",
                "endpoints": [
                    {
                        "lb_endpoints": [
                            {
                                "endpoint": {
                                    "address": {
                                        "socket_address": {
                                            "address": "xxx.xx.xx.xx",
                                            "port_value": 80
                                        }
                                    }
                                }
                            },
                            {
                                "endpoint": {
                                    "address": {
                                        "socket_address": {
                                            "address": "xxx.xxx.xxx",
                                            "port_value": 80
                                        }
                                    }
                                }
                            }
                        ]
                    }
                ]
            }
        ]
    }

    这样配置之后就可以只更新某个Cluster的EndPoint,而不是更新整个cds配置。

  • 相关阅读:
    SQL Server 百万级数据提高查询速度的方法(转)
    sql优化的几种方法
    MyBatis中调用存储过程和函数
    android ipc通信机制之二序列化接口和Binder
    APK的目录结构
    android Handler错误,不同的包Handler
    BaiduMap开发,获取公交站点信息。
    GitHub托管项目步骤
    Mysql,JDBC封装
    简单工厂模式练习
  • 原文地址:https://www.cnblogs.com/pjjwpc/p/15201935.html
Copyright © 2020-2023  润新知