The following sections describe how to configure other resources to target a MeshService.
You can use a MeshService resource as the destination target of a policy by setting to[].targetRef:
spec:
to:
- targetRef:
kind: MeshService
name: test-server
namespace: test-app
sectionName: main
With this configuration, the policy targets requests to the given MeshService and port with the name main.
Only Kubernetes zones can reference using namespace, which always selects resources in the local zone.
In order to direct traffic to a given MeshService, you must reference it with backendRefs:
spec:
targetRef:
kind: Mesh
to:
- targetRef:
kind: MeshService
name: test-server
namespace: test-app
rules:
- matches:
- path:
type: PathPrefix
value: /v2
default:
backendRefs:
- kind: MeshService
name: test-server-v2
namespace: test-app
port: 80
In backendRefs, ports can be optionally referred to by their number.
Instead of referencing a MeshService by name, you can use labels.
This is useful if you want to select a MeshService from other zones, or select multiple MeshService resources.
With backendRefs, only one resource can be selected.
Here’s a configuration example that can be used under targetRef or backendRefs:
- kind: MeshService
labels:
kuma.io/display-name: test-server-v2
k8s.kuma.io/namespace: test-app
kuma.io/zone: east
In this case, the entry selects resources with the display name test-server-v2 from the east zone in the test-app namespace.
Only one resource will be selected.
However, if you leave out the namespace, any resource named test-server-v2 in the east zone is selected, regardless of its namespace:
- kind: MeshService
labels:
kuma.io/display-name: test-server-v2
kuma.io/zone: east