Route to the local zone instances equally
In this example, when a user sends a request to the backend service, the request is routed equally to all instances in the local zone. If there are no instances in the local zone, the request will fail because there is no cross zone traffic.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshLoadBalancingStrategy
metadata:
name: local-zone-affinity-backend
namespace: kuma-demo
labels:
kuma.io/mesh: default
spec:
to:
- targetRef:
kind: MeshService
name: backend_kuma-demo_svc_8080
default:
localityAwareness:
localZone: {}Copied!
apiVersion: kuma.io/v1alpha1
kind: MeshLoadBalancingStrategy
metadata:
name: local-zone-affinity-backend
namespace: kuma-demo
labels:
kuma.io/mesh: default
spec:
to:
- targetRef:
kind: MeshService
name: backend
namespace: kuma-demo
sectionName: http
default:
localityAwareness:
localZone: {}Copied!
type: MeshLoadBalancingStrategy
name: local-zone-affinity-backend
mesh: default
spec:
to:
- targetRef:
kind: MeshService
name: backend
default:
localityAwareness:
localZone: {}Copied!
type: MeshLoadBalancingStrategy
name: local-zone-affinity-backend
mesh: default
spec:
to:
- targetRef:
kind: MeshService
name: backend
sectionName: http
default:
localityAwareness:
localZone: {}Copied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_load_balancing_strategy" "local_zone_affinity_backend" {
provider = konnect-beta
type = "MeshLoadBalancingStrategy"
name = "local-zone-affinity-backend"
spec = {
to = [
{
target_ref = {
kind = "MeshService"
name = "backend"
section_name = "http"
}
default = {
locality_awareness = {
local_zone = {
}
}
}
}
]
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}
Copied!