Chapter 1. Topology plugin for Backstage
The Topology plugin enables you to visualize the workloads such as Deployment, Job, Daemonset, Statefulset, CronJob, and Pods powering any service on the Kubernetes cluster.
1.1. For administrators Copy linkLink copied to clipboard!
1.1.1. Installation Copy linkLink copied to clipboard!
Prerequisites
-
The Kubernetes plugins including
@backstage/plugin-kubernetesand@backstage/plugin-kubernetes-backendare installed and configured by following the installation and configuration guides. -
The Kubernetes plugin is configured and connects to the cluster using a
ServiceAccount. -
The
ClusterRolemust be granted toServiceAccountaccessing the cluster. If you have the Backstage Kubernetes plugin configured, then theClusterRoleis already granted. The following must be added in
customResourcescomponent in theapp-config.yamlfile to view the OpenShift route:kubernetes: ... customResources: - group: 'route.openshift.io' apiVersion: 'v1' plural: 'routes'Also, ensure that the route is granted a
ClusterRole. You can use the following code to grant theClusterRoleto the route :... apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-read-only rules: ... - apiGroups: - route.openshift.io resources: - routes verbs: - get - listThe following code must be added in
customResourcescomponent in theapp-config.yamlfile to view the Tekton PipelineRuns list in side panel:kubernetes: ... customResources: - group: 'tekton.dev' apiVersion: 'v1beta1' plural: 'pipelines' - group: 'tekton.dev' apiVersion: 'v1beta1' plural: 'pipelineruns'Also, ensure that the Pipeline and PipelineRun are granted a
ClusterRole. You can use the following code to grant theClusterRoleto Pipeline and PipelineRun:... apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-read-only rules: ... - apiGroups: - tekton.dev resources: - pipelines - pipelineruns verbs: - get - listThe following annotation is added to the entity’s
catalog-info.yamlfile to identify whether an entitiy contains the Kubernetes resources:```yaml title="catalog-info.yaml" annotations: backstage.io/kubernetes-id: <BACKSTAGE_ENTITY_NAME> ```You can also add the
backstage.io/kubernetes-namespaceannotation to identify the Kubernetes resources using the defined namespace.```yaml title="catalog-info.yaml" annotations: backstage.io/kubernetes-namespace: <RESOURCE_NS> ```A custom label selector is added, which Backstage uses to find the Kubernetes resources. The label selector takes precedence over the ID annotations.
```yaml title="catalog-info.yaml" annotations: backstage.io/kubernetes-label-selector: 'app=my-app,component=front-end' ```The following label is added to the resources so that the Kubernetes plugin gets the Kubernetes resources from the requested entity:
```yaml title="catalog-info.yaml" labels: backstage.io/kubernetes-id: <BACKSTAGE_ENTITY_NAME>` ```NoteWhen using the label selector, the mentioned labels must be present on the resource.
The following label is added to display the workload resources such as Deployments and Pods in a visual group:
```yaml title="catalog-info.yaml" labels: app.kubernetes.io/part-of: <GROUP_NAME> ```The following annotation is added to display the workload resources such as Deployments and Pods with a visual connector:
```yaml title="catalog-info.yaml" annotations: app.openshift.io/connects-to: '[{"apiVersion": <RESOURCE_APIVERSION>,"kind": <RESOURCE_KIND>,"name": <RESOURCE_NAME>}]' ```For more information about the labels and annotations, see Guidelines for labels and annotations for OpenShift applications.
Procedure
Install the Topology plugin using the following command:
yarn workspace app add @redhat/backstage-plugin-topologyEnable TOPOLOGY tab in
packages/app/src/components/catalog/EntityPage.tsx:```tsx title="packages/app/src/components/catalog/EntityPage.tsx" /* highlight-add-next-line */ import { TopologyPage } from '@redhat/backstage-plugin-topology'; const serviceEntityPage = ( <EntityPageLayout> {/* ... */} {/* highlight-add-start */} <EntityLayout.Route path="/topology" title="Topology"> <TopologyPage /> </EntityLayout.Route> {/* highlight-add-end */} </EntityPageLayout> ); ```
1.2. For users Copy linkLink copied to clipboard!
1.2.1. Using the Topology plugin in Backstage Copy linkLink copied to clipboard!
Topology is a front-end plugin that enables you to view the workloads as nodes that power any service on the Kubernetes cluster.
Prerequisites
- Your Backstage application is installed and running.
- You have installed the Topology plugin. For the installation process, see Section 1.1.1, “Installation”.
Procedure
- Open your Backstage application and select a component from the Catalog page.
Go to the TOPOLOGY tab and you can view the workloads such as Deployments, Pods as nodes.
Select a node and a pop-up appears on the right side, which contains two tabs: Details and Resources.
The Details and Resources tab contain the associated information and resources of the node.
Click on the Open URL button on the top of a node.
When you click on the open URL button, it allows you to access the associated Ingresses and runs your application in a new tab.