Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(meshservice): modify targetref #1909

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/_src/guides/federate.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ You should eventually see

We can check policy synchronization from global control plane to zone control plane by applying a policy on global control plane:

{% if_version lte:2.8.x %}
```
echo "apiVersion: kuma.io/v1alpha1
kind: MeshCircuitBreaker
Expand All @@ -137,6 +138,33 @@ spec:
maxRetries: 2
maxRequests: 2" | kubectl --context=kind-mesh-global apply -f -
```
{% endif_version %}
{% if_version gte:2.9.x %}
```
echo "apiVersion: kuma.io/v1alpha1
kind: MeshCircuitBreaker
metadata:
name: demo-app-to-redis
namespace: {{site.mesh_namespace}}
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: MeshService
name: demo-app
namespace: kuma-demo
to:
- targetRef:
kind: MeshService
name: redis_kuma-demo_svc_6379
default:
connectionLimits:
maxConnections: 2
maxPendingRequests: 8
maxRetries: 2
maxRequests: 2" | kubectl --context=kind-mesh-global apply -f -
```
{% endif_version %}

If we execute the following command:
```sh
Expand Down
65 changes: 64 additions & 1 deletion app/_src/policies/targetref.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,17 @@ targetRef:
```
{% endif_version %}

Here's an explanation of each kinds and their scope:
Here's an explanation of each kind and their scope:

- Mesh: applies to all proxies running in the mesh
- MeshSubset: same as Mesh but filters only proxies who have matching `targetRef.tags`
{% if_version lte:2.8.x %}
- MeshService: all proxies with a tag `kuma.io/service` equal to `targetRef.name`
{% endif_version %}
{% if_version gte:2.9.x %}
- MeshService: all proxies with a tag `kuma.io/service` equal to `targetRef.name` (deprecated) or
- MeshService: all proxies matching `name` and `namespace` (only on kubernetes) or specified `labels`
{% endif_version %}
- MeshServiceSubset: same as `MeshService` but further refine to proxies that have matching `targetRef.tags`
- MeshGateway: targets proxies matched by the named MeshGateway
- Note that it's very strongly recommended to target MeshGateway proxies using this
Expand All @@ -166,6 +172,41 @@ In {{site.mesh_product_name}} 2.6.x, the `targetRef` field gained the ability to

Consider the example below:

{% if_version lte:2.8.x %}
```yaml
apiVersion: kuma.io/v1alpha1
kind: MeshAccessLog
metadata:
name: example
namespace: {{ site.mesh_namespace }}
labels:
kuma.io/mesh: default
spec:
targetRef: # top level targetRef
kind: MeshService
name: web-frontend
to:
- targetRef: # to level targetRef
kind: MeshService
name: web-backend
default:
backends:
- file:
format:
plain: '{"start_time": "%START_TIME%"}'
path: "/tmp/logs.txt"
from:
- targetRef: # from level targetRef
kind: Mesh
default:
backends:
- file:
format:
plain: '{"start_time": "%START_TIME%"}'
path: "/tmp/logs.txt"
```
{% endif_version %}
{% if_version gte:2.9.x %}
```yaml
apiVersion: kuma.io/v1alpha1
kind: MeshAccessLog
Expand All @@ -178,10 +219,12 @@ spec:
targetRef: # top level targetRef
kind: MeshService
name: web-frontend
namespace: web
to:
- targetRef: # to level targetRef
kind: MeshService
name: web-backend
namespace: web
default:
backends:
- file:
Expand All @@ -198,6 +241,7 @@ spec:
plain: '{"start_time": "%START_TIME%"}'
path: "/tmp/logs.txt"
```
{% endif_version %}

Using `spec.targetRef`, this policy targets all proxies that implement the service `web-frontend`.
It defines the scope of this policy as applying to traffic either from or to `web-frontend` services.
Expand Down Expand Up @@ -340,6 +384,23 @@ All traffic from any proxy (top level `targetRef`) going to any proxy (to `targe

#### Recommending to users

{% if_version lte:2.8.x %}
```yaml
type: ExamplePolicy
name: example
mesh: default
spec:
targetRef:
kind: Mesh
to:
- targetRef:
kind: MeshService
name: my-service
default:
key: value
```
{% endif_version %}
{% if_version gte:2.9.x %}
```yaml
type: ExamplePolicy
name: example
Expand All @@ -351,9 +412,11 @@ spec:
- targetRef:
kind: MeshService
name: my-service
namespace: demo
default:
key: value
```
{% endif_version %}

All traffic from any proxy (top level `targetRef`) going to the service "my-service" (to `targetRef`) will have this policy applied with value `key=value`.

Expand Down
Loading