|
| 1 | +# SPDX-License-Identifier: AGPL-3.0-only |
| 2 | + |
| 3 | +# ActivityPolicy for MachineAccount resources. |
| 4 | +# Defines how MachineAccount API operations appear in activity timelines. |
| 5 | +# |
| 6 | +# Audit rules handle CRUD operations captured by the Kubernetes API server audit log. |
| 7 | +# No eventRules — the controller sets conditions but does not emit Kubernetes Events. |
| 8 | +# |
| 9 | +# Design principles: |
| 10 | +# - Use the machine account name as display text |
| 11 | +# - Action-oriented language ("created machine account", "deactivated machine account") |
| 12 | +# - State-specific rules (deactivate/activate) are evaluated before the generic update rule |
| 13 | +apiVersion: activity.miloapis.com/v1alpha1 |
| 14 | +kind: ActivityPolicy |
| 15 | +metadata: |
| 16 | + name: iam.miloapis.com-machineaccount |
| 17 | +spec: |
| 18 | + resource: |
| 19 | + apiGroup: iam.miloapis.com |
| 20 | + kind: MachineAccount |
| 21 | + |
| 22 | + # Audit log rules for CRUD operations. |
| 23 | + # These are automatically captured by the API server and don't require controller code. |
| 24 | + # All rules exclude system components (!audit.user.username.startsWith('system:')) |
| 25 | + # so controller reconciliation doesn't generate activity noise. |
| 26 | + auditRules: |
| 27 | + - name: create |
| 28 | + match: "!audit.user.username.startsWith('system:') && audit.verb == 'create'" |
| 29 | + summary: "{{ actor }} created machine account {{ link(audit.objectRef.name, audit.objectRef) }}" |
| 30 | + |
| 31 | + - name: delete |
| 32 | + match: "!audit.user.username.startsWith('system:') && audit.verb == 'delete'" |
| 33 | + summary: "{{ actor }} deleted machine account {{ audit.objectRef.name }}" |
| 34 | + |
| 35 | + - name: deactivate |
| 36 | + match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec) && has(audit.requestObject.spec.state) && audit.requestObject.spec.state == 'Inactive'" |
| 37 | + summary: "{{ actor }} deactivated machine account {{ link(audit.objectRef.name, audit.objectRef) }}" |
| 38 | + |
| 39 | + - name: activate |
| 40 | + match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec) && has(audit.requestObject.spec.state) && audit.requestObject.spec.state == 'Active'" |
| 41 | + summary: "{{ actor }} reactivated machine account {{ link(audit.objectRef.name, audit.objectRef) }}" |
| 42 | + |
| 43 | + - name: update |
| 44 | + match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource)" |
| 45 | + summary: "{{ actor }} updated machine account {{ link(audit.objectRef.name, audit.objectRef) }}" |
0 commit comments