HTTP API
About 605 words
The backend plugin's ID is cilium, so its routes live under /api/cilium on your backend. Both are GET. They use Backstage's default authentication: a request needs a user or service token, like any other plugin route. There's no permission check beyond that, and the data is rendered from the whole catalog with the plugin's own credentials.
The backend renders the overview from the catalog at most once a minute and serves the cached result in between.
| Route | Returns |
|---|---|
GET /api/cilium/overview | every policy, rendered, with its problems and publishing status |
GET /api/cilium/policies/:namespace/:name/file | one policy's manifests |
The TypeScript types of every response are exported from @spechtlabs/backstage-plugin-cilium-common.
GET /api/cilium/overview
curl -H "Authorization: Bearer $TOKEN" https://backstage.example.com/api/cilium/overviewReturns an Overview:
| Field | Type | Meaning |
|---|---|---|
policies | PolicyView[] | every policy, ordered by name |
orphans | Diagnostic[] | rule entities whose spec.target isn't a policy |
publish | map of policy entity ref to PublishStatus | for each policy with spec.publish |
A PolicyView has:
| Field | Meaning |
|---|---|
entityRef, name, title, description, owner | from the policy entity |
cluster | the cluster's entity reference |
defaultDeny | { exclude: string[] } |
metricsScraper | the scraper's entity reference, if the policy names one |
endpoints | EndpointView[], sorted by policy name |
flows | Flow[], each endpoint's own included |
rules | RuleView[] |
diagnostics | the policy's errors, warnings and notes: severity, entityRef, message |
documents | each document of the file: name, entityRef, lines (1-based, inclusive) |
text | the rendered manifests |
publish | the policy's spec.publish |
An EndpointView, here component:orders of the example catalog:
{
"entityRef": "component:default/orders",
"kind": "Component",
"namespace": "orders",
"namespaces": [
"orders"
],
"selector": {
"matchLabels": {
"app": "orders"
}
},
"selectorText": "orders/app=orders",
"excluded": false,
"metricsPorts": [
"tcp:9090"
],
"ingress": [
"f1",
"f27",
"f30",
"f45"
],
"egress": [
"f30"
],
"policyName": "allow-component-orders",
"lines": [
431,
490
]
}namespace is set only when there's exactly one; namespaces is empty for an endpoint without one. excluded says whether all its namespaces are left out of the default deny. ingress and egress are flow IDs; policyName and lines are missing for an endpoint without a policy.
A Flow:
{
"id": "f1",
"from": {
"kind": "endpoint",
"value": "component:default/shop",
"title": "Web shop"
},
"to": {
"kind": "endpoint",
"value": "component:default/orders"
},
"ports": [
"tcp:9000"
],
"reason": {
"via": "consumesApi",
"consumer": "component:default/shop",
"api": "api:default/orders-api"
},
"portsFrom": "api:default/orders-api"
}| Field | Meaning |
|---|---|
id | unique within the policy |
from, to | a Peer: kind (endpoint, entity, cidr, fqdn, tailnet), value (an entity reference for endpoint, the destination for tailnet), and title for endpoints with one |
ports | port entries; empty for every port |
portsFrom | the entity whose ports these are |
reason | why the flow exists, by via |
The reasons:
via | Fields |
|---|---|
consumesApi | consumer, api |
dependsOn | dependent, dependency, gateway (true when the flow runs from a gateway to what it exposes) |
allow | entity: the entity whose cilium-allow names the source |
within | entity |
rule | rule |
metrics | scraper, entity |
A RuleView has entityRef, title, description, from, to and ports as written in the entity, and flows, the IDs of the flows it adds.
A PublishStatus has repo, path, flow, branch, pullRequestBranch, a problem when it isn't published (the repository isn't allowed, or the policy has errors), and last: the time, outcome (opened, updated, pushed, up-to-date or failed), URL and error of the last run on this backend instance.
GET /api/cilium/policies/:namespace/:name/file
curl -H "Authorization: Bearer $TOKEN" \
https://backstage.example.com/api/cilium/policies/default/prod/fileReturns the rendered manifests of the policy entity cilium:<namespace>/<name> as text/yaml, with Content-Disposition: inline; filename="<name>.yaml".
404 with {"error": "No Cilium policy cilium:default/x"} when there's no such policy.
