Questo contenuto non è disponibile nella lingua selezionata.
Chapter 7. Install the Topology plugin
Install and configure the Topology plugin to visualize Kubernetes workloads and manage labels and annotations.
7.1. Install the Topology plugin Copia collegamentoCollegamento copiato negli appunti!
Visualize Kubernetes workloads like Deployments, Pods, and Virtual Machines by enabling the Topology plugin.
The Topology plugin enables you to visualize the workloads such as Deployment, Job, Daemonset, Statefulset, CronJob, Pods and Virtual Machines powering any service on your Kubernetes cluster.
Prerequisites
- You have installed and configured the @backstage/plugin-kubernetes-backend dynamic plugins.
- You have configured the Kubernetes plugin to connect to the cluster using a ServiceAccount.
The
ClusterRolemust be granted to ServiceAccount accessing the cluster.NoteIf you have the Developer Hub Kubernetes plugin configured, then the
ClusterRoleis already granted.
Procedure
The Topology plugin is pre-loaded in Developer Hub with basic configuration properties. To enable it, set the disabled property to false as follows:
app-config.yamlfragmentauth: global: dynamic: includes: - dynamic-plugins.default.yaml plugins: - package: ./dynamic-plugins/dist/backstage-community-plugin-topology disabled: false
7.2. Configure the Topology plugin Copia collegamentoCollegamento copiato negli appunti!
Configure the Topology plugin to view OpenShift routes, pod logs, Tekton PipelineRuns, and virtual machines.
7.2.1. View OpenShift routes Copia collegamentoCollegamento copiato negli appunti!
Grant read access to routes resource in ClusterRole to view OpenShift routes in the Topology plugin.
Procedure
To view OpenShift routes, grant read access to the
routesresource in theClusterRole:apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-read-only rules: ... - apiGroups: - route.openshift.io resources: - routes verbs: - get - listAlso add the following in
kubernetes.customResourcesproperty in yourapp-config.yamlfile:kubernetes: ... customResources: - group: 'route.openshift.io' apiVersion: 'v1' plural: 'routes'
7.2.2. View pod logs Copia collegamentoCollegamento copiato negli appunti!
Grant ClusterRole permissions to pods and pods/log resources to view pod logs in the Topology plugin.
Procedure
To view pod logs, you must grant the following permission to the
ClusterRole:apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-read-only rules: ... - apiGroups: - '' resources: - pods - pods/log verbs: - get - list - watch
7.2.3. View Tekton PipelineRuns Copia collegamentoCollegamento copiato negli appunti!
Grant ClusterRole access to Tekton resources to view PipelineRuns status in the Topology plugin.
Procedure
To view the Tekton
PipelineRuns, grant read access to thepipelines,pipelineruns, andtaskrunsresources in theClusterRole:... apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-read-only rules: ... - apiGroups: - tekton.dev resources: - pipelines - pipelineruns - taskruns verbs: - get - listTo view the Tekton
PipelineRunslist in the side panel and the latestPipelineRunsstatus in the Topology node decorator, add the following code to thekubernetes.customResourcesproperty in yourapp-config.yamlfile:kubernetes: ... customResources: - group: 'tekton.dev' apiVersion: 'v1' plural: 'pipelines' - group: 'tekton.dev' apiVersion: 'v1' plural: 'pipelineruns' - group: 'tekton.dev' apiVersion: 'v1' plural: 'taskruns'
7.2.4. View virtual machines Copia collegamentoCollegamento copiato negli appunti!
Grant ClusterRole access to VirtualMachines resources to view virtual machine nodes in the Topology plugin.
Prerequisites
- The OpenShift Virtualization operator is installed and configured on a Kubernetes cluster.
Procedure
Grant read access to the
VirtualMachinesresource in theClusterRole:... apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-read-only rules: ... - apiGroups: - kubevirt.io resources: - virtualmachines - virtualmachineinstances verbs: - get - listTo view the virtual machine nodes on the topology plugin, add the following code to the
kubernetes.customResourcesproperty in theapp-config.yamlfile:kubernetes: ... customResources: - group: 'kubevirt.io' apiVersion: 'v1' plural: 'virtualmachines' - group: 'kubevirt.io' apiVersion: 'v1' plural: 'virtualmachineinstances'
7.2.5. Enable the source code editor Copia collegamentoCollegamento copiato negli appunti!
Enable the source code editor to allow developers to open source code directly from RHDH.
Procedure
Grant read access to the CheClusters resource in the
ClusterRole:... apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-read-only rules: ... - apiGroups: - org.eclipse.che resources: - checlusters verbs: - get - listAdd the following configuration to the
kubernetes.customResourcesproperty in yourapp-config.yamlfile:kubernetes: ... customResources: - group: 'org.eclipse.che' apiVersion: 'v2' plural: 'checlusters'
7.3. Manage labels and annotations for Topology plugins Copia collegamentoCollegamento copiato negli appunti!
Configure labels and annotations to customize Kubernetes resource identification and visualization in the Topology plugin.
7.3.1. Link to the source code editor or the source Copia collegamentoCollegamento copiato negli appunti!
Add annotations to workload resources to enable navigation to the Git repository of the associated application using the source code editor.
Procedure
Add the following annotations to workload resources, such as Deployments, to navigate to the Git repository of the associated application using the source code editor:
annotations: app.openshift.io/vcs-uri: <GIT_REPO_URL>Optional: Add the following annotation to navigate to a specific branch:
annotations: app.openshift.io/vcs-ref: <GIT_REPO_BRANCH>Optional: Add the
app.openshift.io/edit-linkannotation with the edit URL that you want to access using the decorator.NoteIf Red Hat OpenShift Dev Spaces is installed and configured and Git URL annotations are also added to the workload YAML file, then clicking on the edit code decorator redirects you to the Red Hat OpenShift Dev Spaces instance.
NoteWhen you deploy your application using the OCP Git import flows, you do not need to add the labels as import flows do that. Otherwise, you need to add the labels manually to the workload YAML file.
7.3.2. Add entity annotations and labels for the Kubernetes plugin Copia collegamentoCollegamento copiato negli appunti!
Add annotations and labels to enable RHDH to detect that an entity has Kubernetes components.
Procedure
Add the following annotation to the
catalog-info.yamlfile of the entity:annotations: backstage.io/kubernetes-id: <BACKSTAGE_ENTITY_NAME>Add the following label to the resources so that the Kubernetes plugin gets the Kubernetes resources from the requested entity:
labels: backstage.io/kubernetes-id: <BACKSTAGE_ENTITY_NAME>NoteWhen using the label selector, the mentioned labels must be present on the resource.
7.3.3. Namespace annotation Copia collegamentoCollegamento copiato negli appunti!
Identify Kubernetes resources by namespace using the backstage.io/kubernetes-namespace annotation.
Procedure
To identify the Kubernetes resources using the defined namespace, add the
backstage.io/kubernetes-namespaceannotation:annotations: backstage.io/kubernetes-namespace: <RESOURCE_NS>The Red Hat OpenShift Dev Spaces instance is not accessible using the source code editor if the
backstage.io/kubernetes-namespaceannotation is added to thecatalog-info.yamlfile.To retrieve the instance URL, you require the CheCluster custom resource (CR). As the CheCluster CR is created in the openshift-devspaces namespace, the instance URL is not retrieved if the namespace annotation value is not openshift-devspaces.
7.3.4. Add a label selector query annotation Copia collegamentoCollegamento copiato negli appunti!
Add a custom label selector annotation so that RHDH uses your custom labels to find Kubernetes resources.
Procedure
Add the
backstage.io/kubernetes-label-selectorannotation to thecatalog-info.yamlfile of the entity. The label selector takes precedence over the ID annotations:annotations: backstage.io/kubernetes-label-selector: 'app=my-app,component=front-end'Optional: If you have many entities while Red Hat Dev Spaces is configured and want multmanyities to support the edit code decorator that redirects to the Red Hat Dev Spaces instance, add the
backstage.io/kubernetes-label-selectorannotation to thecatalog-info.yamlfile for each entity:annotations: backstage.io/kubernetes-label-selector: 'component in (<BACKSTAGE_ENTITY_NAME>,che)'If you are using the previous label selector, add the following labels to your resources so that the Kubernetes plugin gets the Kubernetes resources from the requested entity:
labels: component: che # add this label to your che cluster instance labels: component: <BACKSTAGE_ENTITY_NAME> # add this label to the other resources associated with your entityYou can also write your own custom query for the label selector with unique labels to differentiate your entities. However, you need to ensure that you add those labels to the resources associated with your entities including your
CheClusterinstance.
7.3.5. Display a runtime icon in the topology node Copia collegamentoCollegamento copiato negli appunti!
Add a label to workload resources to display a runtime icon in the topology nodes.
Procedure
Add the following label to workload resources, such as Deployments:
labels: app.openshift.io/runtime: <RUNTIME_NAME>Alternatively, you can include the following label to display the runtime icon:
labels: app.kubernetes.io/name: <RUNTIME_NAME>Supported values of
<RUNTIME_NAME>includedjango,dotnet,drupal,go-gopher,golang,grails,jboss,jruby,js,nginx,nodejs,openjdk,perl,phalcon,php,python,quarkus,rails,redis,rh-spring-boot,rust,java,rh-openjdk,ruby,spring, andspring-boot. Other values result in icons not being rendered for the node.
7.3.6. Group applications in the topology view Copia collegamentoCollegamento copiato negli appunti!
Add a label to workload resources to display them in a visual group in the topology view.
Procedure
Add the following label to workload resources, such as deployments or pods, to display them in a visual group:
labels: app.kubernetes.io/part-of: <GROUP_NAME>
7.3.7. Node connector Copia collegamentoCollegamento copiato negli appunti!
Display visual connectors between workload resources like deployments and pods using annotations.
Procedure
To display the workload resources such as deployments or pods with a visual connector, add the following annotation:
annotations: app.openshift.io/connects-to: '[{"apiVersion": <RESOURCE_APIVERSION>,"kind": <RESOURCE_KIND>,"name": <RESOURCE_NAME>}]'