Careful!
You are browsing documentation for the next version of Kuma. Use this version at your own risk.
MeshTrafficPermission
A renewed version of MeshTrafficPermission is available with the SPIFFE-based matches.
It is currently experimental and requires MeshIdentity to be enabled.
See MeshTrafficPermission (experimental) for more details.
This policy uses new policy matching algorithm. Do not combine with TrafficPermission.
Mutual TLS has to be enabled to make MeshTrafficPermission work.
The MeshTrafficPermission policy provides access control within the Mesh.
It allows you to define granular rules about which services can communicate with each other.
TargetRef support matrix
| targetRef | Allowed kinds | 
|---|---|
| targetRef.kind | Mesh,Dataplane,MeshSubset(deprecated) | 
| from[].targetRef.kind | Mesh,MeshSubset,MeshServiceSubset | 
If you don’t understand this table you should read matching docs.
MeshTrafficPermission is not currently supported for MeshExternalService.
Configuration
Action
Kuma allows configuring one of 3 actions for a group of service’s clients:
- Allow- allows incoming requests matching the from- targetRef.
- Deny- denies incoming requests matching the from- targetRef
- AllowWithShadowDeny- same as- Allowbut will log as if request is denied, this is useful for rolling new restrictive policies without breaking things.
Examples
Service ‘payments’ allows requests from ‘orders’
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
  name: allow-orders
  namespace: kuma-demo
  labels:
    kuma.io/mesh: default
spec:
  targetRef:
    kind: Dataplane
    labels:
      app: payments
  from:
  - targetRef:
      kind: MeshSubset
      tags:
        kuma.io/service: orders
    default:
      action: Allow
Explanation
- 
    Top level targetRefselects data plane proxies that haveapp: paymentslabel. MeshTrafficPermissionallow-orderswill be configured on these proxies.targetRef: # 1 kind: Dataplane labels: app: payments
- 
    TargetRefinside thefromarray selects proxies that implementorderservice. These proxies will be subjected to the action fromdefault.action.- targetRef: # 2 kind: MeshSubset tags: kuma.io/service: orders
- 
    The action is Allow. All requests from serviceorderswill be allowed on servicepayments.default: # 3 action: Allow
Deny all
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
  name: deny-all
  namespace: kuma-demo
  labels:
    kuma.io/mesh: default
spec:
  from:
  - targetRef:
      kind: Mesh
    default:
      action: Deny
Explanation
- Since top level targetRefis empty it selects all proxies in the mesh.
- 
    TargetRefinside thefromarray selects all clients.- targetRef: # 2 kind: Mesh
- 
    The action is Deny. All requests from all services will be denied on all proxies in thedefaultmesh.default: # 3 action: Deny
Allow all
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
  name: allow-all
  namespace: kuma-demo
  labels:
    kuma.io/mesh: default
spec:
  from:
  - targetRef:
      kind: Mesh
    default:
      action: Allow
Explanation
- Since top level targetRefis empty it selects all proxies in the mesh.
- 
    targetRefinside the element of thefromarray selects all clients within the mesh.- targetRef: # 2 kind: Mesh
- 
    The action is Allow. All requests from all services will be allow on all proxies in thedefaultmesh.default: # 3 action: Allow
Allow requests from zone ‘us-east’, deny requests from ‘dev’ environment
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
  name: example-with-tags
  namespace: kuma-demo
  labels:
    kuma.io/mesh: default
spec:
  from:
  - targetRef:
      kind: MeshSubset
      tags:
        kuma.io/zone: us-east
    default:
      action: Allow
  - targetRef:
      kind: MeshSubset
      tags:
        env: dev
    default:
      action: Deny
Explanation
- Since top level targetRefis empty it selects all proxies in the mesh.
- 
    TargetRefinside thefromarray selects proxies that have labelkuma.io/zone: us-east. These proxies will be subjected to the action fromdefault.action.- targetRef: # 2 kind: MeshSubset tags: kuma.io/zone: us-east
- 
    The action is Allow. All requests from the zoneus-eastwill be allowed on all proxies.default: # 3 action: Allow
- 
    TargetRefinside thefromarray selects proxies that have tagskuma.io/zone: us-east. These proxies will be subjected to the action fromdefault.action.- targetRef: # 4 kind: MeshSubset tags: env: dev
- 
    The action is Deny. All requests from the envdevwill be denied on all proxies.default: # 5 action: Deny
Order of rules inside the from array matters. 
Request from the proxy that has both kuma.io/zone: east and env: dev will be denied. 
This is because the rule with Deny is later in the from array than any Allow rules.