Merge pull request #24041 from awanlin/topic/nbs-kubernetes
Updated Kubernetes installation with new backend system examples
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user