Skip to main content

Recording who changed a request

SKE records who changes each resource request in two places:

  • On the request, in three kratix.io annotations that describe the latest create or update.
  • In the Kubernetes audit log, as an audit annotation on every create, update and delete. Use it to see the full history of a request, or to count the users of your platform.

For scenarios where a user changes a request directly, for example with kubectl, SKE records this information directly from Kubernetes. When a GitOps tool such as Argo CD or Flux applies the request, Kubernetes sees only the GitOps tool's ServiceAccount. To capture the user, the SKE portal integration records the audit information before it commits the request to Git.

Requirements​

Annotations on the request​

SKE records the latest create or update of each resource request in three annotations on the request:

AnnotationValue
kratix.io/last-changed-byThe user who made the change
kratix.io/last-change-actioncreate or update
kratix.io/last-changed-viaHow the change was made
apiVersion: marketplace.kratix.io/v1alpha1
kind: Database
metadata:
name: my-database
namespace: default
annotations:
kratix.io/last-changed-by: alice@example.com
kratix.io/last-change-action: update
kratix.io/last-changed-via: backstage

The annotations record the latest operation on the request. If the same request is later updated by a different user, the annotations will reflect that instead.

Who sets them depends on how the request reaches Kubernetes:

  • Directly through the Kubernetes API, for example with kubectl, Backstage in Kubernetes API mode with authProvider: oidc, or the SKE MCP server: SKE sets them on every create and update.
  • From a portal using GitOps: the SKE portal integration sets them before the request goes to Git.
  • From a GitOps tool without a portal: nothing sets them, unless you write the annotations into the request yourself.

kratix.io/last-changed-by​

In this annotation, SKE records the user who made the last change to a request. Changes include both creating and modifying a request.

The content of this annotation is configurable based on the information Kubernetes exposes about the user making the change. You choose which of the Kubernetes fields SKE records by setting spec.attribution.userInfoField on the Kratix resource to one of these values:

ValueRecords
username (default)The username the API server gives the user, for example oidc:alice
uidThe user's ID
extra.<KEY>The first value of the extra field <KEY>, for example extra.example.com/email

When the chosen field is empty, SKE records the username instead.

The extra fields are empty unless your cluster sets them. With OIDC, you can copy a claim from the user's token, such as their email, into an extra field. This is useful when the username is an opaque ID and you would rather see another bit of information that better identifies the user.

For example, to record the user's email, map the email claim to the key example.com/email with claimMappings.extra in the API server's authentication configuration:

apiVersion: apiserver.config.k8s.io/v1
kind: AuthenticationConfiguration
jwt:
- issuer:
url: https://issuer.example.com
audiences:
- kubernetes
claimMappings:
username:
claim: sub
prefix: "oidc:"
extra:
- key: example.com/email
valueExpression: claims.email

Then set userInfoField: extra.example.com/email in the Kratix resource.

For a request from a portal using GitOps, the portal records the user: in Backstage, as the value userIdentifierQuery finds on the user's User entity, and in Cortex, as the user's email address.

kratix.io/last-change-action​

create or update.

kratix.io/last-changed-via​

This value is copied from the field manager sent with the Kubernetes request:

  • kubectl sends one on every change, for example kubectl-client-side-apply or kubectl-edit.
  • Backstage, with ske.mode: kubernetes, sends backstage.
  • The SKE MCP server sends ske-mcp-server.

A request without a field manager gets not-informed.

For a request from a portal using GitOps, it is the portal type: backstage or cortex.

Who is skipped​

SKE does not annotate changes from usernames that start with system:. This covers Kratix itself and every ServiceAccount, including a GitOps tool that runs in the cluster. This way, the annotations a portal writes for a GitOps request are kept.

If a GitOps tool connects from outside the cluster, for example with a cloud IAM role, detail the start of its username in the spec.attribution.skipUsernamePrefixes list. Otherwise SKE records the GitOps tool in place of the user the portal recorded.

A change from a skipped username keeps the kratix.io/last-change* annotations it sends.

Configuration​

Both fields are optional:

apiVersion: platform.syntasso.io/v1alpha1
kind: Kratix
metadata:
name: my-kratix
spec:
attribution:
userInfoField: extra.example.com/email
skipUsernamePrefixes:
- "arn:aws:sts::<ACCOUNT_ID>:assumed-role/flux/"

The Kratix resource rejects any other userInfoField value, and an empty prefix. When you change spec.attribution, the SKE Operator restarts the SKE Platform Manager so it picks up the change.

To set these fields when you install SKE without the SKE Operator, see Without the SKE Operator.

Requiring the annotation from a GitOps tool​

By default, SKE does not check that a request applied by a GitOps tool says who made it. When every request in Git should come from a portal, you can make SKE reject any create or update from your GitOps tool that doesn't carry kratix.io/last-changed-by.

List the ServiceAccounts of your GitOps tool in spec.attribution.requireAnnotationsFrom.serviceAccounts on the Kratix resource:

apiVersion: platform.syntasso.io/v1alpha1
kind: Kratix
metadata:
name: my-kratix
spec:
attribution:
requireAnnotationsFrom:
serviceAccounts:
- namespace: argocd
name: argocd-application-controller

For example, Argo CD applies resources with the argocd-application-controller ServiceAccount, and Flux with the kustomize-controller ServiceAccount. Check the namespace and name in your own installation.

Before you list a ServiceAccount, set up your portal to write the annotation, and add it to the requests already in Git. Otherwise SKE rejects them.

If your GitOps tool also applies the sub-requests of a Compound Promise, those need the annotation too. In the Compound Promise's pipeline, copy the kratix.io/last-change* annotations from the parent request onto each sub-request it writes.

A rejected request fails with an error that says which request needs the annotation:

admission webhook "attribution.platform.syntasso.io" denied the request:
Database default/my-database needs the kratix.io/last-changed-by annotation, set
to the user who made the change. SKE requires it on resource requests applied
by service account argocd/argocd-application-controller.

Deletes are not checked, because a GitOps delete removes the file from Git, so it cannot carry the annotation.

SKE checks only that the annotation is set, so a value left from an earlier change passes. SKE lets a request through without checking it:

  • While the SKE Platform Manager is unreachable.
  • Just after its Promise is installed, before SKE sets up the check for that Promise.

The audit log​

The SKE Platform Manager adds the user who made each change to a resource request to the Kubernetes audit log.

Requirements​

The Kubernetes API server audit log must be turned on, with a policy that logs writes to resource requests at the Metadata level or above. The default audit policies of managed Kubernetes services, such as AKS, EKS and GKE, already do this.

To turn on the audit log, find it, and count the number of users of your platform, see the guide for your cluster:

If you run your own API server, a rule like this one logs every write:

apiVersion: audit.k8s.io/v1
kind: Policy
rules:
- level: Metadata
verbs: ["create", "update", "patch", "delete"]

The audit annotation​

Each create, update and delete of a resource request gets the audit annotation attribution.platform.syntasso.io/last-changed-by:

{
"kind": "Event",
"verb": "create",
"user": { "username": "oidc:alice" },
"objectRef": { "resource": "redis", "namespace": "default", "name": "my-redis", "apiGroup": "marketplace.kratix.io" },
"annotations": {
"attribution.platform.syntasso.io/last-changed-by": "alice@example.com"
}
}

Its value depends on who made the change:

Who made the changeValue
A user, for example with kubectlThe user's identity, read from spec.attribution.userInfoField
A GitOps tool listed in spec.attribution.requireAnnotationsFrom.serviceAccountsThe kratix.io/last-changed-by annotation the portal set on the request
note

Changes made by Kratix itself, such as adding finalizers or updating the status, will not get the additional audit annotation. The same goes for any username starting with system: or with one of spec.attribution.skipUsernamePrefixes.

What is not recorded​

  • Deletes through GitOps. The request's file is removed from Git, so nothing says who removed it.
  • Changes from a GitOps tool that is not listed in spec.attribution.requireAnnotationsFrom.serviceAccounts.
  • Changes made while the SKE Platform Manager is unreachable. Kubernetes still accepts the change, so Kratix keeps working, but the audit event has no annotation.

Without the SKE Operator​

If you install SKE from the SKE distribution manifest instead of with the SKE Operator, create the ConfigMap the SKE Operator would write. Its config key takes the same fields as spec.attribution:

apiVersion: v1
kind: ConfigMap
metadata:
name: ske-platform-manager-config
namespace: kratix-platform-system
data:
config: |
attribution:
userInfoField: extra.example.com/email
skipUsernamePrefixes:
- "arn:aws:sts::<ACCOUNT_ID>:assumed-role/flux/"
requireAnnotationsFrom:
serviceAccounts:
- namespace: argocd
name: argocd-application-controller

Without the ConfigMap, the SKE Platform Manager records the username for requests made directly, and checks nothing.

If userInfoField is not one of the supported values, or a prefix is empty, the SKE Platform Manager logs an error and annotates no requests. It still runs the check for requireAnnotationsFrom.

The SKE Platform Manager only reads this ConfigMap when it starts, so restart it after you create or change the ConfigMap.

warning

If the SKE Platform Manager cannot read the config key, for example because it is not valid YAML, the SKE Platform Manager does not start. Check the ConfigMap before you restart it.

kubectl -n kratix-platform-system rollout restart deployment/ske-platform-manager