Skip to content

About

Backstage plugins for NodeRings: show servers on entity pages and create them from Software Templates

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

NodeRings plugins for Backstage

ci OpenSSF Scorecard

Backstage plugins for NodeRings. Platform teams that run Backstage as their developer portal and host servers on NodeRings can:

  • see the NodeRings virtual machines (Compute Instances) of a catalog entity on its page: status, location, provider, plan, size, IP addresses, tags and snapshots, plus the records of a NodeRings DNS zone;
  • create and delete servers and DNS records from Software Templates, with the scaffolder's review step, dry run and task log;
  • optionally start, stop and restart servers from the entity page, behind a Backstage permission and a config switch that is off by default.

The plugins use the new frontend system and the new backend system, and call the NodeRings API only through the official noderings SDK. The NodeRings token stays in the Backstage backend.

NodeRings tab on an entity page

Entity card Power action with confirmation
Entity card Confirm dialog

Packages

All packages share one version.

Package What it is
@noderings/backstage-plugin-noderings Frontend plugin: entity card "NodeRings servers" and entity tab "NodeRings".
@noderings/backstage-plugin-noderings-backend Backend plugin: /api/noderings, holds the token, checks permissions, caches. Required by the frontend plugin.
@noderings/backstage-plugin-scaffolder-backend-module-noderings Scaffolder actions noderings:vm:create, noderings:vm:delete, noderings:dns:record:upsert.
@noderings/backstage-plugin-noderings-common Annotation keys, permissions and types shared by the others.

Install

The packages target Backstage 1.57 and later, with the new frontend and backend systems.

# frontend (packages/app; feature discovery picks it up)
yarn --cwd packages/app add @noderings/backstage-plugin-noderings
# backend
yarn --cwd packages/backend add @noderings/backstage-plugin-noderings-backend @noderings/backstage-plugin-scaffolder-backend-module-noderings

Apps created with @backstage/create-app 0.9 or later set npmMinimalAgeGate: 3d in .yarnrc.yml, so Yarn refuses a package version until it is three days old (The version for tag "latest" is quarantined). To install a fresh release, add the packages to npmPreapprovedPackages:

# .yarnrc.yml
npmPreapprovedPackages:
  - '@backstage/*'
  - '@noderings/*'
  - noderings
// packages/backend/src/index.ts
backend.add(import('@noderings/backstage-plugin-noderings-backend'));
backend.add(
  import('@noderings/backstage-plugin-scaffolder-backend-module-noderings'),
);

If your app does not use feature discovery (app.packages: all), add the plugin to createApp({ features: [...] }):

import nodeRingsPlugin from '@noderings/backstage-plugin-noderings';

Configure

Create a service account in NodeRings and put its token in the backend environment (never in the file):

# app-config.yaml
noderings:
  token: ${NODERINGS_TOKEN} # required
  # organizationId: ${NODERINGS_ORGANIZATION_ID}  # optional: another organization
  # baseUrl: https://api.noderings.com             # optional
  cacheTtlSeconds: 60 # how long an entity's server list is cached
  allowPowerActions: false # start/stop/restart on the entity page
  scaffolder:
    allowCreate: true # registers noderings:vm:create
    allowDelete: false # registers noderings:vm:delete
    allowedPlanIds: [] # plans noderings:vm:create may order; empty = any
    allowedRegionIds: [] # regions noderings:vm:create may use; empty = any
    maxVmsPerTask: 1

The token needs read access to virtual machines, snapshots, DNS zones and the organization; create and delete on virtual machines for the scaffolder actions; DNS record write for noderings:dns:record:upsert; and start/stop/restart if power actions are on.

Annotate entities

Annotation Meaning
noderings.com/vm-tag: <tag> Every NodeRings server with this tag belongs to the entity (recommended).
noderings.com/vm-ids: <id>,<id> Explicit server ids (alternative).
noderings.com/dns-zone-id: <id> Optional: show the records of this DNS zone on the tab.
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: shop-web
  annotations:
    noderings.com/vm-tag: shop-web
spec:
  type: website
  owner: team-shop
  lifecycle: production

The card and the tab only appear on entities with noderings.com/vm-tag or noderings.com/vm-ids. Servers created by noderings:vm:create with an entityRef get the tag backstage-<namespace>-<kind>-<name> (lowercase, at most 63 characters), and the example template writes it into the new entity's catalog-info.yaml, so the card works with no extra step.

Permissions

Permission Action Guards
noderings.virtualMachine.read read The server list, one server, its snapshots
noderings.virtualMachine.power update Start, stop, restart
noderings.dns.read read The DNS records of the entity's zone

The backend also reads the entity from the catalog with the caller's credentials, so catalog permissions apply too. A sample policy that lets only members of group:default/platform use the power buttons:

import { createBackendModule } from '@backstage/backend-plugin-api';
import { policyExtensionPoint } from '@backstage/plugin-permission-node/alpha';
import {
  AuthorizeResult,
  isPermission,
} from '@backstage/plugin-permission-common';
import { nodeRingsVirtualMachinePowerPermission } from '@noderings/backstage-plugin-noderings-common';

export default createBackendModule({
  pluginId: 'permission',
  moduleId: 'noderings-policy',
  register(reg) {
    reg.registerInit({
      deps: { policy: policyExtensionPoint },
      async init({ policy }) {
        policy.setPolicy({
          async handle(request, user) {
            if (
              isPermission(
                request.permission,
                nodeRingsVirtualMachinePowerPermission,
              )
            ) {
              return user?.info.ownershipEntityRefs.includes(
                'group:default/platform',
              )
                ? { result: AuthorizeResult.ALLOW }
                : { result: AuthorizeResult.DENY };
            }
            return { result: AuthorizeResult.ALLOW };
          },
        });
      },
    });
  },
});

Software Templates

examples/templates/noderings-vm/template.yaml orders a server with noderings:vm:create, writes a catalog-info.yaml for a Resource of type: virtual-machine with the noderings.com/vm-tag annotation, and leaves publishing and registration to you (commented publish:github and catalog:register steps). Register it in catalog.locations, then open /create. The actions and their examples are listed at /create/actions.

Action What it does
noderings:vm:create Orders a billed server. Checks the plan and region allowlists, sends the order with an idempotency key stored in a task checkpoint (a retried task never orders a second server), tags it for the entity and waits until it runs. Dry run reads the plan and orders nothing.
noderings:vm:delete Permanent. Only registered with scaffolder.allowDelete: true, only for servers with a backstage- tag, and only when confirmHostname matches. Snapshots and backups are deleted with the server; if it is the last server on its subscription, the subscription is cancelled with a final usage charge.
noderings:dns:record:upsert Writes an A, AAAA, CNAME, MX or TXT record set. Takes www, @ or a full name (www.example.com). Refuses to replace a different existing record set unless allowOverwrite: true; a rerun with the same values changes nothing.

Billing: servers are billed from the moment they are created. Usage-billed (hourly) plans need prepaid credit; if the credit is too low, the action fails with the API's message, which states the minimum. Plan ids come from the NodeRings marketplace.

Not supported

  • Block volumes, load balancers and resizing a running server: the NodeRings API has none of these (updating a server only edits its tags).
  • Custom image upload.
  • Outbound webhooks: the API has none, so the plugin polls, with a cache (60 s by default) per entity.
  • Restoring snapshots or backups: the tab shows snapshots read-only.
  • Instant Apps are not handled by these plugins.
  • The legacy frontend system: v0.1 ships only the new frontend system. The React components and nodeRingsApiRef are exported for apps that compose their own pages.

Security

  • The NodeRings token is only in backend config (@visibility secret); the browser talks to /api/noderings with the user's Backstage token. Do not put the NodeRings API behind the Backstage proxy: that would let every signed-in user call every API operation.
  • Every data route needs a signed-in user, an entityRef, a permission, and the server must match the entity's tag or id list.
  • Power actions and delete are off by default. Power actions are logged and recorded with the Backstage auditor.

See SECURITY.md to report a vulnerability.

Development

yarn install
yarn start                                  # dev app + backend; NODERINGS_TOKEN in the environment
yarn --cwd plugins/noderings start          # frontend plugin alone, with mock data
yarn tsc && yarn lint:all && yarn test:all  # checks CI runs

See CONTRIBUTING.md and RELEASING.md. NodeRings API docs: https://docs.noderings.com.

License

Apache-2.0

About

Backstage plugins for NodeRings: show servers on entity pages and create them from Software Templates

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages