Prioritize traffic to data planesin specific order
Requests to backend will be distributed based on weights, with 99.9% of requests routed to data planes in the same data center, 0.099% to data planes in the same region, and the remainder to other local instances.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshLoadBalancingStrategy
metadata:
name: local-zone-affinity-cross-backend
namespace: kuma-demo
labels:
kuma.io/mesh: default
spec:
to:
- targetRef:
kind: MeshMultiZoneService
name: backend
namespace: kuma-demo
sectionName: http
_port: 8080
default:
localityAwareness:
localZone:
affinityTags:
- key: kubernetes.io/hostname
weight: 9000
- key: topology.kubernetes.io/zone
weight: 9
crossZone:
failover:
- from:
zones:
- us-1
- us-2
- us-3
to:
type: Only
zones:
- us-1
- us-2
- us-3
- from:
zones:
- eu-1
- eu-2
- eu-3
to:
type: Only
zones:
- eu-1
- eu-2
- eu-3
- to:
type: Only
zones:
- us-4
apiVersion: kuma.io/v1alpha1
kind: MeshLoadBalancingStrategy
metadata:
name: local-zone-affinity-cross-backend
namespace: kuma-demo
labels:
kuma.io/mesh: default
spec:
to:
- targetRef:
kind: MeshMultiZoneService
name: backend
namespace: kuma-demo
sectionName: http
_port: 8080
default:
localityAwareness:
localZone:
affinityTags:
- key: kubernetes.io/hostname
weight: 9000
- key: topology.kubernetes.io/zone
weight: 9
crossZone:
failover:
- from:
zones:
- us-1
- us-2
- us-3
to:
type: Only
zones:
- us-1
- us-2
- us-3
- from:
zones:
- eu-1
- eu-2
- eu-3
to:
type: Only
zones:
- eu-1
- eu-2
- eu-3
- to:
type: Only
zones:
- us-4
type: MeshLoadBalancingStrategy
name: local-zone-affinity-cross-backend
mesh: default
spec:
to:
- targetRef:
kind: MeshMultiZoneService
name: backend
namespace: kuma-demo
sectionName: http
_port: 8080
default:
localityAwareness:
localZone:
affinityTags:
- key: kubernetes.io/hostname
weight: 9000
- key: topology.kubernetes.io/zone
weight: 9
crossZone:
failover:
- from:
zones:
- us-1
- us-2
- us-3
to:
type: Only
zones:
- us-1
- us-2
- us-3
- from:
zones:
- eu-1
- eu-2
- eu-3
to:
type: Only
zones:
- eu-1
- eu-2
- eu-3
- to:
type: Only
zones:
- us-4
type: MeshLoadBalancingStrategy
name: local-zone-affinity-cross-backend
mesh: default
spec:
to:
- targetRef:
kind: MeshMultiZoneService
name: backend
namespace: kuma-demo
sectionName: http
_port: 8080
default:
localityAwareness:
localZone:
affinityTags:
- key: kubernetes.io/hostname
weight: 9000
- key: topology.kubernetes.io/zone
weight: 9
crossZone:
failover:
- from:
zones:
- us-1
- us-2
- us-3
to:
type: Only
zones:
- us-1
- us-2
- us-3
- from:
zones:
- eu-1
- eu-2
- eu-3
to:
type: Only
zones:
- eu-1
- eu-2
- eu-3
- to:
type: Only
zones:
- us-4
Please 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_cross_backend" {
provider = konnect-beta
type = "MeshLoadBalancingStrategy"
name = "local-zone-affinity-cross-backend"
spec = {
to = [
{
target_ref = {
kind = "MeshMultiZoneService"
name = "backend"
namespace = "kuma-demo"
section_name = "http"
_port = "8080"
}
default = {
locality_awareness = {
local_zone = {
affinity_tags = [
{
key = "kubernetes.io/hostname"
weight = "9000"
},
{
key = "topology.kubernetes.io/zone"
weight = "9"
}
]
}
cross_zone = {
failover = [
{
from = {
zones = [
= "us-1",
= "us-2",
= "us-3"
]
}
to = {
type = "Only"
zones = [
= "us-1",
= "us-2",
= "us-3"
]
}
},
{
from = {
zones = [
= "eu-1",
= "eu-2",
= "eu-3"
]
}
to = {
type = "Only"
zones = [
= "eu-1",
= "eu-2",
= "eu-3"
]
}
},
{
to = {
type = "Only"
zones = [
= "us-4"
]
}
}
]
}
}
}
}
]
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}