|
| 1 | +# SPDX-License-Identifier: AGPL-3.0-only |
| 2 | + |
| 3 | +# ActivityPolicy for DNSRecordSet resources. |
| 4 | +# Defines how DNSRecordSet API operations and controller events appear in activity timelines. |
| 5 | +# |
| 6 | +# Audit rules handle CRUD operations captured by the Kubernetes API server audit log. |
| 7 | +# Event rules handle async controller events for programming outcomes. |
| 8 | +apiVersion: activity.miloapis.com/v1alpha1 |
| 9 | +kind: ActivityPolicy |
| 10 | +metadata: |
| 11 | + name: dns.networking.miloapis.com-dnsrecordset |
| 12 | +spec: |
| 13 | + resource: |
| 14 | + apiGroup: dns.networking.miloapis.com |
| 15 | + kind: DNSRecordSet |
| 16 | + |
| 17 | + # Audit log rules for CRUD operations. |
| 18 | + # These are automatically captured by the API server and don't require controller code. |
| 19 | + auditRules: |
| 20 | + - match: "audit.verb == 'create'" |
| 21 | + summary: "{{ actor }} created {{ audit.responseObject.spec.recordType }} record {{ link(audit.objectRef.name, audit.responseObject) }} in zone {{ audit.responseObject.spec.dnsZoneRef.name }}" |
| 22 | + |
| 23 | + - match: "audit.verb == 'delete'" |
| 24 | + summary: "{{ actor }} deleted DNS record {{ audit.objectRef.name }}" |
| 25 | + |
| 26 | + - match: "audit.verb in ['update', 'patch'] && !audit.objectRef.subresource" |
| 27 | + summary: "{{ actor }} updated {{ audit.requestObject.spec.recordType }} record {{ link(audit.objectRef.name, audit.objectRef) }}" |
| 28 | + |
| 29 | + # Status subresource updates are system-initiated and typically not shown to users, |
| 30 | + # but can be enabled if needed for debugging. |
| 31 | + # - match: "audit.verb in ['update', 'patch'] && audit.objectRef.subresource == 'status'" |
| 32 | + # summary: "System updated status of DNS record {{ link(audit.objectRef.name, audit.objectRef) }}" |
| 33 | + |
| 34 | + # Event rules for controller-emitted Kubernetes events. |
| 35 | + # These capture async outcomes that audit logs cannot represent. |
| 36 | + # |
| 37 | + # A DNSRecordSet can contain multiple records with potentially different names |
| 38 | + # (e.g., "www" and "api" A records in one set). The annotations reflect this: |
| 39 | + # - record-count: total number of record entries |
| 40 | + # - record-names: comma-separated unique names (e.g., "www" or "www,api") |
| 41 | + # - ip-addresses: all IPs for A/AAAA types (may span multiple names) |
| 42 | + eventRules: |
| 43 | + # RecordSetProgrammed: DNS records successfully programmed to the DNS provider. |
| 44 | + # Annotations available: |
| 45 | + # dns.networking.miloapis.com/event-type: dns.recordset.programmed |
| 46 | + # dns.networking.miloapis.com/domain-name: example.com |
| 47 | + # dns.networking.miloapis.com/record-type: A |
| 48 | + # dns.networking.miloapis.com/record-names: www (or "www,api" for multi-name) |
| 49 | + # dns.networking.miloapis.com/record-count: 2 |
| 50 | + # dns.networking.miloapis.com/ip-addresses: 192.168.1.1,192.168.1.2 (A/AAAA only) |
| 51 | + # dns.networking.miloapis.com/zone-ref: my-zone |
| 52 | + # dns.networking.miloapis.com/resource-name: my-recordset |
| 53 | + # dns.networking.miloapis.com/resource-namespace: my-project |
| 54 | + |
| 55 | + # Single A/AAAA record (most common case): show name and IPs |
| 56 | + - match: "event.reason == 'RecordSetProgrammed' && event.annotations['dns.networking.miloapis.com/record-type'] in ['A', 'AAAA'] && event.annotations['dns.networking.miloapis.com/record-count'] == '1'" |
| 57 | + summary: "{{ event.annotations['dns.networking.miloapis.com/record-type'] }} record {{ link(event.regarding.name, event.regarding) }} ({{ event.annotations['dns.networking.miloapis.com/record-names'] }}.{{ event.annotations['dns.networking.miloapis.com/domain-name'] }} -> {{ event.annotations['dns.networking.miloapis.com/ip-addresses'] }}) is now active" |
| 58 | + |
| 59 | + # Multiple A/AAAA records: show count and names |
| 60 | + - match: "event.reason == 'RecordSetProgrammed' && event.annotations['dns.networking.miloapis.com/record-type'] in ['A', 'AAAA'] && event.annotations['dns.networking.miloapis.com/record-count'] != '1'" |
| 61 | + summary: "{{ event.annotations['dns.networking.miloapis.com/record-count'] }} {{ event.annotations['dns.networking.miloapis.com/record-type'] }} records {{ link(event.regarding.name, event.regarding) }} ({{ event.annotations['dns.networking.miloapis.com/record-names'] }}.{{ event.annotations['dns.networking.miloapis.com/domain-name'] }}) are now active" |
| 62 | + |
| 63 | + # Single non-IP record: show name |
| 64 | + - match: "event.reason == 'RecordSetProgrammed' && !(event.annotations['dns.networking.miloapis.com/record-type'] in ['A', 'AAAA']) && event.annotations['dns.networking.miloapis.com/record-count'] == '1'" |
| 65 | + summary: "{{ event.annotations['dns.networking.miloapis.com/record-type'] }} record {{ link(event.regarding.name, event.regarding) }} ({{ event.annotations['dns.networking.miloapis.com/record-names'] }}.{{ event.annotations['dns.networking.miloapis.com/domain-name'] }}) is now active" |
| 66 | + |
| 67 | + # Multiple non-IP records: show count and names |
| 68 | + - match: "event.reason == 'RecordSetProgrammed' && !(event.annotations['dns.networking.miloapis.com/record-type'] in ['A', 'AAAA']) && event.annotations['dns.networking.miloapis.com/record-count'] != '1'" |
| 69 | + summary: "{{ event.annotations['dns.networking.miloapis.com/record-count'] }} {{ event.annotations['dns.networking.miloapis.com/record-type'] }} records {{ link(event.regarding.name, event.regarding) }} ({{ event.annotations['dns.networking.miloapis.com/record-names'] }}.{{ event.annotations['dns.networking.miloapis.com/domain-name'] }}) are now active" |
| 70 | + |
| 71 | + # RecordSetProgrammingFailed: DNS record programming failed after previous success. |
| 72 | + # Annotations available: |
| 73 | + # dns.networking.miloapis.com/event-type: dns.recordset.programming_failed |
| 74 | + # dns.networking.miloapis.com/domain-name: example.com |
| 75 | + # dns.networking.miloapis.com/record-type: A |
| 76 | + # dns.networking.miloapis.com/record-names: www |
| 77 | + # dns.networking.miloapis.com/failure-reason: Provider API error |
| 78 | + # dns.networking.miloapis.com/zone-ref: my-zone |
| 79 | + # dns.networking.miloapis.com/resource-name: my-recordset |
| 80 | + # dns.networking.miloapis.com/resource-namespace: my-project |
| 81 | + - match: "event.reason == 'RecordSetProgrammingFailed'" |
| 82 | + summary: "{{ event.annotations['dns.networking.miloapis.com/record-type'] }} record {{ link(event.regarding.name, event.regarding) }} programming failed: {{ event.annotations['dns.networking.miloapis.com/failure-reason'] }}" |
0 commit comments