[backstage] Reflect Flux resources into BS entities #3297
Open
Description
As outlined here: https://github.com/weaveworks/weave-technical-scratchpad/blob/main/kevin/backstage/backstage_gitrepository_resources_as_entities.md
User story:
- As a User I use backstage a lot and use its dependency declaration system to do things like declaring that team-salsa owns a particular git-repo, so I can contact them if I have questions, need to change something etc.
Question:
- Would this go in EE or OSS BS plugin? Probably OSS
Behaviour:
- When I add a Flux GitRepository (or hr,ks,helmrepo etc) to my cluster, I see a BS "Kind: Resource" entity appear in the BS catalog
- This allows me to declare relationships between different flux resources AND other BS entities like Users / services / etc.
- E.g. we could reference a flux bs resource like this: https://github.com/weaveworks/backstage-sockshop/blob/main/components/catalogue-service.yaml#L21-L22
Tasks
- run the command to generate new backstage backend plugin https://backstage.io/docs/plugins/backend-plugin,
yarn new --select backend-plugin
maybe calledcatalog-backend-module-flux
- Wanna install it very similarly to other entityprovider plugins
import { FluxEntityProvider } from '@backstage/plugin-catalog-backend-module-flux';
...
builder.addEntityProvider(
FluxEntityProvider.fromConfig({
logger: env.logger,
scheduler: env.scheduler,
config: env.config
})
);
And add some more config stuff:
catalog:
providers:
flux:
gitrepositories:
labelSelector:
example.com/git: true
schedule:
frequency: { minutes: 30 }
timeout: { minutes: 3 }
- And add a schema like this one https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-gcp/config.d.ts
- Implement an EntityProvider like https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.ts#L41