This tutorial will walk you through how to deploy applications to multiple clusters with dynamic scheduling. It is different from static dividing scheduling. When using dynamic scheduling, the replicas of an application will be split based on cluster capacity.
Let’s see an example using dynamic scheduling. Below
Subscription “dynamic-dividing-scheduling-demo” defines the
target child clusters to be distributed to, and the resources to be deployed with.
# examples/dynamic-dividing-scheduling/subscription.yaml apiVersion: apps.clusternet.io/v1alpha1 kind: Subscription metadata: name: dynamic-dividing-scheduling-demo namespace: default spec: subscribers: # filter out a set of desired clusters - clusterAffinity: matchExpressions: - key: clusters.clusternet.io/cluster-id operator: Exists schedulingStrategy: Dividing dividingScheduling: type: Dynamic dynamicDividing: strategy: Spread # currently we only support Spread dividing strategy feeds: # defines all the resources to be deployed with - apiVersion: v1 kind: Namespace name: qux - apiVersion: v1 kind: Service name: my-nginx-svc namespace: qux - apiVersion: apps/v1 # with a total of 6 replicas kind: Deployment name: my-nginx namespace: qux
Deployment qux/my-nginx above will run in a set of clusters with a total of 6 replicas. For example, if we’ve got
three matching clusters as below.
cluster-01can run 3 replicas of Deployment
cluster-02can run 6 replicas of Deployment
cluster-03can run 9 replicas of Deployment
clusternet-scheduler will assign replicas to each matching cluster by their capacity. As a result, these three clusters
will run 1, 2, 3 replicas respectively.
You can get the scheduling result by checking the status of Subscription
bindingClusters: - clusternet-v7wzq/clusternet-cluster-bb2xp - clusternet-wlf5b/clusternet-cluster-skxd4 - clusternet-bbf20/clusternet-cluster-aqx3b desiredReleases: 6 replicas: apps/v1/Deployment/qux/my-nginx: - 1 - 2 - 3 v1/Namespace/qux:  v1/Service/qux/my-nginx-svc: 
If you want to apply overrides per cluster, please follow How to Set Overrides in Clusternet.
After installing kubectl plugin kubectl-clusternet, you could run commands below to distribute this application to child clusters.
$ kubectl clusternet apply -f examples/dynamic-dividing-scheduling/ namespace/qux created deployment.apps/my-nginx created service/my-nginx-svc created subscription.apps.clusternet.io/dynamic-dividing-scheduling-demo created $ # or $ # kubectl-clusternet apply -f examples/dynamic-dividing-scheduling/
You can check aggregated status of feeds/resources running in each child clusters.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.