@k3tech/backstage-plugin-frontend-addons
v2.0.5
Published
π― **K3T Backstage Plugin Frontend Addons** - A powerful solution for extending components in Backstage through a smart, template-based addon marketplace.
Readme
Entity Addons Plugin
π― K3T Backstage Plugin Frontend Addons - A powerful solution for extending components in Backstage through a smart, template-based addon marketplace.
This Backstage frontend plugin provides a marketplace-like experience for extending component capabilities through reusable addon templates. It intelligently filters and displays only relevant addons for your components based on their template origin.
π¬ π Live Presentation Preview
Interactive Presentation Available! Watch our comprehensive guide covering architecture, setup, best practices, and more.
π Bilingual: Portuguese (BR) & English | π± Responsive | π¨ Neon Theme | β¨οΈ Keyboard Navigation
βΆοΈ OPEN PRESENTATION π₯
- 17 Interactive Slides covering the entire plugin
- Language Switcher in top-right corner (PT-BR / EN-US)
- Instant Language Switching - your preference is saved
- Navigation: Arrow keys or spacebar to navigate
- Content Includes:
- Architecture & template binding system
- Installation & configuration
- API reference & components
- Real-world examples
- Best practices
- Troubleshooting guide
- FAQ section
Quick Tips:
- Press
F11for fullscreen mode - Use arrow keys
ββor spacebar to navigate - Click language buttons in top-right to switch
- Available in Brazilian Portuguese (default) and English
β¨ Key Features
- π Template-based Addons: Create reusable addon templates that enhance existing components
- π― Smart Filtering: Automatically discover addons relevant to your component's template origin
- ποΈ Visual Discovery: Display addons in a grid with template cards showing title, description, and metadata
- β‘ One-Click Integration: Pre-populate the scaffolder form with the current component reference
- π Git-native: Addons can directly modify component repositories with automated commits
- ποΈ Flexible Architecture: Full support for different template types and custom annotations
- π¦ Lightweight: Optimized plugin with zero side effects and minimal dependencies
π― Architecture & How It Works
This plugin uses an intelligent two-level template binding system:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BACKSTAGE CATALOG β
β β
β ββββββββββββββββ ββββββββββββββββββββββββ β
β β COMPONENT β ββββββββββ¬βββΆ β ADDON TEMPLATES β β
β β β β β (addon-of link) β β
β β Origin: β β β β β
β β microservice-ββββββββββββ β β Add Monitoring β β
β β template β β β Add Logging β β
β ββββββββββββββββ β β Add Security β β
β β β Add CI/CD β β
β ββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββHow It Works:
Template Origin (Component Metadata): Stores which template was used to create the component
metadata: k3t.io: scaffolder-origin: template:default/microservice-templateAddon Templates (Scaffolder Templates): Templates marked with
metadata.k3t.addon-compatible-to(array) that reference the originmetadata: k3t: addon-compatible-to: - template:default/microservice-templateAddon Discovery (Smart Query): When viewing the "Addons" tab, the plugin queries the catalog for matching templates
Pre-filled Scaffolder (Automatic Integration): Clicking an addon pre-populates the scaffolder with the component reference as
entity_ref
π¦ Installation
yarn add @k3tech/backstage-plugin-frontend-addonsπ Quick Start
Step 1: Install the Plugin
Add the plugin to your Backstage instance by updating packages/app/src/components/catalog/EntityPage.tsx:
import { EntityAddonsContent } from '@k3tech/backstage-plugin-frontend-addons';
const defaultEntityPage = (
<EntityLayout>
{/* ... other routes ... */}
<EntityLayout.Route path="/addons" title="Addons">
<EntityAddonsContent variant="gridItem" />
</EntityLayout.Route>
</EntityLayout>
);Step 2: Annotate Your Components with Template Origin
Update your catalog-info.yaml:
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: my-microservice
k3t.io:
scaffolder-origin: template:default/microservice-template
annotations:
backstage.io/repo-url: https://github.com/my-org/my-microservice
spec:
type: service
lifecycle: production
owner: my-teamStep 3: Create Addon Templates
Create scaffolder templates with the metadata.k3t.addon-compatible-to field:
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: add-monitoring
title: π Add Monitoring & Observability
description: Integrate Prometheus, Grafana and intelligent alerts
k3t:
addon-compatible-to:
- template:default/microservice-template
tags:
- monitoring
- observability
- infrastructure
spec:
type: Service
parameters:
- title: π― Target Configuration
required:
- entity_ref
properties:
entity_ref:
title: Select Component
type: string
description: Which microservice do you want to monitor?
ui:field: EntityPicker
ui:options:
defaultNamespace: default
allowedKinds:
- Component
catalogFilter:
- kind: ['Component']
'metadata.k3t.io.scaffolder-origin': 'template:default/microservice-template'
monitoring_tool:
title: π§ Monitoring Tool
type: string
enum:
- prometheus
- datadog
- newrelic
- elastic
description: Which solution do you prefer?
enable_alerts:
title: π Enable Alerts
type: boolean
default: true
steps:
- id: fetch_component
name: π¦ Fetch Component Information
action: catalog:fetch
input:
entityRef: ${{ parameters.entity_ref }}
- id: clone_repo
name: π Clone Repository
action: git:clone:azure
input:
defaultBranch: main
repoUrl: ${{ steps.fetch_component.output.entity.metadata.annotations["backstage.io/repo-url"] }}
- id: apply_monitoring
name: π Apply Monitoring Configuration
action: fetch:template
input:
url: ./templates/${{ parameters.monitoring_tool }}
targetPath: ./monitoring
values:
monitoring_tool: ${{ parameters.monitoring_tool }}
enable_alerts: ${{ parameters.enable_alerts }}
component_name: ${{ steps.fetch_component.output.entity.metadata.name }}
- id: commit
name: πΎ Commit Changes
action: git:commit:azure
input:
createBranch: false
defaultBranch: feat/add-${{ parameters.monitoring_tool }}-monitoring
commitMessage: "feat: add ${{ parameters.monitoring_tool }} monitoring and observability"
gitAuthorName: 'Backstage Addon Bot'
output:
links:
- title: π View Component in Catalog
icon: catalog
entityRef: ${{ parameters.entity_ref }}
- title: π§ Repository
url: ${{ steps.fetch_component.output.entity.metadata.annotations["backstage.io/repo-url"] }}Configuration
Template Binding Annotations
Two key annotations enable the plugin's functionality:
Component Annotation: metadata.k3t.io.scaffolder-origin
Applied to components to specify which template they were created from:
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: my-service
k3t.io:
scaffolder-origin: template:default/microservice-template
annotations:
backstage.io/repo-url: https://github.com/my-org/my-service
spec:
type: service
owner: my-teamTemplate Annotation: metadata.k3t.addon-compatible-to
Applied to addon templates to indicate which component template origin they are compatible with:
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: add-monitoring
title: Add Monitoring
description: Add monitoring and observability to microservices
k3t:
addon-compatible-to:
- template:default/microservice-template
spec:
type: Service
parameters:
- title: Select Target Component
required:
- entity_ref
properties:
entity_ref:
title: Component to Enhance
type: string
ui:field: EntityPicker
ui:options:
defaultNamespace: default
allowedKinds:
- Component
catalogFilter:
- kind: ['Component']
'metadata.annotations.k3t.io/scaffolder-origin': 'template:default/microservice-template'
monitoring_tool:
title: Monitoring Tool
type: string
enum:
- prometheus
- datadog
- newrelic
description: Select monitoring solution
steps:
- id: fetch_component
name: Fetch Component Repository Info
action: catalog:fetch
input:
entityRef: ${{ parameters.entity_ref }}
- id: clone
name: Clone Repository
action: git:clone:azure
input:
defaultBranch: main
repoUrl: ${{ steps.fetch_component.output.entity.metadata.annotations["backstage.io/repo-url"] }}
- id: apply_monitoring
name: Apply Monitoring Configuration
action: fetch:template
input:
url: ./monitoring-templates/${{ parameters.monitoring_tool }}
targetPath: ./
values:
monitoring_tool: ${{ parameters.monitoring_tool }}
- id: commit
name: Commit Changes
action: git:commit:azure
input:
createBranch: false
defaultBranch: feat/add-monitoring
commitMessage: "feat: add ${{ parameters.monitoring_tool }} monitoring"
gitAuthorName: 'Backstage Bot'
output:
links:
- title: View Component
icon: catalog
entityRef: ${{ parameters.entity_ref }}
- title: Repository
url: ${{ steps.fetch_component.output.entity.metadata.annotations["backstage.io/repo-url"] }}API Reference
EntityAddonsContent
The main component for displaying available addons for an entity.
import { EntityAddonsContent } from '@k3tech/backstage-plugin-frontend-addons';Props:
variant?: string- Display variant (default:'gridItem')
Features:
- Automatically detects the current entity's template origin
- Queries the catalog for all matching addon templates
- Displays results in an interactive grid
- Pre-populates scaffolder with entity reference
Exported Components
export { entityAddonsPlugin } from './plugin';
export { EntityAddonsComponent, EntityAddonsContent } from './components/EntityAddons';
export { TemplateCard, TemplateCardGridItem } from './components/TemplateCard';Advanced Usage Examples
Example 1: Multiple Addon Categories
Create different addon templates for different aspects:
# Addon for adding CI/CD
annotations:
k3t/supported-by: template:default/backend-service
backstage.io/addon-category: infrastructure
---
# Addon for adding security scanning
annotations:
k3t/supported-by: template:default/backend-service
backstage.io/addon-category: security
---
# Addon for documentation setup
annotations:
k3t/supported-by: template:default/backend-service
backstage.io/addon-category: documentationExample 2: Conditional Addon Parameters
Configure addons to accept component-specific metadata:
steps:
- id: fetch_component
name: Load Component Details
action: catalog:fetch
input:
entityRef: ${{ parameters.entity_ref }}
- id: apply_addon
name: Apply Based on Component Type
action: fetch:template
input:
url: ./templates
values:
component_owner: ${{ steps.fetch_component.output.entity.metadata.annotations["backstage.io/owner"] }}
component_lifecycle: ${{ steps.fetch_component.output.entity.spec.lifecycle }}Troubleshooting
Addons Not Showing
- Verify the annotation format: Ensure
k3t.io/scaffolder-originin your component exactly matchesk3t/supported-byin your addon template - Check catalog sync: Run
backstage-cli catalog:refreshto ensure templates are indexed - Validate YAML: Use a YAML validator to ensure proper formatting
Pre-population Not Working
- Check component reference: Component must be accessible in the catalog
- Verify EntityPicker configuration: Ensure catalog filters match your component annotations
- Test URL encoding: The component ref is URL-encoded; verify special characters are handled
Best Practices
- Naming: Use consistent, descriptive names for addon templates (e.g.,
add-logging,add-security-scanning) - Documentation: Add clear descriptions to addon templates so users understand what they do
- Testing: Test addon templates with sample components before promoting to production
- Git Workflow: Use feature branches (e.g.,
feat/addon-name) to keep changes organized - Metadata: Include ownership and lifecycle information in component annotations for better governance
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
License
This plugin is licensed under the Apache-2.0 License.
