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 Allow but 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

  1. Top level targetRef selects data plane proxies that have app: payments label. MeshTrafficPermission allow-orders will be configured on these proxies.

     targetRef: # 1
       kind: Dataplane
       labels:
         app: payments
    
  2. TargetRef inside the from array selects proxies that implement order service. These proxies will be subjected to the action from default.action.

     - targetRef: # 2
         kind: MeshSubset
         tags: 
           kuma.io/service: orders
    
  3. The action is Allow. All requests from service orders will be allowed on service payments.

     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

  1. Since top level targetRef is empty it selects all proxies in the mesh.
  2. TargetRef inside the from array selects all clients.

     - targetRef: # 2
         kind: Mesh
    
  3. The action is Deny. All requests from all services will be denied on all proxies in the default mesh.

     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

  1. Since top level targetRef is empty it selects all proxies in the mesh.
  2. targetRef inside the element of the from array selects all clients within the mesh.

     - targetRef: # 2
         kind: Mesh
    
  3. The action is Allow. All requests from all services will be allow on all proxies in the default mesh.

     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

  1. Since top level targetRef is empty it selects all proxies in the mesh.
  2. TargetRef inside the from array selects proxies that have label kuma.io/zone: us-east. These proxies will be subjected to the action from default.action.

     - targetRef: # 2
         kind: MeshSubset
         tags:
           kuma.io/zone: us-east
    
  3. The action is Allow. All requests from the zone us-east will be allowed on all proxies.

     default: # 3
       action: Allow
    
  4. TargetRef inside the from array selects proxies that have tags kuma.io/zone: us-east. These proxies will be subjected to the action from default.action.

     - targetRef: # 4
         kind: MeshSubset
         tags:
           env: dev
    
  5. The action is Deny. All requests from the env dev will 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.

See also

All policy options

targetRef object
TargetRef is a reference to the resource the policy takes an effect on. The resource could be either...
kind enum required
Kind of the referenced resource
Values: Mesh | MeshSubset | MeshGateway | MeshService | MeshExternalService | MeshMultiZoneService | MeshServiceSubset | MeshHTTPRoute | Dataplane
name string
Name of the referenced resource. Can only be used with kinds: `MeshService`, `MeshServiceSubset` and...
namespace string
Namespace specifies the namespace of target resource. If empty only resources in policy namespace wi...
labels object
Labels are used to select group of MeshServices that match labels. Either Labels or Name and Namespa...
sectionName string
SectionName is used to target specific section of resource. For example, you can target port from Me...
mesh string
Mesh is reserved for future use to identify cross mesh resources.
proxyTypes array
ProxyTypes specifies the data plane types that are subject to the policy. When not specified, all da...
tags object
Tags used to select a subset of proxies by tags. Can only be used with kinds `MeshSubset` and `MeshS...
rules array
Rules defines inbound permissions configuration
Allow definees a list of matches for which access will be allowed
SpiffeID defines a matcher configuration for SpiffeID matching
type enum required
Type defines how to match incoming traffic by SpiffeID. `Exact` or `Prefix` are allowed.
Values: Exact | Prefix
value string required
Value is SpiffeId of a client that needs to match for the configuration to be applied
AllowWithShadowDeny defines a list of matches for which access will be allowed but emits logs as if ...
SpiffeID defines a matcher configuration for SpiffeID matching
type enum required
Type defines how to match incoming traffic by SpiffeID. `Exact` or `Prefix` are allowed.
Values: Exact | Prefix
value string required
Value is SpiffeId of a client that needs to match for the configuration to be applied
Deny defines a list of matches for which access will be denied
SpiffeID defines a matcher configuration for SpiffeID matching
type enum required
Type defines how to match incoming traffic by SpiffeID. `Exact` or `Prefix` are allowed.
Values: Exact | Prefix
value string required
Value is SpiffeId of a client that needs to match for the configuration to be applied
from array
From list makes a match between clients and corresponding configurations
TargetRef is a reference to the resource that represents a group of clients.
kind enum required
Kind of the referenced resource
Values: Mesh | MeshSubset | MeshGateway | MeshService | MeshExternalService | MeshMultiZoneService | MeshServiceSubset | MeshHTTPRoute | Dataplane
name string
Name of the referenced resource. Can only be used with kinds: `MeshService`, `MeshServiceSubset` and...
namespace string
Namespace specifies the namespace of target resource. If empty only resources in policy namespace wi...
labels object
Labels are used to select group of MeshServices that match labels. Either Labels or Name and Namespa...
sectionName string
SectionName is used to target specific section of resource. For example, you can target port from Me...
mesh string
Mesh is reserved for future use to identify cross mesh resources.
proxyTypes array
ProxyTypes specifies the data plane types that are subject to the policy. When not specified, all da...
tags object
Tags used to select a subset of proxies by tags. Can only be used with kinds `MeshSubset` and `MeshS...
Default is a configuration specific to the group of clients referenced in 'targetRef'
action enum
Action defines a behavior for the specified group of clients:
Values: Allow | Deny | AllowWithShadowDeny