Skill: gen-relationship
Generate schema-backed relationship definitions for Meshery models between given components. This skill ensures that relationships are mathematically accurate, logically sound, and strictly compliant with the canonical v1beta1 relationship schema.
Usage
Invoke this skill when you need to define a new relationship between two or more components:
/gen-relationship Define a reference relationship between a Deployment and a PersistentVolumeClaim in the kubernetes model./gen-relationship Create a hierarchical parent-inventory relationship between a ServiceMesh and its ControlPlane.
Instructions
- Identify the Components: Determine the source (
from) and target (to) components. Note theirkindand themodelthey belong to. - Determine the Relationship Type: Select the appropriate
kind,type, andsubTypebased on the desired interaction. - Formulate Selectors: Construct the
selectorsarray withallow(and optionallydeny) blocks. - Define Patches: If the relationship involves data flow or configuration binding, define
mutatorRefandmutatedRefas nested arrays of strings. - Assign Metadata: Include UI capabilities and styles to ensure the relationship is rendered correctly in MeshMap.
- Validate against Schema: Ensure the output matches the
v1beta1schema structure rigorously.
Technical Context
Relationship Terminologies
- Kind:
hierarchical: For parent-child or ownership interactions.edge: For peer-to-peer or connective interactions.sibling: For components that occupy the same logical level or group.
- Type:
Parent: Defines a strong hierarchical bond where the child belongs to the parent (child is usually discovered within the parent's inventory).Binding: Defines a functional connection between components.non-binding: Defines a logical or informational connection without functional enforcement.
- SubType:
inventory: Hierarchical mapping of resources (e.g., used inParenttype).reference: Binding based on a property reference (e.g., a Deployment referencing a ConfigMap).network: Connectivity mapping (L3/L4/L7 interactions).permission: Authorization or access control mapping.wallet: Cloud billing or cost mapping.
Canonical Schema (v1beta1)
- schemaVersion:
relationships.meshery.io/v1beta1 - Selectors:
allow: Containsfromandtoarrays of component selectors.deny: (Optional) Excludes specific components from the relationship.
- Selector Item:
kind: The kind of the component (e.g.,Deployment).model: The model name (e.g.,kubernetes).patch: (Optional) Specifies how properties are mapping.
- Path References:
mutatorRef: Source path, formatted as[["path", "to", "field"]].mutatedRef: Target path, formatted as[["path", "to", "field"]].- CRITICAL: Both must be nested arrays of strings (e.g.,
[["settings", "name"]]) to pass upstream evaluation.
- UI Metadata:
metadata.capabilities.designer.edit: Must betruefor a relationship to be editable in MeshMap.description: A clear, human-readable description of the relationship's purpose.
Examples
1. Peer-to-Peer Reference (Edge)
Reasoning: The Deployment is the originator of the reference, containing the field that must match the source PVC. The PVC provides its identity (mutator) to the Deployment's volume configuration (mutated).
{
"schemaVersion": "relationships.meshery.io/v1beta1",
"kind": "edge",
"type": "non-binding",
"subType": "reference",
"metadata": {
"description": "Deployment referencing a PVC via claimName",
"capabilities": {
"designer": { "edit": true }
}
},
"selectors": [
{
"allow": {
"from": [
{
"kind": "Deployment",
"model": "kubernetes",
"patch": {
"mutatedRef": [["configuration", "spec", "template", "spec", "volumes", "0", "persistentVolumeClaim", "claimName"]]
}
}
],
"to": [
{
"kind": "PersistentVolumeClaim",
"model": "kubernetes",
"patch": {
"mutatorRef": [["configuration", "metadata", "name"]]
}
}
]
}
}
]
}
2. Hierarchical Inventory (Parent)
Reasoning: The Namespace is the authoritative parent defining the logical scope. It provides its name (mutator) to be injected into the namespace field of all child components (mutated).
{
"schemaVersion": "relationships.meshery.io/v1beta1",
"kind": "hierarchical",
"type": "parent",
"subType": "inventory",
"metadata": {
"description": "Namespace-level resource containment",
"capabilities": {
"designer": { "edit": true }
}
},
"selectors": [
{
"allow": {
"from": [
{
"kind": "Namespace",
"model": "kubernetes",
"patch": {
"mutatorRef": [["configuration", "metadata", "name"]]
}
}
],
"to": [
{
"kind": "*",
"model": "kubernetes",
"patch": {
"mutatedRef": [["configuration", "metadata", "namespace"]]
}
}
]
}
}
]
}
3. Network Connectivity (Edge)
Reasoning: The Service is the originator of the network connection, defining selection criteria. It provides its selector labels (mutator) to match or be mirrored by the Deployment's pod labels (mutated).
{
"schemaVersion": "relationships.meshery.io/v1beta1",
"kind": "edge",
"type": "binding",
"subType": "network",
"metadata": {
"description": "Service targeting deployment pods",
"capabilities": {
"designer": { "edit": true }
}
},
"selectors": [
{
"allow": {
"from": [
{
"kind": "Service",
"model": "kubernetes",
"patch": {
"mutatorRef": [["configuration", "spec", "selector"]]
}
}
],
"to": [
{
"kind": "Deployment",
"model": "kubernetes",
"patch": {
"mutatedRef": [["configuration", "spec", "template", "metadata", "labels"]]
}
}
]
}
}
]
}
Guidelines
- Source of Truth: Always prioritize
v1beta1schema rules frommeshery/schemas. Do not copy existingv1beta2or older files blindly as they may contain legacy non-compliant structures. - Strict Pathing: Ensure that the
mutatorRefandmutatedRefpaths correspond to the actual JSON schema of the components being linked. - Logical Consistency: Match
Kinds,Types, andsubTypesthat corresponds logically to the components being linked (e.g.inventoryforParent,networkforServiceconnections). - No Guessing: If component schemas are unavailable, use
grep_searchto find component definitions inserver/meshmodelto verify valid paths forpatchoperations.
Source: meshery/meshery — distributed by TomeVault.