Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #63 from bradmccoydev/feat/add-backstage-annotations
Browse files Browse the repository at this point in the history
Add backstage annotations for service discovery
  • Loading branch information
bradmccoydev authored Nov 28, 2022
2 parents 32905e6 + b3ff37b commit df0119b
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 31 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# [Backstage](https://backstage.io)
# [Ortelius Backstage Portal](https://backstage.ortelius.io)

This is your newly scaffolded Backstage App, Good Luck!
This repo is for the Ortelius Backstage Portal.

To start the app, run:
## Disclaimer 🚧

```sh
yarn install
yarn dev
```
This portal is work in work in progress the first release will be on 15-Dec-22
45 changes: 41 additions & 4 deletions app-config.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ backend:
createRetryIntervalMillis: 200
propagateCreateError: false

kubernetes:
serviceLocatorMethod: 'multiTenant'
clusterLocatorMethods:
- 'config'
clusters:
- url: ${KUBERNETES_URL}
name: aks
serviceAccountToken: ${KUBERNETES_TOKEN}
authProvider: 'serviceAccount'

# plugin:
# auth:
# connection:
Expand All @@ -58,7 +68,34 @@ backend:
# $file: <file-path>/ca/server.crt

catalog:
# Overrides the default list locations from app-config.yaml as these contain example data.
# See https://backstage.io/docs/features/software-catalog/software-catalog-overview#adding-components-to-the-catalog for more details
# on how to get entities into the catalog.
locations: []
import:
entityFilename: catalog-info.yaml
pullRequestBranchName: backstage-integration
rules:
- allow: [Component, System, API, Resource, Location]
locations:
# Local example data, file locations are relative to the backend process, typically `packages/backend`
- type: file
target: ../../examples/entities.yaml

# Local example template
- type: file
target: ../../examples/template/template.yaml
rules:
- allow: [Template]

# Local example organizational data
- type: file
target: ../../examples/org.yaml
rules:
- allow: [User, Group]

# # Uncomment these lines to add more example data
# - type: url
# target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/all.yaml

# # Uncomment these lines to add an example org
# - type: url
# target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/acme-corp.yaml
# rules:
# - allow: [User, Group]
4 changes: 2 additions & 2 deletions chart/backstage/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for the Ortelius Backstage Instance

type: application

version: 0.0.13
appVersion: "0.0.13"
version: 0.0.14
appVersion: "0.0.14"

home: "https://ortelius.io"
icon: https://backstage.io/img/twitter-summary.png
Expand Down
10 changes: 10 additions & 0 deletions chart/backstage/templates/backend/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ spec:
secretKeyRef:
name: backstage-secrets
key: GITHUB_CLIENT_SECRET
- name: KUBERNETES_URL
valueFrom:
secretKeyRef:
name: backstage-secrets
key: KUBERNETES_URL
- name: KUBERNETES_TOKEN
valueFrom:
secretKeyRef:
name: backstage-secrets
key: KUBERNETES_TOKEN
{{- with .Values.backend.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down
23 changes: 23 additions & 0 deletions examples/template/content/catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,26 @@ spec:
email: [email protected]
picture: https://avatars.githubusercontent.com/u/25817813?v=4
memberOf: [devsecops]
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: ortelius-www
annotations:
'backstage.io/kubernetes-id': ortelius-www
spec:
type: service
owner: user:guest
lifecycle: experimental
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: ortelius-docs
annotations:
'backstage.io/kubernetes-id': ortelius-docs
spec:
type: service
owner: user:guest
lifecycle: experimental
---
7 changes: 3 additions & 4 deletions packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ import {

import { TechDocsAddons } from '@backstage/plugin-techdocs-react';
import { ReportIssue } from '@backstage/plugin-techdocs-module-addons-contrib';
// TODO BM uncomment
// import { EntityKubernetesContent } from '@backstage/plugin-kubernetes';
import { EntityKubernetesContent } from '@backstage/plugin-kubernetes';

const techdocsContent = (
<EntityTechdocsContent>
Expand Down Expand Up @@ -168,9 +167,9 @@ const serviceEntityPage = (
{techdocsContent}
</EntityLayout.Route>

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

</EntityLayout>
);
Expand Down
17 changes: 3 additions & 14 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* Hi!
*
* Note that this is an EXAMPLE Backstage backend. Please check the README.
*
* Happy hacking!
*/

import Router from 'express-promise-router';
import {
createServiceBuilder,
Expand All @@ -31,8 +23,7 @@ import search from './plugins/search';
import { PluginEnvironment } from './types';
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
// TODO BM: uncomment
//import kubernetes from './plugins/kubernetes';
import kubernetes from './plugins/kubernetes';

function makeCreateEnv(config: Config) {
const root = getRootLogger();
Expand Down Expand Up @@ -87,8 +78,7 @@ async function main() {
const techdocsEnv = useHotMemoize(module, () => createEnv('techdocs'));
const searchEnv = useHotMemoize(module, () => createEnv('search'));
const appEnv = useHotMemoize(module, () => createEnv('app'));
// TODO BM: add k8s config https://backstage.io/docs/features/kubernetes/configuration
//const kubernetesEnv = useHotMemoize(module, () => createEnv('kubernetes'));
const kubernetesEnv = useHotMemoize(module, () => createEnv('kubernetes'));

const apiRouter = Router();
apiRouter.use('/catalog', await catalog(catalogEnv));
Expand All @@ -97,8 +87,7 @@ async function main() {
apiRouter.use('/techdocs', await techdocs(techdocsEnv));
apiRouter.use('/proxy', await proxy(proxyEnv));
apiRouter.use('/search', await search(searchEnv));
// TODO BM: uncomment once k8s config done
//apiRouter.use('/kubernetes', await kubernetes(kubernetesEnv));
apiRouter.use('/kubernetes', await kubernetes(kubernetesEnv));

// Add backends ABOVE this line; this 404 handler is the catch-all fallback
apiRouter.use(notFoundHandler());
Expand Down
16 changes: 16 additions & 0 deletions packages/backend/src/plugins/kubernetes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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,
}).build();
return router;
}

0 comments on commit df0119b

Please sign in to comment.