Skip to main content

Recording ownership from a portal

When a GitOps tool applies a resource request, Kubernetes only sees the GitOps tool's ServiceAccount. So the SKE portal integrations for Backstage and Cortex record the user on the request before it goes to Git, in the kratix.io/last-change* annotations.

This page covers how to set up each portal. For the annotations themselves, requests made directly with kubectl, the audit log, and how to require the annotation from your GitOps tool, see Recording who changed a request.

Requirements​

  • Portal Controller v0.9.0 or later.
  • @syntasso/plugin-ske-backend v0.26.0 or later (for Backstage).

Backstage​

Set userIdentifierQuery in the config of each type: backstage entry in portals[]:

apiVersion: platform.syntasso.io/v1alpha1
kind: SKEIntegration
metadata:
name: portal-controller
spec:
type: portal-controller
version: v0.9.0
portals:
- name: prod
type: backstage
config:
userIdentifierQuery: user.spec.profile.email

userIdentifierQuery is a path into the catalog entity of the signed-in user. It starts with user., which stands for that entity, so user.spec.profile.email reads the entity's spec.profile.email.

Every Backstage sign-in provider stores the user's details in a different place on the User entity. SKE cannot know where yours keeps them, so userIdentifierQuery tells it where to look.

The SKE backend plugin reads the value from the signed-in user's entity when the request is submitted. A Template cannot set it.

userIdentifierQuery is optional. Without it, the portal does not annotate its requests.

The request will fail when userIdentifierQuery is set in the following situations:

  • the user has no User entity in the catalog, for example a guest
  • the query finds no value, or the value is not text
  • the query does not start with user.

In Kubernetes API mode with authProvider: oidc, Backstage changes the request as the signed-in user. The SKE Platform Manager then replaces the annotations, as it does for any request made directly. With authProvider: serviceAccount, or in GitOps or hybrid mode, the annotations from userIdentifierQuery are kept.

Upgrading the Backstage backend plugin

You can upgrade the backend plugin and the Portal Controller in either order. However, only set userIdentifierQuery after you upgrade the backend plugin. An older plugin refuses every request from a Template that passes it.

Cortex​

Cortex needs no specific configuration. The create and update workflows that the Portal Controller generates always write the annotations, using the email address of the user who ran the workflow.

Upgrading from older Portal Controllers

Cortex used to write cortex.io/initiated-by and cortex.io/initiated-action. It now writes the kratix.io annotations, and for one release it still reads the old ones, so requests made before the upgrade keep their owner in Cortex.