Skip to content

Reference · security

Audit trail

Each change to a machine goes through an approved HostOperation or TalosRollout. Three records tell who asked for the change, who approved it, who lifted a guard, and what ran.

Record What it holds Where it lives How long it stays
The objects The current state of each operation and rollout: proposer, approver, guard lifts, steps, result. The API server of the management cluster. Until the operator or a person deletes it. See Retention.
The operator audit log One JSON line for each decision: proposed, approved, guard lifted, step, finished, deleted. The log of the manager pod, and your log store. As long as your log store keeps it.
The kube-apiserver audit log Each request to the API server: who sent it. With the audit policy for Talos, also the body for the pk-metal kinds. Each control-plane node of the management cluster, and your log store. As long as the node or your log store keeps it.

The objects are complete but short-lived. The two logs stay after the object is gone. Send both logs to a log store that you keep for as long as your audit rules ask.

Field Kind What it records
spec.proposedBy HostOperation, TalosRollout The person or the operator that proposed it. Admission checks it against the request.
spec.approval.approvedBy HostOperation, TalosRollout The person that approved it. Admission checks it against the request.
spec.approval.planHash TalosRollout The plan that the person approved.
metadata.annotations HostOperation, HostClaim, TalosNode, Host The guard lifts, with the name of the person and the reason. See Named guard lifts.
status.conditions HostOperation, TalosRollout When the approval took effect, when it ran, and why it stopped.
status.steps HostOperation, TalosRollout Each step, its result and its message.

Read one record:

Terminal window
kubectl -n pk-metal get hostoperation reboot-node-1 -o yaml

The manager writes one JSON line for each decision on the logger audit. The lines go to the standard error of the manager, with its other log lines. The field "logger":"audit" sets them apart.

Read the lines of the last day:

Terminal window
kubectl -n pk-metal logs deployment/pk-metal-manager --since=24h \
| jq -cR 'fromjson? | select(.logger == "audit")'

In a log store, select the manager container of the manager pods, then the field. Other pods in pk-metal can write lines that look the same. For example, in Loki with the labels of the Kubernetes service discovery:

{namespace="pk-metal", app_kubernetes_io_component="manager", container="manager"} | json | logger="audit"

The label names depend on how your log shipper maps the pod labels. Select on the pod label app.kubernetes.io/component=manager and the container manager.

Each line has these fields:

Field Value
ts The time of the line, RFC 3339 in UTC.
logger Always audit.
seq The number of the line in the manager process, from 1. A gap or a repeated number shows a missing or a repeated line. A new process starts again at 1.
pod The name of the manager pod that wrote the line.
event One of the events below.
kind HostOperation, TalosRollout, HostClaim, TalosNode, Host, ConfigMap (the site settings) or ValidatingAdmissionPolicy.
namespace The namespace of the object. It is empty for a cluster-scoped kind.
name The name of the object.
uid The UID of the object. A new object with the same name has a different UID.
actor Who made the decision: a person, or the service account of the operator. It is empty if a guard lift names nobody.
requestedBy On proposed and approved: the persons whose edit made the operator propose the change (spec.requestedBy). Not there if the list is empty.
old, new On settings.read and settings.changed: the settings before and after, by key. A key that the ConfigMap does not have is not there.
replayed, replayedBy On approved and guard.lifted: true if pk-metal pivot set the decision again on the target cluster, and the user who ran the move. The decision is not new. pk-metal pivot writes these lines to its standard error.

An event adds the fields in the table below. A line never holds a Secret, a credential, a BMC password or a media grant token. The operator masks the credentials and the grant token of a URL in a message. A message has at most 512 bytes.

event When Fields that it adds
proposed The operator first writes the status of the operation or rollout. proposedBy, requestedBy, target (the Host or the cluster), plan, approvalRequired
approved The approval of a person takes effect. proposedBy, requestedBy, approvedBy, selfApproved, planHash (rollouts)
paused A person pauses a rollout (spec.paused). The actor is the person that metal.platform-kit.org/requested-by names. None
resumed A rollout continues after a pause: a person cleared spec.paused, or resumed it after its first node. None
guard.lifted The operator uses a guard lift. That occurs at the start of an operation, at each step that stops a node, and at a proposal that changes etcd. annotation, value, named, and operation or step and action
step.started A step starts. step (from 0), action
step.finished A step succeeds. step, action, result
step.failed A step fails. step, action, result, reason, message
finished The operation or rollout ends. phase, reason, durationSeconds, and message with the abort. For a rollout, the message names the person who aborted it.
deleted The operator deletes the object. The line comes before the delete request. reason, message
media.fetched A BMC fetches through a media grant of the operation for the first time. The grant is now bound to that address. grant (the file name), source
media.refused The media service refuses a request with a wrong password, or from an address that is not the bound one. At most ten lines for each grant. grant, source, reason
media.grantEnded A media grant ends. grant, source (empty if nobody fetched), reason (revoked or expired), requests, bytes, refused
settings.read The operator reads the site settings (hostoperation-approval) for the first time after it starts. The actor is empty. new, and message if the ConfigMap is missing
settings.changed The operator sees a change of selfApproval, retention, adminGroup or operator. The actor is empty: the kube-apiserver audit log names who. old, new, and message if the ConfigMap is gone
gate.degraded An admission policy of the gate, or its binding, is missing or does not deny. See Admission gate degraded. message
gate.restored A degraded policy is in place again. None
bmc.account.set The operator sets the password of its managed account on a BMC. The password is not in the line. account, reason (Adopted, Rotated, Renamed or Repaired)
bmc.account.disabled The operator disables an account on a BMC that a rotation replaced. account, reason
bmc.identity.pushed The operator gives a BMC a new TLS certificate. key (the fingerprint), message
bmc.restarted The operator restarts a BMC. action (the reset type), reason
bmc.tls.pinned The operator trusts a TLS key of a BMC from this point. key, reason (FirstUse, Approved or Pushed)

The reason of a deleted line is one of these:

reason Why the operator deletes the object
RetentionExpired The record finished and the retention ended.
Withdrawn A proposal that nobody approved. A newer plan replaced it, or its cause went away.
Stopped The operator stops an operation that cannot complete, for example the boot of a node that a person deleted.
RetryRequested A person asked for a retry with pk-metal retry. The operator proposes the plan again.
RecordOfRemovedObject The record of a claim or a node that a person removed.
OwnerDeleted An operation of a rollout. The API server deletes it with the rollout.
PivotPruned pk-metal pivot removed it from the target cluster: the source cluster no longer has it. The actor is the user who ran the move.

The ts field is the same in each example. The operator is system:serviceaccount:pk-metal:pk-metal-manager, shown as <operator>.

{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":1,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"proposed","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"alice","proposedBy":"alice","target":"host-1","plan":"talosReboot, waitNodeReady","approvalRequired":true}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":2,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"approved","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"bob","proposedBy":"alice","approvedBy":"bob","selfApproved":false}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":3,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"approved","kind":"TalosRollout","namespace":"","name":"fleet-talosupgrade-1a2b3c4d","uid":"u-2","actor":"alice","proposedBy":"<operator>","requestedBy":["alice"],"approvedBy":"alice","selfApproved":true,"planHash":"sha256:abc"}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":4,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"guard.lifted","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"alice","annotation":"metal.platform-kit.org/ignore-window","value":"alice: CVE fix","named":true}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":5,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"guard.lifted","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"bob","annotation":"metal.platform-kit.org/override-cluster-guard","value":"bob: single control plane","named":true,"step":2,"action":"talosReboot"}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":6,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"step.started","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"<operator>","step":0,"action":"cordon"}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":7,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"step.finished","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"<operator>","step":1,"action":"drain","result":"Succeeded"}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":8,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"step.failed","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"<operator>","step":2,"action":"talosReboot","result":"Failed","reason":"StepFailed","message":"node did not come back"}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":9,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"finished","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"<operator>","reason":"StepsSucceeded","phase":"Succeeded","durationSeconds":95}
{"ts":"2026-03-04T05:06:07.0000008Z","logger":"audit","seq":10,"pod":"pk-metal-manager-7c9d5-x2v4q","event":"deleted","kind":"HostOperation","namespace":"pk-metal","name":"reboot-node-1","uid":"u-1","actor":"<operator>","reason":"RetentionExpired","message":"finished 720h0m0s ago"}

The operator writes a line when its status write records the change. If the API server refuses the write, the operator writes no line, and writes it on the next pass. So a reconcile that repeats writes no second line.

  • A deleted line can show two times. That occurs if the delete request fails and the operator tries again. Use uid and event to find a repeated line.
  • A restart of the manager between the status write and the line loses that one line. The object and the kube-apiserver audit log still record the change.
  • Each line has pod and seq. Sort the lines of one pod by seq and look for gaps. The numbers show a lost line. They do not stop a person who can write to your log store from changing a line. Keep the log store outside the cluster, and write-once if your audit rules ask for it.
  • A field change in this schema breaks each site that reads it. The unit tests of internal/audit pin each line.

The API server records each request that its audit policy selects. It shows who sent a request, also through impersonation. With the policy below, it also shows the body that changed an object. Use it to find when a person set an annotation, and who deleted a record.

Talos writes the log on each control-plane node, in /var/log/audit/kube/. Read it with talosctl:

Terminal window
talosctl -n 192.0.2.11 read /var/log/audit/kube/kube-apiserver.log \
| jq -c 'select(.objectRef.apiGroup == "metal.platform-kit.org")'

Send the log to your log store, because the node rotates the file.

Without a policy of your own, Talos records Metadata only: who sent a request, never the body. To record the bodies, give the policy as a KubeAuditPolicyConfig document in the patches of the TalosCluster of the management cluster. The operator renders it into the configuration of each control plane. Talos allows the document only on control planes, so the operator leaves it out of the configuration of each worker. The API server uses the first rule that matches.

TalosCluster patch: audit policy
spec:
patches:
- inline: |
apiVersion: v1alpha1
kind: KubeAuditPolicyConfig
configuration:
apiVersion: audit.k8s.io/v1
kind: Policy
omitStages:
- RequestReceived
rules:
# Secrets of pk-metal: BMC logins, credentials, backup keys.
# Who read or changed them, never the body.
- level: Metadata
namespaces: ["pk-metal"]
resources:
- group: ""
resources: ["secrets"]
# Each change to a pk-metal kind, with the request and the response.
- level: RequestResponse
verbs: ["create", "update", "patch", "delete", "deletecollection"]
resources:
- group: metal.platform-kit.org
- group: os.platform-kit.org
# The site settings and the Talos config patches.
- level: Request
verbs: ["create", "update", "patch", "delete"]
namespaces: ["pk-metal"]
resources:
- group: ""
resources: ["configmaps"]
# The policies and the bindings that guard the approval.
- level: Request
verbs: ["create", "update", "patch", "delete"]
resources:
- group: admissionregistration.k8s.io
- group: rbac.authorization.k8s.io
# Reads of the rest: not recorded.
- level: None
verbs: ["get", "list", "watch"]
# Each other change: who and what, no body.
- level: Metadata
  • The rule for Secrets comes first. A later rule cannot record the body of a Secret.
  • The Metadata rule at the end also covers each Secret outside pk-metal. That rule records no body.
  • Do not use the field cluster.apiServer.auditPolicy. Talos 1.14 and later refuse it next to the documents that the operator renders.
  • Do not change the policy with talosctl patch machineconfig on a node that pk-metal manages. The operator sees the change as drift, and its next Config rollout removes the policy.
  • The change of the patch makes the operator propose a Config rollout for the control planes. The policy applies when a person approves it. A test of the operator renders this patch with the Talos version that the operator pins, and validates the result.

The key retention in the ConfigMap hostoperation-approval tells how long the operator keeps a finished record.

Value Effect
30d (the default) The operator deletes a finished record 30 days after it finished. A missing key has the same effect.
Days, for example 90d The same, after that number of days.
A duration, for example 720h The same, after that time.
Forever The operator deletes no finished record. A person deletes them.
0, 0s, 0d, a negative value, or more days than a duration holds (106752d and more) The operator keeps each record, and logs the problem.
A value that the operator cannot read The operator keeps each record, and logs the problem.

The operator deletes only these records:

  • A Succeeded operation that has spec.ttlSecondsAfterFinished: after its TTL or the retention, whichever is longer. The operator sets a TTL on releases, wipes and convergence proposals. The TTL is frozen after creation, so an approver cannot add one to a record that must stay.
  • A Succeeded rollout, after the retention. Its operations go with it, and each gets a deleted line.
  • A proposal that nobody approved, when a newer plan replaces it or its cause goes away. The retention does not apply, because nothing ran. The deleted line has the reason Withdrawn.

The operator keeps each Failed or Aborted record. A person deletes it, for example with pk-metal retry.

The default of 30 days is long enough to look back over a month of changes. It is short enough that the API server does not keep many records that nobody reads. Keep the two logs for longer in your log store.

Set the value in the site overlay:

approval.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: hostoperation-approval
namespace: pk-metal
data:
retention: 90d

The operator reads the value again within one hour.

These annotations lift a safety rule or decide a step of a change:

Annotation On Rule that it lifts, or decision
metal.platform-kit.org/override-cluster-guard HostOperation A control plane goes down only while etcd is healthy without it.
metal.platform-kit.org/ignore-window HostOperation The operation starts only in a MaintenanceWindow.
metal.platform-kit.org/ack-etcd-risk HostClaim, TalosNode A control plane leaves etcd only if etcd keeps an odd size and a majority.
metal.platform-kit.org/allow-self-disruption Host The operator does not stop the machine that it runs on, or a control plane of its own cluster.
metal.platform-kit.org/wipe-waived Host The operator installs nothing on a machine with metal.platform-kit.org/disk-not-wiped. A person who removes that mark must set this annotation in the same request.
metal.platform-kit.org/abort HostOperation A person stops the operation.
metal.platform-kit.org/etcd-snapshot-uploaded HostOperation A person uploaded the etcd snapshot. The reason is the sha256 of the upload.

The value must be <username>: <reason>. The username is the username of the request, and the reason is not empty. The admission policy guard-lift refuses each other value. So the object records who lifted the rule and why.

Terminal window
kubectl -n pk-metal annotate hostoperation reboot-node-1 \
metal.platform-kit.org/ignore-window="$(kubectl auth whoami -o jsonpath='{.status.userInfo.username}'): CVE fix"

The audit log records metal.platform-kit.org/allow-self-disruption with each operation that it lets stop the node of the operator, and metal.platform-kit.org/wipe-waived with each install that starts on the machine. The finished line of an aborted operation has the value of metal.platform-kit.org/abort in message. The operator removes metal.platform-kit.org/wipe-waived when it marks the machine again or wipes it.

If the site sets selfApproval: Allowed, a person can approve their own change. The approved line then has "selfApproved":true. A change is their own if proposedBy names them, or if requestedBy names them: their edit made the operator propose it. See Set up approval permissions.

Find each self-approval in the operator audit log:

Terminal window
kubectl -n pk-metal logs deployment/pk-metal-manager --since=168h \
| jq -cR 'fromjson? | select(.logger == "audit" and .event == "approved" and .selfApproved)
| {ts, kind, namespace, name, actor}'

The objects show the same thing while they exist: spec.approval.approvedBy has the value of spec.proposedBy, or a value in spec.requestedBy.