Navigation Menu

Skip to content

Commit

Permalink
add docs on dynamic scheduling and status aggregation (#26)
Browse files Browse the repository at this point in the history
Signed-off-by: Di Xu <stephenhsu90@gmail.com>
  • Loading branch information
dixudx committed Jul 14, 2022
1 parent a45b15e commit 588d770
Show file tree
Hide file tree
Showing 11 changed files with 458 additions and 55 deletions.
92 changes: 92 additions & 0 deletions content/en/docs/tutorials/multi-cluster-apps/aggregated-status.md
@@ -0,0 +1,92 @@
---
title: "Checking Aggregated Status"
description: "Aggregating resource status from child clusters"
date: 2022-07-13
draft: false
weight: 8
---

In Clusternet, you can check the aggregated status of all deployed resources by visiting the status of Subscription. For
every feed/resource, you can check the detailed status (field `feedStatusDetails`) per cluster and the summarized
status (field `feedStatusSummary`) of all clusters in `status.aggregatedStatuses`.

```yaml
status:
aggregatedStatuses:
- apiVersion: v1
feedStatusDetails:
- available: true
clusterId: 851a623b-a38c-42ec-95b5-dbea9ed27116
clusterName: clusternet-cluster-bb2xp
replicaStatus: { }
- available: true
clusterId: 58602f69-8664-43f5-bbf2-0b20af76b0bc
clusterName: clusternet-cluster-skxd4
replicaStatus: { }
feedStatusSummary:
available: true
replicaStatus: { }
kind: Namespace
name: qux
- apiVersion: v1
feedStatusDetails:
- available: true
clusterId: 851a623b-a38c-42ec-95b5-dbea9ed27116
clusterName: clusternet-cluster-bb2xp
replicaStatus: { }
- available: true
clusterId: 58602f69-8664-43f5-bbf2-0b20af76b0bc
clusterName: clusternet-cluster-skxd4
replicaStatus: { }
feedStatusSummary:
available: true
replicaStatus: { }
kind: Service
name: my-nginx-svc
namespace: qux
- apiVersion: apps/v1
feedStatusDetails:
- available: true
clusterId: 851a623b-a38c-42ec-95b5-dbea9ed27116
clusterName: clusternet-cluster-bb2xp
replicaStatus:
availableReplicas: 1
observedGeneration: 9
readyReplicas: 1
replicas: 1
updatedReplicas: 1
- available: true
clusterId: 58602f69-8664-43f5-bbf2-0b20af76b0bc
clusterName: clusternet-cluster-skxd4
replicaStatus:
availableReplicas: 2
observedGeneration: 5
readyReplicas: 2
replicas: 2
updatedReplicas: 2
feedStatusSummary:
available: true
replicaStatus:
availableReplicas: 3
observedGeneration: 9
readyReplicas: 3
replicas: 3
updatedReplicas: 3
kind: Deployment
name: my-nginx
namespace: qux
bindingClusters:
- clusternet-v7wzq/clusternet-cluster-bb2xp
- clusternet-wlf5b/clusternet-cluster-skxd4
desiredReleases: 2
replicas:
apps/v1/Deployment/qux/my-nginx:
- 1
- 2
v1/Namespace/qux: [ ]
v1/Service/qux/my-nginx-svc: [ ]
specHash: 3893382778
```

From above example, we can see Deployment `qux/my-nginx` with total 3 replicas has been deployed to 2 clusters.
From `feedStatusSummary`, we can see total 3 replicas are available and running healthy.
@@ -0,0 +1,96 @@
---
title: "Deploying Applications to Multiple Clusters with Dynamic Scheduling"
description: "Scheduling applications of multiple replicas to several clusters by cluster capacity"
date: 2022-07-13
draft: false
weight: 3
---

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.

## Defining Your Applications

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.

```yaml
# 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
```

The `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-01` can run 3 replicas of Deployment `qux/my-nginx`
- `cluster-02` can run 6 replicas of Deployment `qux/my-nginx`
- `cluster-03` can run 9 replicas of Deployment `qux/my-nginx`

`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 `dynamic-dividing-scheduling-demo`.

```yaml
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](/docs/tutorials/multi-cluster-apps/setting-overrides/).

## Applying Your Applications

After installing kubectl plugin [kubectl-clusternet](/docs/kubectl-clusternet/), you could run commands below to
distribute this application to child clusters.

```bash
$ 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](docs/tutorials/multi-cluster-apps/aggregated-status/) of feeds/resources running in
each child clusters.
Expand Up @@ -2,7 +2,7 @@
title: "Deploying Applications to Multiple Clusters with Replication Scheduling"
date: 2022-04-11
draft: false
weight: 3
weight: 1
description: "Scheduling applications to multiple clusters"
---

Expand All @@ -17,7 +17,7 @@ First, let's see an example application. Below `Subscription` "app-demo" defines
distributed to, and the resources to be deployed with.

```yaml
# examples/applications/subscription.yaml
# examples/replication-scheduling/subscription.yaml
apiVersion: apps.clusternet.io/v1alpha1
kind: Subscription
metadata:
Expand Down Expand Up @@ -47,7 +47,7 @@ spec:
```

Before applying this `Subscription`, please
modify [examples/applications/subscription.yaml](https://github.com/clusternet/clusternet/blob/main/examples/applications/subscription.yaml)
modify [examples/replication-scheduling/subscription.yaml](https://github.com/clusternet/clusternet/blob/main/examples/replication-scheduling/subscription.yaml)
with your clusterID.

{{% alert title="Note" color="primary" %}}
Expand All @@ -56,11 +56,11 @@ If you want to install a helm chart from a private helm repository, please set a
{{% /alert %}}

Clusternet also supports using [OCI-based registries](https://helm.sh/docs/topics/registries/) for Helm charts. Please
refer [this oci-based helm chart](../../examples/oci/oci-chart-mysql.yaml).
refer [this oci-based helm chart](https://github.com/clusternet/clusternet/blob/main/examples/oci/oci-chart-mysql.yaml).

If you want to apply overrides per cluster, please follow [How to Set Overrides in Clusternet](setting-overrides.md).
Before applying these Localization(s), please
modify [examples/applications/localization.yaml](https://github.com/clusternet/clusternet/blob/main/examples/applications/localization.yaml)
modify [examples/replication-scheduling/localization.yaml](https://github.com/clusternet/clusternet/blob/main/examples/replication-scheduling/localization.yaml)
with your `ManagedCluster` namespace, such as `clusternet-5l82l`.

## Applying Your Applications
Expand All @@ -69,17 +69,20 @@ After installing kubectl plugin [kubectl-clusternet](https://github.com/clustern
below commands to distribute this application to child clusters.

```bash
$ kubectl clusternet apply -f examples/applications/
$ kubectl clusternet apply -f examples/replication-scheduling/
helmchart.apps.clusternet.io/mysql created
namespace/foo created
deployment.apps/my-nginx created
service/my-nginx-svc created
subscription.apps.clusternet.io/app-demo created
$ # or
$ # kubectl-clusternet apply -f examples/applications/
$ # kubectl-clusternet apply -f examples/replication-scheduling/
```

## Checking Status
You can [check aggregated status](docs/tutorials/multi-cluster-apps/aggregated-status/) of feeds/resources running in
each child clusters.

## Checking Subscription Status

Then you can view the resources just created,

Expand Down
Expand Up @@ -24,7 +24,7 @@ Meanwhile, below override policies are supported,

Here you can refer below samples to learn more,

- [Localization Sample](https://github.com/clusternet/clusternet/blob/main/examples/applications/localization.yaml)
- [Globalization Sample](https://github.com/clusternet/clusternet/blob/main/examples/applications/globalization.yaml)
- [Localization Sample](https://github.com/clusternet/clusternet/blob/main/examples/replication-scheduling/localization.yaml)
- [Globalization Sample](https://github.com/clusternet/clusternet/blob/main/examples/replication-scheduling/globalization.yaml)

Please remember to modify the namespace to your `ManagedCluster` namespace, such as `clusternet-5l82l`.
Expand Up @@ -3,7 +3,7 @@ title: "Deploying Applications to Multiple Clusters with Static Weight Schedulin
description: "Scheduling applications of multiple replicas to several clusters by static cluster weight"
date: 2022-04-11
draft: false
weight: 4
weight: 2
---

This tutorial will walk you through how to deploy applications to multiple clusters with static weight scheduling. It is
Expand Down Expand Up @@ -54,6 +54,21 @@ spec:
The `Deployment` bar/my-nginx above will run in two clusters with a total of 6 replicas, while 2 replicas run in cluster
with ID `dc91021d-2361-4f6d-a404-7c33b9e01118`, 4 replicas in cluster with ID `5f9da921-0437-4fea-a89d-42aa1ede9b25`.

You can get the scheduling result by checking the status of Subscription `static-dividing-scheduling-demo`.

```yaml
bindingClusters:
- clusternet-v7wzq/clusternet-cluster-bb2xp
- clusternet-wlf5b/clusternet-cluster-skxd4
desiredReleases: 6
replicas:
apps/v1/Deployment/qux/my-nginx:
- 2
- 4
v1/Namespace/qux: []
v1/Service/qux/my-nginx-svc: []
```

Before applying this `Subscription`, please
modify [examples/static-dividing-scheduling/subscription.yaml](https://github.com/clusternet/clusternet/blob/main/examples/static-dividing-scheduling/subscription.yaml)
with your clusterID.
Expand All @@ -74,3 +89,6 @@ subscription.apps.clusternet.io/static-dividing-scheduling-demo created
$ # or
$ # kubectl-clusternet apply -f examples/static-dividing-scheduling/
```

You can [check aggregated status](docs/tutorials/multi-cluster-apps/aggregated-status/) of feeds/resources running in
each child clusters.
4 changes: 2 additions & 2 deletions content/zh-cn/docs/tutorials/multi-cluster-apps/_index.md
@@ -1,7 +1,7 @@
---
title: "Multi-Cluster Applications"
title: "多集群应用分发"
weight: 2
description: "Deploying applications to multiple clusters with various scheduling strategies"
description: "通过多种调度策略将应用分发到多集群中"
---

Clusternet支持通过一组API将应用程序从托管集群部署到多个集群。
Expand Down

0 comments on commit 588d770

Please sign in to comment.