Skip to content

Reference · security

Admission policies

RBAC says who may create or patch an object. It cannot see the name that a person writes into a field. Eight ValidatingAdmissionPolicies close that gap. They are CEL in the API server: no webhook, no certificate, no pod.

Policy Kind Operations Purpose
hostoperation-approval HostOperation CREATE, UPDATE The approval gate of one operation.
talosrollout-approval TalosRollout CREATE, UPDATE The approval gate of one rollout plan.
hostclaim-provisioning HostClaim CREATE, UPDATE Who may choose the OS of a machine, and who may skip the boot approval.
etcdbackuppolicy-guard EtcdBackupPolicy CREATE, UPDATE Who may choose who can read the etcd backups, and where they go.
endpointprofile-guard EndpointProfile CREATE, UPDATE Who may change what the operator writes to the BMCs.
taloscluster-credentials-guard TalosCluster CREATE, UPDATE Who may make the published admin credentials live longer than 24 hours.
guard-lift HostOperation, HostClaim, TalosNode, Host CREATE, UPDATE A guard lift or a decision names the person who sets it, and a reason. Only the operator removes disk-not-wiped without a named waiver.
requested-by TalosCluster, TalosNode, HostClaim, BiosProfile, FirmwareProfile, Host, TalosRollout, ConfigMaps with os.platform-kit.org/patch CREATE, UPDATE, DELETE A change that makes the operator propose work names the user who asked for it.
settings-guard The ConfigMap pk-metal/hostoperation-approval CREATE, UPDATE, DELETE Only the admin group changes or deletes the site settings.

All nine have these settings:

failurePolicy: Fail
If the API server cannot evaluate the policy, it refuses the request.
validationActions: [Deny]
A failed rule refuses the request with reason Forbidden.
Parameters
All except requested-by and settings-guard, which need none: the ConfigMap hostoperation-approval in pk-metal. Key operator is the name of the manager. Key adminGroup is the admin group. Key selfApproval tells if a person can approve their own proposal.
parameterNotFoundAction: Deny
Without the ConfigMap, each create and update is refused. The gate fails closed.
apiVersion: v1
kind: ConfigMap
metadata:
name: hostoperation-approval
namespace: pk-metal
data:
operator: system:serviceaccount:pk-metal:pk-metal-manager
adminGroup: pk-metal:admins
selfApproval: Allowed

The two approval policies read the key selfApproval. It applies to operations and to rollouts.

Value A person approves their own proposal Use it when
Allowed Yes. The record names the same person as proposer and approver. The team is too small for review by two persons.
Forbidden No. Another person must approve. One account must not change a machine alone.
Key not set Yes, as Allowed.
Another value No, as Forbidden. The message tells you to set a correct value.

The operator never approves, with each value. Set up approval permissions tells you how to choose.

An operation from proposal to start: the manager creates it, the policy checks the proposer, a person patches the approval, the policy checks the approver, and the executor starts.Proposemanager createsPolicyrules 1 to 3Approvea person patchesPolicyrules 4 to 7Runexecutor
Two checks: one at create, one at approval.

The CRD schema freezes the target, the actions, approval.required and proposedBy. The policy checks the rules that need the name of the requester.

# Rule When Message
1 Nobody creates an operation that is already approved. CREATE an operation cannot be created pre-approved
2 spec.proposedBy is your own name. CREATE spec.proposedBy must name you
3 Only the operator or an admin creates an operation with approval.required: false. CREATE only the operator or an admin may create an operation that needs no approval
4 An approval, once set, does not change. UPDATE approval is write-once
5 You approve as yourself: approvedBy is your name. Approval write you may only approve as yourself
6 The operator approves nothing. Approval write the operator approves nothing: a person with the pk-metal-approver role must approve
7 You approve your own proposal only if selfApproval is Allowed or not set. Approval write this site forbids approving your own proposal (selfApproval: Forbidden in ConfigMap pk-metal/hostoperation-approval): another person must approve
8 You approve a change that you asked for (spec.requestedBy names you) only if selfApproval is Allowed or not set. Approval write you asked for this change (spec.requestedBy names you: your edit made the operator propose it), and this site does not allow approving your own change
Why rule 3
Anybody else could skip the gate. The operator itself creates such operations in three cases. These are the node steps of an approved rollout, an install of a claim with provisioning.approval: Automatic, and a release that needs no person.
Why rule 6 names the operator
The operator proposes most operations. A person must approve them. RBAC also stops the operator: it has no patch on operations. See RBAC. Rule 6 is the second lock. It is the same rule as rule 5 of talosrollout-approval. No setting changes it.
Why rule 7 is a setting
A small team cannot always find a second person. With Allowed, the record still names who proposed and who approved. A value that is not Allowed or Forbidden closes the gate. The message names the value.
Why rule 8
The operator proposes most operations as the result of an edit by a person. Without rule 8, that person could approve the result of their own edit. The operator copies the names from the requested-by annotations into spec.requestedBy. The CRD schema freezes the field.

Example: the manager proposed an operation. jo approves it.

Terminal window
kubectl -n pk-metal patch hostoperation install-node-07 --type merge \
-p '{"spec":{"approval":{"approvedBy":"jo"}}}'

The policy accepts this only if the username of jo is jo. Use pk-metal approve. It writes your name.

One approval covers each node of a rollout plan. So the rules are the rules of an operation, plus the plan hash.

# Rule When Message
1 Nobody creates a rollout with approvedBy or planHash. CREATE a rollout cannot be created pre-approved
2 spec.proposedBy is your own name. CREATE spec.proposedBy must name you
3 approvedBy and planHash, once set, do not change. UPDATE approval is write-once
4 You approve as yourself. Approval write you may only approve as yourself
5 The operator approves nothing. Approval write the operator approves nothing: a person with the pk-metal-approver role must approve
6 You approve your own proposal only if selfApproval is Allowed or not set. Approval write this site forbids approving your own proposal (selfApproval: Forbidden in ConfigMap pk-metal/hostoperation-approval): another person must approve
7 You approve a change that you asked for (spec.requestedBy names you) only if selfApproval is Allowed or not set. Approval write you asked for this change (spec.requestedBy names you: your edit made the operator propose it), and this site does not allow approving your own change

The approval names the planHash that you read. The TalosRollout controller runs the rollout only while that hash is the plan.

A claim that names a TalosNode makes the operator mount the config of that node on the machine. A control-plane config carries the CA keys of the cluster. So these changes are an admin decision.

# Rule When Message
1 Only an admin sets or changes spec.os.nodeRef. CREATE, UPDATE only an admin may name the TalosNode a claim boots
2 Only an admin turns spec.provisioning.approval to Automatic. CREATE, UPDATE only an admin may waive provisioning approval
3 Only an admin points a claim at another machine: a change of spec.assetRef or spec.systemRef. UPDATE only an admin may point a claim at another machine
  • A value that did not change passes. So the finalizers of the operator and edits to other fields need no admin.
  • Each refusal says who you are, your groups, and where group membership comes from.

A snapshot holds each Secret of the cluster. The age recipients decide who can decrypt it. The sink decides where the ciphertext goes. A person who adds a recipient can read each later snapshot. So these changes are an admin decision.

# Rule When Message
1 Only an admin creates a backup policy, or changes spec.encryption or spec.sink. CREATE, UPDATE only an admin may create a backup policy or change its encryption or sink
  • The sink includes the S3 endpoint, the bucket, credentialsSecretRef and caSecretRef.
  • spec.interval, spec.retention and spec.suspend need no admin.
  • The CRD schema refuses an http:// S3 endpoint unless allowPlainHTTP is true. Set it only for a store in a lab.

An EndpointProfile has no approval of its own. The operator applies it to each BMC that it selects. It makes an Administrator account, sets the NTP servers, and replaces the TLS identity, which restarts the BMC.

# Rule When Message
1 Only an admin creates a profile or changes its spec. CREATE, UPDATE only an admin may create or change an EndpointProfile

Labels and annotations of a profile need no admin.

spec.credentials.ttl of a TalosCluster sets how long the published admin kubeconfig and talosconfig are valid. Nobody can revoke a copy before it expires. The CRD allows 720 hours at most.

# Rule When Message
1 Only an admin sets spec.credentials.ttl to more than 24 hours. CREATE, UPDATE, when the value changes only an admin may set spec.credentials.ttl above 24h

Each person who can patch a cluster can make the time shorter, or remove it. The on-call and approver roles can patch clusters.

These annotations lift a safety rule of the operator, or decide a step of a change: metal.platform-kit.org/override-cluster-guard, metal.platform-kit.org/ignore-window, metal.platform-kit.org/ack-etcd-risk, metal.platform-kit.org/allow-self-disruption, metal.platform-kit.org/wipe-waived, metal.platform-kit.org/abort and metal.platform-kit.org/etcd-snapshot-uploaded. RBAC lets each holder of patch set them. This policy makes the value name that holder. See Named guard lifts.

# Rule When Message
1 A request that sets a lift, or changes its value, gives the value <username>: <reason>. The username is the username of the request. The reason is not empty. CREATE, UPDATE a guard lift must name you and say why: set … to "<username>: <reason>"
2 A request that removes metal.platform-kit.org/disk-not-wiped from a Host also sets metal.platform-kit.org/wipe-waived to <username>: <reason>. The operator is exempt: it removes the mark after a wipe. UPDATE the machine may still hold the install of another cluster: wipe it (pk-metal wipe), or waive the wipe in the same request
  • A request that removes a lift passes. That puts the rule back.
  • A request that leaves the value as it is passes. So the writes of the operator and a value from before the policy pass.
  • The operator sets none of these annotations, so it has no exemption from rule 1.
  • The policy takes the ConfigMap hostoperation-approval as parameters, to know the operator. Without the ConfigMap, it refuses each create and update of the four kinds.
  • A GitOps controller that applies a lift must name its own identity. The commit names the person.
  • See Audit trail for the records that show the lift.

The operator proposes most changes itself, as the result of an edit. The proposal names the operator as proposer. This policy makes each such edit name the user who made it, in the annotation metal.platform-kit.org/requested-by. The operator copies the names into spec.requestedBy of the proposal. Rule 8 of hostoperation-approval and rule 7 of talosrollout-approval then apply.

An edit asks for work in these cases:

Kind Requests that ask for work
TalosCluster, TalosNode, BiosProfile, FirmwareProfile Create, a change of spec, delete
HostClaim Create, a change of spec or of metal.platform-kit.org/reinstall, delete (a release)
Host A request that sets or changes metal.platform-kit.org/wipe
TalosRollout A change of spec.abort or spec.paused, or a request that sets os.platform-kit.org/resume
ConfigMap with the label os.platform-kit.org/patch Create, a change of data or binaryData, the label set on a ConfigMap without it, delete
# Rule When Message
1 A request that asks for work sets metal.platform-kit.org/requested-by to the username of the request. CREATE, UPDATE this change makes the operator propose work, so it must name who asked for it
2 A delete that asks for work needs the annotation to name the user of the delete already. Controllers in kube-system (the garbage collector, the namespace controller) are exempt. DELETE deleting it makes the operator propose work, so it must name who asked for it: first set the annotation
3 A request that changes the annotation sets it to the username of the request. Nobody removes it. UPDATE you may set it only to your own username

The ConfigMap pk-metal/hostoperation-approval names the operator and the admin group. It also tells if a person can approve their own change, and how long finished records stay. RBAC lets each holder of update on ConfigMaps in pk-metal change it. This policy limits that to the admin group.

# Rule When Message
1 A change of data, or a delete, comes from a member of the admin group that the ConfigMap names before the request. A request that does not change data passes. UPDATE, DELETE only a member of the admin group "…" may change or delete them
2 The key operator names a service account (system:serviceaccount:…). CREATE, UPDATE the operator key must name the manager's service account
  • A create is not limited. Without the ConfigMap, each policy that reads it refuses each request, so the create is the install.
  • The namespace controller in kube-system can delete the ConfigMap with its namespace.
  • The operator writes a settings.changed line for each change that it sees. See Audit trail.

The operator checks each policy of this page one time each minute. It reports a policy that is missing, has a failurePolicy other than Fail, or has no binding that denies. A binding of a policy with parameters must also have parameterNotFoundAction: Deny. The operator then sets the metric pk_metal_admission_gate_degraded to 1 for the policy, and writes a gate.degraded line. The alert PkMetalAdmissionGateDegraded links Admission gate degraded. The operator changes no policy.