MeshIdentity is a namespaced resource for system namespaces that controls how data plane proxies receive identity certificates.
The following key fields define how identities are issued and applied:
-
selector: Which data plane proxies this identity applies to.
-
spiffeID: How the SPIFFE ID is constructed (trust domain and path).
-
provider: Which system issues the certificates (Bundled or Spire).
The selector field controls which data plane proxies a MeshIdentity applies to.
It uses a Kubernetes-style label selector on data plane proxy tags.
You can scope an identity to all workloads, a subset of workloads, or none at all.
When multiple MeshIdentity resources apply to the same data plane proxy,
the one with the most specific selector (the greatest number of matching labels) takes precedence.
If two policies have selectors with the same number of labels, Kong Mesh compares their names lexicographically.
The policy whose name comes first in alphabetical order takes precedence.
The following table contains examples of the selector field with different scopes:
|
Description
|
Example
|
|
Apply to all data plane proxies
|
spec:
selector:
dataplane:
matchLabels: {}
|
|
Apply to a group of data plane proxies
|
spec:
selector:
dataplane:
matchLabels:
app: my-app
|
|
Apply to nothing
|
|
The spiffeID field lets you override how SPIFFE IDs are constructed for the data plane proxies selected by this MeshIdentity.
By default, Kong Mesh generates a SPIFFE ID based on the mesh and zone.
With spiffeID, you can customize the trustDomain and the path template.
spec:
spiffeID:
trustDomain: "{{ .Mesh }}.{{ .Zone }}.mesh.local"
path: "/ns/{{ .Namespace }}/sa/{{ .ServiceAccount }}"
Supported variables in the trustDomain field are:
Supported variables in the path field are:
.Namespace
.ServiceAccount
You can also use resource labels in both trustDomain and path, for example:
spec:
spiffeID:
trustDomain: '{{ label "kuma.io/mesh" }}.{{ label "kuma.io/zone" }}.mesh.local'
path: '/ns/{{ label "k8s.kuma.io/namespace" }}/sa/{{ label "k8s.kuma.io/service-account" }}'
When using {{ label "kuma.io/workload" }} in the path template, data plane proxies selected by this MeshIdentity must have the kuma.io/workload label. This label can be provided either:
- Via a data plane proxy token generated with the
--workload parameter
- Directly on the data plane proxy resource
Connections from data plane proxies lacking the required label will be rejected.
Here’s an example using a workload label in the path:
spec:
spiffeID:
trustDomain: '{{ .Mesh }}.{{ .Zone }}.mesh.local'
path: '/workload/{{ label "kuma.io/workload" }}'
The provider field defines how identity certificates are issued.
This field is required and must specify one of the supported provider types:
-
Bundled: Certificates are issued by Kong Mesh’s control plane, either autogenerated or supplied by the user.
-
Spire: Certificates are issued directly by a SPIRE Agent through SDS.