The Backstage-policy-reporter-plugin integrates Policy Reporter with Backstage to provide a clear and detailed view of Kyverno Policies applied to your entities
Go to file
Jonas Beck 3390a1d16d
chore: policy reports empty state component (#66)
2025-06-29 07:32:55 +02:00
.changeset chore: policy reports empty state component (#66) 2025-06-29 07:32:55 +02:00
.devcontainer Initial commit 2025-01-10 14:15:44 +01:00
.github ci(release): remove yarn changeset tag that was moved into script (#56) 2025-06-13 09:11:42 +02:00
.husky Initial commit 2025-01-10 14:15:44 +01:00
.yarn chore: setup backstage repo-tools workspace dev tooling (#49) 2025-06-16 10:55:30 +02:00
catalog chore: setup backstage repo-tools workspace dev tooling (#49) 2025-06-16 10:55:30 +02:00
docs feat: policy reporter page (#58) 2025-06-16 10:57:16 +02:00
example Initial commit 2025-01-10 14:15:44 +01:00
packages chore(tsconfig): add packages/ to tsconfig include to avoid warnings (#65) 2025-06-28 09:38:20 +02:00
plugins chore: policy reports empty state component (#66) 2025-06-29 07:32:55 +02:00
.eslintignore Initial commit 2025-01-10 14:15:44 +01:00
.eslintrc.js Initial commit 2025-01-10 14:15:44 +01:00
.gitattributes Initial commit 2025-01-10 14:15:44 +01:00
.gitignore chore: policy reports empty state component (#66) 2025-06-29 07:32:55 +02:00
.prettierignore chore: setup backstage repo-tools workspace dev tooling (#49) 2025-06-16 10:55:30 +02:00
.yarnrc.yml chore: setup backstage repo-tools workspace dev tooling (#49) 2025-06-16 10:55:30 +02:00
CODEOWNERS chore: add codeowners file 2025-04-15 18:11:17 +02:00
DEVELOPMENT.md chore: upgrade to latest backstage version (#40) 2025-05-06 07:40:13 +02:00
LICENSE Initial commit 2025-01-10 14:15:44 +01:00
README.md feat: add component for viewing policies from custom sources (#34) 2025-04-07 09:23:23 +02:00
app-config.yaml chore: setup backstage repo-tools workspace dev tooling (#49) 2025-06-16 10:55:30 +02:00
backstage.json chore: setup backstage repo-tools workspace dev tooling (#49) 2025-06-16 10:55:30 +02:00
lerna.json Initial commit 2025-01-10 14:15:44 +01:00
package.json chore: setup backstage repo-tools workspace dev tooling (#49) 2025-06-16 10:55:30 +02:00
playwright.config.ts chore: upgrade to latest backstage version (#40) 2025-05-06 07:40:13 +02:00
tsconfig.json chore(tsconfig): add packages/ to tsconfig include to avoid warnings (#65) 2025-06-28 09:38:20 +02:00
yarn.lock chore: add policy report page to example app (#62) 2025-06-17 07:28:57 +02:00

README.md

backstage-kyverno

screenshot

Description

The Backstage-policy-reporter-plugin integrates Policy Reporter with Backstage to provide a clear and detailed view of Kyverno Policies applied to your entities

Setup Backstage with policy-reporter plugin

Step 1: Install packages

From your backstage root directory, run the following commands:


yarn --cwd packages/app add @kyverno/backstage-plugin-policy-reporter
yarn --cwd packages/backend add @kyverno/backstage-plugin-policy-reporter-backend

Step 2: Add the route

Add the desired policy-reporter component(s) to your Entity routes in packages/app/src/components/catalog/EntityPage.tsx Choose from the available components:

For detailed setup instructions including screenshots, see the Component Setup Guide.

EntityKyvernoPoliciesContent example


+ import { EntityKyvernoPoliciesContent } from '@kyverno/backstage-plugin-policy-reporter';

const serviceEntityPage = (

  <EntityLayout>

    // ...

+    <EntityLayout.Route path="/kyverno" title="kyverno policy">
+      <EntityKyvernoPoliciesContent />
+    </EntityLayout.Route>

    // ..

  </EntityLayout>
)

Step 3: Add the backend plugin

for the new backend system, add the plugin in packages/backend/src/index.ts


const backend = createBackend();

// ..
+backend.add(import('@kyverno/backstage-plugin-policy-reporter-backend'));
// ..

backend.start();

Step 4: Define Kubernetes Clusters

In your Backstage instance, define your Kubernetes clusters using the Resource kind and kubernetes-cluster type. Add the kyverno.io/endpoint annotation with the URL to the Policy Reporter API for each cluster.

apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: aks-dev
  annotations:
    # Add the Policy Reporter API endpoint as an annotation
    kyverno.io/endpoint: http://kyverno.io/policy-reporter/api/
spec:
  type: kubernetes-cluster

Policy Reporter Endpoint Configuration

The kyverno.io/endpoint annotation should point to the Policy Reporter API. Use one of the following configurations:

When using Policy Reporter UI:
  • UI Version 1: Use http://your-domain/policy-reporter/api/
  • UI Version 2: Use http://your-domain/policy-reporter/proxy/default/core/
When using standalone Policy Reporter:
  • The Policy Reporter backend needs to be exposed via an ingress (Ingress can be configured in the policy-reporter helmchart)
  • Point to your ingress URL that exposes the Policy Reporter API (e.g., https://your-domain/api/)

Step 5: Annotate Services

To show the policies on the service, add a dependency to the Kubernetes cluster resource in the catalog-info.yaml file of your service. Ensure that the necessary annotations are added as well. For more details, refer to the How to annotate services section.

metadata:
  annotations:
    kyverno.io/namespace: default # Specify the namespace of the service
    kyverno.io/kind: Deployment,Pod # Specify the kind(s) of the Kubernetes resource(s)
    kyverno.io/resource-name: policy-reporter # Specify the name of the resource
spec:
  dependsOn:
    # Add dependency to all environments the service is deployed to using the Resource entityRef
    - resource:default/aks-dev
    - resource:default/aks-tst
    - resource:default/aks-qa
    - resource:default/aks-prd

Optional: Custom policy documentation

To configure the plugin to make the policy Chip a link to custom documentation, follow the steps below.

Step 1: Update the EntityKyvernoPolicyReportsContent component

To enable policy Chip links, the EntityKyvernoPolicyReportsContent component requires the policyDocumentationUrl prop to be set to the URL of the documentation.

const serviceEntityPage = (
  <EntityLayout>
    // ...
    <EntityLayout.Route path="/kyverno" title="kyverno policy">
      <EntityKyvernoPoliciesContent policyDocumentationUrl="Your full URL link" />
    </EntityLayout.Route>
    // ..
  </EntityLayout>
);

Step 2: Configure the Policy documentation

The policy documentation file provided in the above step needs to follow a specific structure.

All policies being used should have a header that matches the exact same name as the policy. Under this header, you can add information about the policy and provide a guide on how to solve it.

The plugin will create a link using the following format: <DocumentationUrl>#<PolicyName>

See the example/policy-documentation.md file for an example of how this could look.

How to annotate services

To use the Kyverno-Policy-Reports plugin with your services, you need to add the following annotations to your catalog-info.yaml:

  • kyverno.io/namespace: This annotation specifies the Kubernetes namespace where the service is located. Multiple values can be separated by a comma (e.g., default,kyverno)
  • kyverno.io/kind: This annotation specifies the kind of Kubernetes resource (e.g., Deployment, StatefulSet, Pod) Multiple values can be separated by a comma (e.g., Deployment,Pod).
  • kyverno.io/resource-name: This annotation specifies the name of the resource
metadata:
  annotations:
    # Annotations for Kyverno-Policy-Reports
+    kyverno.io/namespace: default                   # Specify the namespace(s) of the service
+    kyverno.io/kind: Deployment,Pod                 # Specify the kind(s) of the Kubernetes resource(s)
+    kyverno.io/resource-name: policy-reporter       # Specify the name of the resource