karmada
karmada copied to clipboard
Deployment deployed in all cluster members
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:
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.
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?
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 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?
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.
Thanks. Another question, how to propagate resource to every mebmer of member clusters? Hah,@RainbowMango
set minGroups to number of member clusters?
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.
ok, thanks. @RainbowMango
/close Feel free to reopen it if you have any questions.
@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.