AvitalTamir / cyphernetes

A Kubernetes Query Language
https://cyphernet.es
Apache License 2.0
527 stars 12 forks source link

Support custom relationships #139

Closed AvitalTamir closed 3 weeks ago

AvitalTamir commented 3 weeks ago

Allows defining custom relationships between Kubernetes resources in a ~/.cyphernetes/relationships.yaml file. This is useful when working with custom resources or when you want to define relationships that aren't built into Cyphernetes.

Example relationships.yaml:

relationships:
  - kindA: applications.argoproj.io
    kindB: services
    relationship: ARGOAPP_SYNC_SERVICE
    matchCriteria:
      - fieldA: "$.spec.source.targetRevision"
        fieldB: "$.metadata.labels.targetRevision"
        comparisonType: ExactMatch
      - fieldA: "$.spec.project"
        fieldB: "$.metadata.labels.project" 
        comparisonType: ExactMatch

  - kindA: pods
    kindB: deployments
    relationship: DEPLOYMENT_OWN_POD
    matchCriteria:
      - fieldA: "$.metadata.name"
        fieldB: "$.metadata.name"
        comparisonType: StringContains

The relationships.yaml file supports the following fields:

Custom relationships are loaded on startup and can be used just like built-in relationships in queries:

MATCH (d:Deployment)->(p:Pod)
RETURN d.metadata.name, p.metadata.name