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.
- In the Backstage environment, edit the
app-config.yaml
file. Example path:/my-backstage-app/app-config.yaml
. -
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¶
- In Backstage, click Create.
- Click Register Existing Component.
- Enter the URL for the Rafay Backstage plugin repository.
- Click Analyze.
- Review the entities that will be added, then click Import.
Using Commands¶
-
Install the Rafay Backstage backend plugin package to the Backstage environment.
yarn workspace backend add @RafaySystems/plugin-rafay-backend
-
Create a
rafay.ts
file in thepackages/backend/src/plugins
folder. Include the following content in therafay.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, }); }
-
Edit the
index.ts
file to register the backend plugin. Theindex.ts
file is located atpackages/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));
- Import the Rafay Backstage plugin
import rafay from
-
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"}
- Go to this URL:
-
Install the Rafay Backstage frontend plugin package to the Backstage environment.
yarn workspace app add @RafaySystems/plugin-rafay
-
Edit the
EntityPage.tsx
file to add the Rafay Org entity cards to the entity page layout. TheEntityPage.tsx
file is located atpackages/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 }),
]