Skip to content

Commit

Permalink
feat: add kubernetes plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
voidrot committed Oct 24, 2023
1 parent b06767d commit c3889a6
Show file tree
Hide file tree
Showing 7 changed files with 389 additions and 12 deletions.
11 changes: 11 additions & 0 deletions app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,14 @@ events:
modules:
github:
webhookSecret: ${GITHUB_CLIENT_WEBHOOK_SECRET}


kubernetes:
serviceLocatorMethod:
type: 'multiTenant'
clusterLocatorMethods:
- type: 'config'
clusters:
- name: local-cluster
authProvider: 'serviceAccount'
skipTLSVerify: true
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@backstage/plugin-catalog-import": "^0.10.1",
"@backstage/plugin-catalog-react": "^1.8.5",
"@backstage/plugin-github-actions": "^0.6.6",
"@backstage/plugin-kubernetes": "^0.11.0",
"@backstage/plugin-org": "^0.6.15",
"@backstage/plugin-permission-react": "^0.4.16",
"@backstage/plugin-scaffolder": "^1.15.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
import { TechDocsAddons } from '@backstage/plugin-techdocs-react';
import { ReportIssue } from '@backstage/plugin-techdocs-module-addons-contrib';
import { EntityAdrContent, isAdrAvailable } from '@backstage/plugin-adr';
import { EntityKubernetesContent } from '@backstage/plugin-kubernetes';

const techdocsContent = (
<EntityTechdocsContent>
Expand Down Expand Up @@ -176,6 +177,10 @@ const serviceEntityPage = (
<EntityLayout.Route path="/docs" title="Docs">
{techdocsContent}
</EntityLayout.Route>

<EntityLayout.Route path="/kubernetes" title="Kubernetes">
<EntityKubernetesContent refreshIntervalMs={30000} />
</EntityLayout.Route>
</EntityLayout>
);

Expand Down
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@backstage/plugin-events-backend": "^0.2.15",
"@backstage/plugin-events-backend-module-github": "^0.1.16",
"@backstage/plugin-events-node": "^0.2.15",
"@backstage/plugin-kubernetes-backend": "^0.13.0",
"@backstage/plugin-permission-common": "^0.7.9",
"@backstage/plugin-permission-node": "^0.7.17",
"@backstage/plugin-proxy-backend": "^0.4.3",
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { ServerPermissionClient } from '@backstage/plugin-permission-node';
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
import {DefaultEventBroker} from "@backstage/plugin-events-backend";
import adr from './plugins/adr';
import kubernetes from './plugins/kubernetes';

function makeCreateEnv(config: Config) {
const root = getRootLogger();
Expand Down Expand Up @@ -90,6 +91,7 @@ async function main() {
const searchEnv = useHotMemoize(module, () => createEnv('search'));
const appEnv = useHotMemoize(module, () => createEnv('app'));
const adrEnv = useHotMemoize(module, () => createEnv('adr'));
const kubernetesEnv = useHotMemoize(module, () => createEnv('kubernetes'));

const apiRouter = Router();
apiRouter.use('/catalog', await catalog(catalogEnv));
Expand All @@ -99,7 +101,7 @@ async function main() {
apiRouter.use('/proxy', await proxy(proxyEnv));
apiRouter.use('/search', await search(searchEnv));
apiRouter.use('/adr', await adr(adrEnv));

apiRouter.use('/kubernetes', await kubernetes(kubernetesEnv));
// Add backends ABOVE this line; this 404 handler is the catch-all fallback
apiRouter.use(notFoundHandler());

Expand Down
17 changes: 17 additions & 0 deletions packages/backend/src/plugins/kubernetes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { KubernetesBuilder } from '@backstage/plugin-kubernetes-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
import { CatalogClient } from '@backstage/catalog-client';

export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
const catalogApi = new CatalogClient({ discoveryApi: env.discovery });
const { router } = await KubernetesBuilder.createBuilder({
logger: env.logger,
config: env.config,
catalogApi,
permissions: env.permissions,
}).build();
return router;
}
Loading

0 comments on commit c3889a6

Please sign in to comment.