From 520490ed85e8944a31cfddd6ad5041d56a9ee48b Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Sat, 6 Apr 2024 18:29:33 -0500 Subject: [PATCH] Updated Kubernetes installation with new backend system examples Signed-off-by: Andre Wanlin --- docs/features/kubernetes/installation.md | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/docs/features/kubernetes/installation.md b/docs/features/kubernetes/installation.md index 12053c1ac0..42ceaaa016 100644 --- a/docs/features/kubernetes/installation.md +++ b/docs/features/kubernetes/installation.md @@ -103,6 +103,31 @@ async function main() { That's it! The Kubernetes frontend and backend have now been added to your Backstage app. +### New Backend System + +To get the Kubernetes plugin install using the New Backend System you will need to do the following: + +Run this command to add the package: + +```bash +# From your Backstage root directory +yarn --cwd packages/backend add @backstage/plugin-kubernetes-backend +``` + +Then add it to your backend `index.ts` file: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-kubernetes-backend/alpha')); +/* highlight-add-end */ + +backend.start(); +``` + ### Custom cluster discovery If either existing @@ -174,6 +199,45 @@ export default async function createPlugin( } ``` +### New Backend System Custom cluster discovery + +To use Custom cluster discovery with the New Backend System you'll need to create a module and add it to your backend. Here's a very simplified example: + +```ts title="packages/backend/src/index.ts" +import { createBackend } from '@backstage/backend-defaults'; +import { createBackendModule } from '@backstage/backend-plugin-api'; +import { Duration } from 'luxon'; +import { kubernetesClusterSupplierExtensionPoint } from '@backstage/plugin-kubernetes-node'; +import { CustomClustersSupplier } from './path/to/class'; + +const backend = createBackend(); + +export const kubernetesModuleCustomClusterDiscovery = createBackendModule({ + pluginId: 'kubernetes', + moduleId: 'custom-cluster-discovery', + register(env) { + env.registerInit({ + deps: { + kubernetes: kubernetesClusterSupplierExtensionPoint, + }, + async init({ kubernetes }) { + kubernetes.addClusterSupplier( + CustomClustersSupplier.create(Duration.fromObject({ minutes: 60 })), + ); + }, + }); + }, +}); + +// Other plugins... +backend.add(import('@backstage/plugin-kubernetes-backend/alpha')); +backend.add(kubernetesModuleCustomClusterDiscovery); + +backend.start(); +``` + +> Note: this example assumes the `CustomClustersSupplier` class is the same from the [previous example](#custom-cluster-discovery) + ## Configuration After installing the plugins in the code, you'll need to then