ITPub博客

首页 > 应用开发 > XML/XSL > 获取目标集群列表:从 bindingSpec.Clusters 中获取调度结果

获取目标集群列表:从 bindingSpec.Clusters 中获取调度结果

投稿 XML/XSL 作者:crucz025 时间:2026-01-28 19:23:17 0 删除 编辑
    • 克隆 workload
    • 根据调度结果调整副本数( ReviseReplica)
    • 应用 OverridePolicies
    • 创建 Work 对象

四、RB 的数据结构

4.1 ResourceBindingSpec


//   2. If both ClusterAffinity and ClusterAffinities are not set, any cluster //      can be scheduling candidates. // +optional ClusterAffinity *ClusterAffinity `json:"clusterAffinity,omitempty"` // ClusterAffinities represents scheduling restrictions to multiple cluster // groups that indicated by ClusterAffinityTerm. // // The scheduler will evaluate these groups one by one in the order they // appear in the spec, the group that does not satisfy scheduling restrictions // will be ignored which means all clusters in this group will not be selected // unless it also belongs to the next group(a cluster could belong to multiple // groups).


// // If none of the groups satisfy the scheduling restrictions, then scheduling // fails, which means no cluster will be selected. // // Note: //  czjzz.com    1. ClusterAffinities can not co-exist with ClusterAffinity. //   2. If both ClusterAffinity and ClusterAffinities are not set, any cluster //   skjcxs.cn     can be scheduling candidates. // // Potential use case 1:sx17.cn   // The private clusters in the local data center could be the main group, and // the managed clusters provided by cluster providers could be the secondary // group. So that the Karmada scheduler would prefer to schedule workloads // to the main group and the second group will only be considered in case of // the main group does not satisfy restrictions(like, lack of resources). //


// Potential use case 2: // For the disaster recovery scenario, the clusters could be organized to // primary and backup groups, the workloads would be scheduled to primary // clusters firstly, and when primary cluster fails(like data center power off), // Karmada scheduler could migrate workloads to the backup clusters. // // +optional ClusterAffinities []ClusterAffinityTerm `json:"clusterAffinities,omitempty"`


// ClusterTolerations represents the tolerations. // +optional ClusterTolerations []corev1.Toleration `json:"clusterTolerations,omitempty"`



// SpreadConstraints represents a list of the scheduling constraints. // +optional SpreadConstraints []SpreadConstraint `json:"spreadConstraints,omitempty"` // ReplicaScheduling represents the scheduling policy on dealing with the number of replicas // when propagating resources that have replicas in spec (e.g. deployments, statefulsets) to member clusters. // +optional


  • ClusterAffinity: 首选哪些集群(通过标签、字段、集群名选择)
  • ClusterTolerations: 集群容忍度(类似 Pod 的 Tolerations)
  • SpreadConstraints: 分散约束(如:最多 3 个集群,每个集群至少 1 个副本)
  • ReplicaScheduling: 副本调度策略(Duplicated 或 Divided)

ResourceBindingSpec

RB 的 Spec 包含:

  • Resource: 资源引用(APIVersion, Kind, Name, Namespace, UID)
  • Replicas: 副本数(从 ResourceInterpreter 获取)
  • ReplicaRequirements: 资源需求(CPU、内存等)
  • Clusters: 目标集群列表( 由 Scheduler 填充)
  • Placement: 放置规则(从 PropagationPolicy 复制)
  • Failover: 故障转移行为


ype FailoverBehavior struct { huome.cn // Application indicates failover behaviors in case of application failure. // If this value is nil, failover is disabled. // If set, the PropagateDeps should be true so that the dependencies could // be migrated along with the application. // +optional Application *ApplicationFailoverBehavior `json:"application,omitempty"` // Cluster indicates failover behaviors in case of cluster failure. // If this value is nil, the failover behavior in case of cluster failure


// will be controlled by the controller's no-execute-taint-eviction-purge-mode // parameter. // If set, the failover behavior in case of cluster failure will be defined // by this value.


// +optional Cluster *ClusterFailoverBehavior `json:"cluster,omitempty"` } // ApplicationFailoverBehavior indicates application failover behaviors. type ApplicationFailoverBehavior struct {huome.cn // DecisionConditions indicates the decision conditions  moyizhai.com   of performing the failover process. // Only when all conditions are met can the failover process be performed. // Currently, DecisionConditions includes several conditions:


// - TolerationSeconds (optional)  hcsaikj.com // +required DecisionConditions DecisionConditions `json:"decisionConditions"`xmich.cn // PurgeMode represents how to deal with the legacy applications on the // cluster from which the application is migrated. // Valid options are "Directly", "Gracefully", "Never", "Immediately"(deprecated), // and "Graciously"(deprecated). // Defaults to "Gracefully". // +kubebuilder:validation:Enum=Directly;Gracefully;Never;Immediately;Graciously // +kubebuilder:default=Gracefully


在分布式系统中,最危险的不是错误,而是慢。当某个下游服务变慢时:

  • 上游请求不断堆积
  • 线程、连接被耗尽
  • 最终引发级联故障(雪崩)

Envoy 的熔断机制,目的非常明确:在下游资源耗尽之前,主动拒绝请求,保护系统整体稳定

Envoy 的熔断配置

Envoy 的熔断是基于资源使用情况的硬限制,而不是基于错误率的统计判断。

核心限制指标包括:

  • 最大连接数
  • 最大并发请求数
  • 最大等待请求数
  • 最大重试请求数


[ 2025-12-30T08:03:41.267Z ] "GET /test HTTP/1.0" 200 40 0 aecc99c3 -4649 -478e-8610 -79e1 b86c6338 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service - [ 2025-12-30T08:03:41.270Z ] "GET /test HTTP/1.0" 503 81 0 98609f 61 -60 cf -4522 -96 c6-e0eb51743791 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service UO [ 2025-12-30T08:03:41.270Z ] "GET /test HTTP/1.0" 503 81 0 0b 244330 -25b d -48e9 -b9fc-a0b7f5846e17 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service UO [ 2025-12-30T08:03:41.270Z ] "GET /test HTTP/1.0" 503 81 0 09906490 -1916 -4e26 -bc9f -85 d830e1f219 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service UO  czjzz.com [ 2025-12-30T08:03:41.271Z ] "GET /test HTTP/1.0" 503 81 0 a77bc60a -5 cdc -4340 -8969 -9 ce2a1b6206d "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service UO [ 2025-12-30T08:03:41.270Z ] "GET /test HTTP/1.0" 200 40 2 550 dc619 -6002 -4b d6 -9b 36 -3f e1a2b2b3e3 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service - [ 2025-12-30T08:03:41.270Z ] "GET /test HTTP/1.0" 200 40 3 da2a001c -3 dc0 -4 afb-ae0a-a09b78642890 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service - meistercoating.cn [ 2025-12-30T08:03:41.269Z ] "GET /test HTTP/1.0" 200 40 3 3 a7f7ec4 -42 c1 -48 d3-acf5 -190 a81439d84 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service -  sytianxing.cn [ 2025-12-30T08:03:41.270Z ] "GET /test HTTP/1.0" 200 40 4 3b cd9947-e4c2 -43 c8 -84 de -12b d551af590


          address:             socket_address:               address: 0.0 .0 .0               port_value: 10000           filter_chains:             - filters:                 - name: envoy.filters.network.http_connection_manager                   typed_config:                     ...                     http_filters:                     - name: envoy.filters.http.local_ratelimit                       typed_config:                         "@type" : type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit                         stat_prefix: purongtech.com   local_rate_limiter                         token_bucket:                           max_tokens: 100                           tokens_per_fill: 100                           fill_interval: 1s                         filter_enabled:                           default_value:                             numerator: 100                             denominator: HUNDRED                         filter_enforced:                           default_value:xmich.cn                             numerator: 100                             denominator: HUNDRED


[ 2025-12-30T09:58:43.655Z ] "GET /test HTTP/1.0" 200 40 1 f775154c -898e-46 b2 -99 d5-b5629493834c "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service - [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 429 18 0 fde80049-a2df -473e-9 f96 -08 a1526352ce "ApacheBench/2.3" "-" - app_service RL [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 429 18 0 85 d3f948-eb71 -4304 -88 ae-ab1dc29e42b7 "ApacheBench/2.3" "-" - app_service RL [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 429 18 0 11 c01a56 -46f 1 -4b c0-a611 -4 d32d32e3440 "ApacheBench/2.3" "-" - app_service RL [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 429 18 0 53 d14770-b89a -48 ec-a430-a10d28849ccd "ApacheBench/2.3" "-" - app_service RL  yqfh.cn [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 429 18 0 2b cfd5d9-bfba -4b da-b178-aaf85389a5c6 "ApacheBench/2.3" "-" - app_service RL [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 200 40 2 1 c56e4ec-b463 -4 a89-bdcb -978 d81ec5826 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service - sx17.cn [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 200 40 2 989 c07b8 -1 af3 -48f 1 -9398 -fb28ad1ad0bd "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service - [ 2025-12-30T09:58:43.658Z ] "GET /test HTTP/1.0" 200 40 2 ba224777 -066 d -4f ae-b7e3-e5461c94b236 "ApacheBench/2.3" "-" 10.244 .0 .203 : 10000 app_service -



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70048956/viewspace-3109307/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2026-01-28

  • 博文量
    15
  • 访问量
    13025