Relations
About 292 words
The catalog module emits these relations for every kind: Cilium entity, each with its reverse on the other entity.
| From the Cilium entity | To | Reverse | Comes from | Default kind of the target |
|---|---|---|---|---|
ownedBy | its owner | ownerOf | spec.owner | Group |
partOf | its system | hasPart | spec.system | System |
appliesTo | the cluster (policies) | ciliumAppliedBy | spec.cluster | Resource |
partOfPolicy | its policy (rules) | hasPolicyPart | spec.target | Cilium |
appliesTo | each catalog entity it names (rules) | ciliumAppliedBy | the catalog references in spec.from and spec.to | none: the kind is part of the reference |
ownedBy, ownerOf, partOf and hasPart are Backstage's own relation types. partOfPolicy, hasPolicyPart, appliesTo and ciliumAppliedBy are the plugin's. Target references without a namespace take the Cilium entity's namespace.
A rule that names the same entity in from and to gets one appliesTo to it. entity:, cidr:, fqdn: and * peers give no relation.
What reads them
The backend doesn't use the Cilium relations to render: it reads spec.cluster, spec.target, spec.from and spec.to directly. The relations are for the catalog's pages, so a policy shows on its cluster's page and a rule on the pages of what it allows.
To find endpoints and flows, the backend reads Backstage's own relations:
| Relation | On | Used for |
|---|---|---|
dependsOn | Component, Resource | whether it's an endpoint of a cluster; flows to the Resources and external entities it depends on; gateways |
consumesApi | Component | flows to the APIs it consumes |
apiProvidedBy | API | the API's providers: their pods, or their cilium-dst |
In code
@spechtlabs/backstage-plugin-cilium-common exports the relation names (RELATION_PART_OF_POLICY, RELATION_HAS_POLICY_PART, RELATION_APPLIES_TO, RELATION_APPLIED_BY) and ciliumRelations(entity), which returns the relations above for one entity. backstage-cilium-render uses it to add the relations the catalog would.
