Skip to content

Setup

Configure Rafay Org Account in Backstage

Using Backstage with the Rafay Org requires authentication using the Rafay Org API token. Update the Backstage app-config.yaml file with the Rafay Org URL and your API key.

  1. In the Backstage environment, edit the app-config.yaml file. Example path: /my-backstage-app/app-config.yaml.
  2. Add the following to the YAML file.

    rafay:
      baseUrl: <rafay_console_url>
      apiKey: <rafay_api_key>
    

Example:

rafay:
  baseUrl: console.rafay.dev
  apiKey: 09876abcde12345fghij54321klmno67890

Install Rafay Backstage Plugin

Using Backstage

  1. In Backstage, click Create.
  2. Click Register Existing Component.
  3. Enter the URL for the Rafay Backstage plugin repository.
  4. Click Analyze.
  5. Review the entities that will be added, then click Import.

Using Commands

  1. Install the Rafay Backstage backend plugin package to the Backstage environment.

    yarn workspace backend add @RafaySystems/plugin-rafay-backend
    
  2. Create a rafay.ts file in the packages/backend/src/plugins folder. Include the following content in the rafay.ts file.

    import { createRouter } from '@RafaySystems/plugin-rafay-backend';
    import { PluginEnvironment } from '../types';
    
    export default async function createPlugin(env: PluginEnvironment) {
        return await createRouter({
            logger: env.logger,
            config: env.config,
        });
    }
    
  3. Edit the index.ts file to register the backend plugin. The index.ts file is located at packages/backend/src/.

    • Import the Rafay Backstage plugin import rafay from ./plugins/rafay
    • Create Rafay Org environment const rafayEnv = useHotMemoize(module, () => createEnv('rafay'));
    • Add route apiRouter.use('/rafay-backend', await rafay(rafayEnv));

      Update Index TS

  4. Verify that the backend plugin is running in the Backstage environment.

    • Go to this URL: https://<your-backstage-app>/api/rafay-backend/health
    • You should receive {"status":"ok"}
  5. Install the Rafay Backstage frontend plugin package to the Backstage environment.

    yarn workspace app add @RafaySystems/plugin-rafay
    
  6. Edit the EntityPage.tsx file to add the Rafay Org entity cards to the entity page layout. The EntityPage.tsx file is located at packages/app/scr/components/catalog.


Import Rafay Org Templates

Some example templates have been provided for creating resources. These templates can be imported by adding a location to the catalog coofiguration in th app-config.yaml file.

-type: file
  target: ../../rafay-examples/templates/all.yaml
  rules:
  - allow: [Template]

Install Template Actions

Edit the scaffolder.ts file to register the Rafay Org scaffolder actions. The scaffolder.t file is located at packages/backend/src/plugins/.

- Import template actions
    import {
  createNewEKSClusterAction,
  createNewClusterFromTemplateAction,
  createNewNamespaceAction,
  createNewWorkloadAction,
  createNewAKSClusterAction,
  createNewGKEClusterAction,
} from '@RafaySystems/plugin-rafay-backend';
- Extend builtin actions
    const actions = [
    ...builtInActions,
    createNewGKEClusterAction({ config: env.config }),
    createNewAKSClusterAction({ config: env.config }),
    createNewClusterAction({ config: env.config }),
    createNewClusterFromTemplateAction({ config: env.config }),
    createNewNamespaceAction({ config: env.config }),
    createNewWorkloadAction({ config: env.config }),
  ]