Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler: support the ability to automatically assign replicas evenly #4805

Open
whitewindmills opened this issue Apr 7, 2024 · 19 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@whitewindmills
Copy link
Member

What would you like to be added:

Background

We want to introduce a new replica assignment strategy in the scheduler, which supports an even assignment of the target replicas across the currently selected clusters.

Explanation

After going through the filtering, prioritization, and selection phases, three clusters(member1, member2, member3) were selected. We will automatically assign 9 replicas equally among these three clusters, the result we expect is [{member1: 3}, {member2: 3}, {member3: 3}].

Why is this needed:

User Story

As a developer, we have a deployment with 2 replicas that needs to be deployed with high availability across AZs. We hope Karmada can schedule it to two AZs and ensure that there is a replica on each AZ.
2AZ

Our PropagationPolicy might look like this:

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: foo
  namespace: bar
spec:
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: foo
  placement:
    replicaScheduling:
      replicaSchedulingType: Divided
      replicaDivisionPreference: Weighted
      weightPreference:
        dynamicWeight: AvailableReplicas
    spreadConstraints:
    - spreadByField: zone
      maxGroups: 2
      minGroups: 2
    - spreadByField: cluster
      maxGroups: 2
      minGroups: 2

But unfortunately, the strategy AvailableReplicas does not guarantee that our replicas are evenly assigned.

Any ideas?

We can introduce a new replica assignment strategy like AvailableReplicas, maybe we can name it AverageReplicas. It is essentially different from static weight assignment, because it does not support spread constraints and is mandatory. When assigning replicas, it does not consider whether the cluster can place so many replicas.

@whitewindmills whitewindmills added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 7, 2024
@XiShanYongYe-Chang
Copy link
Member

If the weights are set to the same, I understand that's the effect.

I understand that sometimes the number of replicas is not divisible by the number of clusters. In this case, there must be some clusters with one more replica.

@whitewindmills
Copy link
Member Author

In this case, there must be some clusters with one more replica.

For general scenarios, we can only achieve the maximum approximate average assignment. This is an unchangeable fact.

@XiShanYongYe-Chang
Copy link
Member

How about describing it in detail at a community meeting?

@whitewindmills
Copy link
Member Author

cc @RainbowMango

@XiShanYongYe-Chang
Copy link
Member

Given the plausibility of this feature, and the fact that the difficulty of implementing it is not very complicated, how about we do this requirement as an OSPP project @RainbowMango @whitewindmills

@Vacant2333
Copy link
Contributor

if user specified it the strategy, will it ignore the result of score step?

@whitewindmills
Copy link
Member Author

if user specified it the strategy, will it ignore the result of score step?

@Vacant2333
Great to hear your thoughts. I don't think this strategy has something to do with cluster scores. Cluster scores only are used to select clusters based on the cluster spread constraint.

@Vacant2333
Copy link
Contributor

hello, i wonder know that when will be different with when we use AverageReplicas, at my understanding, static weight assignment will consider the cluster can create so many replicas, but AverageReplcias will just assign the replicas, any other situation will cause different schdule result?

(( thanks for your answer @whitewindmills

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-propagation
spec:
  #...
  placement:
    replicaScheduling:
      replicaDivisionPreference: Weighted
      replicaSchedulingType: Divided
      weightPreference:
        staticWeightList:
          - targetCluster:
              clusterNames:
                - member1
            weight: 1
          - targetCluster:
              clusterNames:
                - member2
            weight: 1

@whitewindmills
Copy link
Member Author

@Vacant2333
Whether it's the static weight strategy or this AverageReplicas strategy, they're just a way of assigning replicas. At present, the static weights strategy mainly have the following two ”disadvantages“:

  1. Don't comply with the spread constraints.
  2. Does not take into account the available replicas in the cluster.

Hope it helps you.

@Vacant2333
Copy link
Contributor

@whitewindmills i got it, if this feat is not add to OSPP, i would like to implement it~~ im watch on karmada-scheduler for now

@XiShanYongYe-Chang
Copy link
Member

Hi @Vacant2333 We are going to add this task to the OSPP 2024. You can join in the discussion and review.

@ipsum-0320
Copy link
Contributor

/assign

@RainbowMango
Copy link
Member

@whitewindmills explained the reason why introducing a new replica allocation method at #4805 (comment).

I'd like to hear your opinions on the following questions:

  1. Currently, the StaticWeight doesn't take the spread constraints into account, but do you think it should?
  2. As well, do you think StaticWeight should take available resource into account?

@XiShanYongYe-Chang @chaunceyjiang @whitewindmills What's your thoughts?

@whitewindmills
Copy link
Member Author

I prefer to keep it as it is.

@RainbowMango
Copy link
Member

Why? Can you explain it in more detail?

@whitewindmills
Copy link
Member Author

@RainbowMango
there is no doubt that StaticWeight is a static assignment strategy, which refers to a set of rules or configurations that are defined before a system or process runs and generally do not change unless manually updated. and the rules are set up in advance and do not adjust automatically based on real-time data or environmental changes.
so we get the expected output based on the input. AM I RIGHT?
if we try to change its default behavior, I think at least we can no longer call it StaticWeight.

@RainbowMango
Copy link
Member

@XiShanYongYe-Chang @chaunceyjiang What do you think?

@XiShanYongYe-Chang
Copy link
Member

I think a new policy can be added to represent the average. The biggest difference between it and the StaticWeight policy is that the replicas is allocated considering the resources available.
StaticWeight appears to be a rigid and inflexible way of allocating replicas, and is handled exactly as the user has set it up. Perhaps the user will only try this strategy in a test environment.

@whitewindmills
Copy link
Member Author

@RainbowMango what's your options. anyway, this PR #5225 is waiting for you to push forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
Status: No status
Development

No branches or pull requests

5 participants