Multi-cluster scaling with DistributedScaledObject (ConfigMap trigger)
This guide shows how to scale one workload across multiple member clusters using DistributedScaledObject (DSO) with a kubernetes-resource trigger reading a ConfigMap value.
Prerequisites
Section titled “Prerequisites”- Kedify Agent is installed in your KEDA cluster.
- Multi-cluster member clusters are already registered in
kedify-agent-multicluster-kubeconfigs. DistributedScaledObjectcontroller is enabled in Kedify Agent.kubectlinstalled and access to:- KEDA cluster context
- each member cluster context
Enable DSO controller if needed:
kubectl -n keda set env deploy/kedify-agent DSO_ENABLED="true"Architecture used in this guide
Section titled “Architecture used in this guide”- KEDA cluster runs Kedify Agent and the
DistributedScaledObjectresource. - Member clusters run identical
Deploymentworkloads. - Trigger source is a ConfigMap in the KEDA cluster.
When ConfigMap key metric-value is higher than target value 5, DSO increases desired replicas and distributes them across member clusters by weights.
Step 1: Deploy the same workload to member clusters
Section titled “Step 1: Deploy the same workload to member clusters”Apply this manifest to each member cluster in the same namespace (default in this example):
apiVersion: apps/v1kind: Deploymentmetadata: name: dso-demo-app namespace: defaultspec: replicas: 0 selector: matchLabels: app: dso-demo-app template: metadata: labels: app: dso-demo-app spec: containers: - name: app image: nginx:1.27 ports: - containerPort: 80Example apply commands:
kubectl --context member-1 apply -f dso-demo-app.yamlkubectl --context member-2 apply -f dso-demo-app.yamlStep 2: Create trigger ConfigMap in the KEDA cluster
Section titled “Step 2: Create trigger ConfigMap in the KEDA cluster”Create ConfigMap in the KEDA cluster (same namespace where you will create DSO):
apiVersion: v1kind: ConfigMapmetadata: name: dso-mock-metric namespace: defaultdata: metric-value: "0"kubectl --context keda-cluster apply -f dso-mock-metric.yamlStep 3: Create DistributedScaledObject
Section titled “Step 3: Create DistributedScaledObject”Apply this DistributedScaledObject in the KEDA cluster:
apiVersion: keda.kedify.io/v1alpha1kind: DistributedScaledObjectmetadata: name: dso-demo namespace: defaultspec: memberClusters: - name: member-1 weight: 4 - name: member-2 weight: 6 scaledObjectSpec: scaleTargetRef: kind: Deployment name: dso-demo-app minReplicaCount: 0 maxReplicaCount: 10 triggers: - type: kubernetes-resource metadata: resourceKind: ConfigMap resourceName: dso-mock-metric key: metric-value targetValue: "5"kubectl --context keda-cluster apply -f distributedscaledobject.yamlStep 4: Trigger scaling
Section titled “Step 4: Trigger scaling”Increase the metric value above the target:
kubectl --context keda-cluster -n default patch configmap dso-mock-metric \ --type merge \ -p '{"data":{"metric-value":"20"}}'Set it back below target to scale down:
kubectl --context keda-cluster -n default patch configmap dso-mock-metric \ --type merge \ -p '{"data":{"metric-value":"0"}}'Step 5: Verify distribution and status
Section titled “Step 5: Verify distribution and status”Check DSO status in KEDA cluster:
kubectl --context keda-cluster -n default get distributedscaledobject dso-demo -o yamlCheck replicas in each member cluster:
kubectl --context member-1 -n default get deploy dso-demo-appkubectl --context member-2 -n default get deploy dso-demo-appYou should observe replica distribution following weights (member-1:4, member-2:6) within rounding limits.
Troubleshooting
Section titled “Troubleshooting”- DSO does not scale:
- Verify
DSO_ENABLED="true"onkedify-agent. - Verify member cluster names in
spec.memberClustersexactly match registered member names. - Verify
Deploymentname and namespace are identical across member clusters.
- Verify
- Trigger not firing:
- Verify ConfigMap exists in the same namespace as DSO.
- Verify
metric-valueis numeric and abovetargetValue.
- Member cluster stays at 0 replicas:
- Check DSO status field
memberClusterStatusesfor connectivity or auth issues.
- Check DSO status field