A MeshService names one destination, so a policy can address it in spec.to[].targetRef.
The zone control plane generates a MeshService for each Kubernetes Service.
For how the control plane generates them, see MeshService sources.
The team that owns check-in-api wants every caller to retry failed requests to it.
A policy in the destination’s namespace becomes a producer policy when each to[] entry selects a local MeshService by kuma.io/display-name, k8s.kuma.io/namespace, and kuma.io/zone.
A producer policy reaches every caller of that destination, in any namespace.
-
Create a MeshRetry in kong-air-production that retries requests to check-in-api that fail with a 5xx status:
echo 'apiVersion: kuma.io/v1alpha1
kind: MeshRetry
metadata:
name: check-in-api-retry
namespace: kong-air-production
labels:
kuma.io/mesh: kong-air-mesh
spec:
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: check-in-api
k8s.kuma.io/namespace: kong-air-production
kuma.io/zone: zone1
default:
http:
numRetries: 3
perTryTimeout: 2s
retryOn:
- 5xx' | kubectl apply -f -
-
Check that the control plane gave the policy the producer role:
kubectl get meshretry check-in-api-retry -n kong-air-production \
-o jsonpath='{.metadata.labels.kuma\.io/policy-role}{"\n"}'
-
Get the name of the policy on the global control plane.
When the zone syncs a policy to the global control plane, the global control plane adds a hash suffix to its name:
export RETRY_NAME=$(kongctl get mesh meshretries --mesh kong-air-mesh -o json \
--control-plane-id "$CONTROL_PLANE_ID" --region "$KONNECT_REGION" \
--pat "$KONNECT_TOKEN" -r \
--jq '.items[] | select(.name | startswith("check-in-api-retry")) | .name')
-
Inspect the policy to see which proxies it reaches:
kongctl inspect mesh meshretry "$RETRY_NAME" \
--control-plane-id "$CONTROL_PLANE_ID" --region "$KONNECT_REGION" \
--pat "$KONNECT_TOKEN" --mesh kong-air-mesh
The policy reaches every proxy that can call check-in-api, including the zone ingress and zone egress of kong-air-mesh.
On each of these proxies, the retries apply only to requests sent to check-in-api:
MESH NAME
kong-air-mesh check-in-api-7c4756644b-gncds-55274dvzw…
kong-air-mesh flight-control-75c96dd768-j4mr6-f52w6v4…
kong-air-mesh kong-mesh-kong-air-mesh-egress-7c599494…
kong-air-mesh kong-mesh-kong-air-mesh-ingress-67bdc77…
kong-air-mesh passenger-portal-7f5f54d874-mfqvn-czw47…
kong-air-mesh passenger-portal-v2-7fbf8f8655-wzklr-42…