zoukankan      html  css  js  c++  java
  • 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配置。

  • 相关阅读:
    js将时间戳转化为时间,(不省略0)
    SpringMVC路径传参
    贪心算法及实例
    剪绳子(贪心算法)
    c语言输入一行未知个数数字存入数组
    Netlink机制详解
    new和malloc的区别
    堆 和 栈的 区别
    strlen与sizeof区别(转载)
    任务
  • 原文地址:https://www.cnblogs.com/pjjwpc/p/15201935.html
Copyright © 2011-2022 走看看