karmada icon indicating copy to clipboard operation
karmada copied to clipboard

Deployment deployed in all cluster members

Open mrequena opened this issue 3 years ago • 3 comments

Please provide an in-depth description of the question you have: I have 2 clusters in Karmada. When I apply a deployment, the deployment is deployed in both clusters. I use a simple nginx deployment as the one in samples/nginx/deployment.yaml. I use propagationpolicy.yaml (from samples/nginx) without the block "replicaScheduling" because I only have 1 replica. I want to deploy the deployment in only one cluster (randomly chosen by karmada/k8s or depending on the "load" of the cluster). Is this possible? I guess I can to configure correctly propagationpolicy.yaml, right? What options there exists for the scheduler of Karmada?

What do you think about this question?:

Environment:

  • Karmada version: v1.3.0
  • Kubernetes version: v1.24.6
  • Others:

mrequena avatar Oct 27 '22 12:10 mrequena

I want to deploy the deployment in only one cluster (randomly chosen by karmada/k8s or depending on the "load" of the cluster). Is this possible?

For now, the number of selected clusters can be restricted by SpreadConstraint, a simple example would be:

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: example-policy
spec:
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: deployment-1
  placement:
    clusterAffinity:
      clusterNames:
        - member1
        - member2
   spreadConstraints:
      - spreadByField: cluster
        maxGroups: 1  ## only one cluster would be selected.

Karmada scheduler will select one cluster, but for now, it doesn't consult the load of the cluster. We are working on it at #780.

RainbowMango avatar Oct 27 '22 13:10 RainbowMango

I tested and it works (thanks!), i.e. the deployment is deployed in only one cluster. In addition to this, I tried several times and the deployment is done in the same cluster. What is the policy of the Karmada scheduler to choose the cluster?

mrequena avatar Oct 28 '22 18:10 mrequena

Good questions. But hard to say. Because the Karmada scheduler makes the final decision according to a bunch of factors, not by random, some of the rules are defined by plugins, maybe you can figure out it from the scheduler logs.

RainbowMango avatar Oct 29 '22 01:10 RainbowMango

@RainbowMango Can I propagate a resource to a random member, when I don't know the clusterNames, or I should not care the member clusters.

......
  placement:
    spreadConstraints:
      - spreadByField: cluster
        maxGroups: 1  ## only one cluster would be selected.

Does it works?

szediktam avatar Nov 17 '22 14:11 szediktam

Yes, I think it works. In addition, you can use both minGroups and maxGroups to specify the number of member clusters, if you want to propagate to more than one cluster.

RainbowMango avatar Nov 19 '22 07:11 RainbowMango

Thanks. Another question, how to propagate resource to every mebmer of member clusters? Hah,@RainbowMango

szediktam avatar Nov 20 '22 13:11 szediktam

set minGroups to number of member clusters?

szediktam avatar Nov 20 '22 13:11 szediktam

how to propagate resource to every mebmer of member clusters?

The easiest way is to leave the .spec.placement unset so that the resource will be propagated to every member cluster.

RainbowMango avatar Nov 21 '22 01:11 RainbowMango

ok, thanks. @RainbowMango

szediktam avatar Nov 21 '22 11:11 szediktam

/close Feel free to reopen it if you have any questions.

Poor12 avatar Apr 24 '23 07:04 Poor12

@Poor12: Closing this issue.

In response to this:

/close Feel free to reopen it if you have any questions.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

karmada-bot avatar Apr 24 '23 07:04 karmada-bot