Skip to content

Day 1

Set up approval permissions

Give each person the rights for their work. Choose if a person can approve a change that they proposed.

Role What it does How a person gets it
Operator Proposes most operations and rollouts. It never approves. The service account pk-metal/pk-metal-manager. The base binds it.
Proposer Proposes an operation or a rollout: pk-metal reboot, pk-metal restore plan --propose, or a TalosRollout of kind Reboot. create on hostoperations or talosrollouts. The base has no role for this. Write a ClusterRole for it.
Approver Approves with pk-metal approve and pk-metal rollout. Also aborts, pauses, resumes, and lifts guards. The ClusterRole pk-metal-approver. bindings.yaml binds it to a group.
Admin group Names the TalosNode of a claim. Sets automatic approval. Moves a claim to a different machine. Changes backup recipients and EndpointProfiles. Creates operations that need no approval. The group in the ConfigMap key adminGroup, default pk-metal:admins. The membership comes from the login, not from a binding.
On call Follows the runbooks: reads each kind, deletes failed operations, holds claims. It cannot approve. The ClusterRole pk-metal-oncall. Bind it in your overlay.
GitOps service account Applies the kinds that you keep in git. Its own binding. Never give it pk-metal-approver. See Git and GitOps.

A person can have more than one role. A person on call usually also has pk-metal-approver.

The key selfApproval in the ConfigMap hostoperation-approval tells if a person can approve their own change. It applies to operations and to rollouts. A change is "their own" when one of these names the person:

Value What it prevents What it does not prevent
Allowed (the default) The operator approves nothing. A person approves in their own name only, and only one time. Nobody creates an approved object. One person with the proposer and the approver role changes a machine alone. The record names that person as requester and as approver.
Forbidden The same, and also: one account alone cannot change a machine. A second person reads each plan before it runs. The operator and the admin group can still create operations that need no approval. A GitOps service account is the requester of what it applies, not the person who wrote the commit. See Threat model.
  • Select Forbidden if two or more approvers can answer in time.

  • Select Allowed for a small team. Then examine the approvals that a person gave to their own proposals:

    Terminal window
    kubectl get hostoperations,talosrollouts -A -o json | jq -r '.items[]
    | select(.spec.approval.approvedBy as $a | $a != null
    and (.spec.proposedBy == $a or ((.spec.requestedBy // []) | index($a))))
    | "\(.kind) \(.metadata.name) \(.spec.approval.approvedBy)"'
  • The API server reads each other value as Forbidden, and its message names the value.

  1. Bind the approvers. In bindings.yaml, replace example:platform-approvers with your group.

  2. Bind the persons on call. Add this binding to bindings.yaml, with your group:

    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
    name: pk-metal-oncall
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: pk-metal-oncall
    subjects:
    - apiGroup: rbac.authorization.k8s.io
    kind: Group
    name: example:platform-oncall
  3. Set selfApproval in approval.yaml.

    approval.yaml
    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: hostoperation-approval
    namespace: pk-metal
    data:
    selfApproval: Forbidden
  4. Apply the overlay.

    Terminal window
    kubectl apply --server-side -k .

    After the first install, only a member of the admin group can change or delete the ConfigMap. The settings-guard policy refuses each other person. The operator writes a settings.changed line in the Audit trail for each change.

  5. Read the setting back.

    Terminal window
    kubectl -n pk-metal get configmap hostoperation-approval -o jsonpath='{.data.selfApproval}{"\n"}'

    The API server uses the new value after a few seconds.

  6. Ask each approver to examine their rights.

    Terminal window
    kubectl auth can-i patch hostoperations -n pk-metal

    The output is yes.

The operator proposes most changes itself, as the result of an edit. For example, a new talosVersion on a TalosCluster becomes a rollout, and a metal.platform-kit.org/wipe mark on a Host becomes a wipe operation. The proposal names the operator as its proposer. So the person who made the edit must also be on the record.

  • Each request that makes the operator propose work sets the annotation metal.platform-kit.org/requested-by to the username of the request. The requested-by policy refuses the request if not. A delete of such an object needs the annotation before the delete.

  • The pk-metal commands set the annotation for you: pk-metal upgrade, pk-metal scale, pk-metal replace, pk-metal wipe, pk-metal reinstall, and pk-metal rollout pause, resume, and abort.

  • If you use kubectl, set the annotation in the same request:

    Terminal window
    me=$(kubectl auth whoami -o jsonpath='{.status.userInfo.username}')
    kubectl annotate talosnode node-2 --overwrite "metal.platform-kit.org/requested-by=$me"
  • You can set the annotation to your own username only. You cannot remove it. To make a change of another person your own, set your own username.

  • The operator copies the names from the objects behind a proposal into spec.requestedBy of the operation or rollout. This field cannot change after the create.

  • A rollout that the operator proposed ends with PlanChanged if a person who is not in its spec.requestedBy changes what it applies. The operator then proposes it again, with the new names.

  • A Talos config patch in a ConfigMap must have the label os.platform-kit.org/patch: "true". The operator reads no ConfigMap without it. So the policy can find the patches and ask for a name.

Two annotations on a HostOperation lift a safety rule for that operation:

Annotation Rule that it lifts
metal.platform-kit.org/override-cluster-guard A control plane goes down only while etcd is healthy without it. See Cluster guard.
metal.platform-kit.org/ignore-window The operation starts only in a MaintenanceWindow.
  • Each person with patch on operations can set them, before or after the approval. That is each holder of pk-metal-approver. selfApproval does not apply to annotations.
  • The value is <username>: <reason>, with your own username. The guard-lift policy refuses each other value. So the operation records who lifted the rule and why.
  • pk-metal approve shows each lifted guard in the plan, with the person and the reason. If an annotation changes after the command showed the plan, the command approves nothing.
  • An annotation with an empty value lifts nothing. The plan shows it as empty: lifts nothing.

To lift the window on an operation:

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

The key retention in the same ConfigMap tells how long the operator keeps a finished operation or rollout. The default is 30d. Set Forever to keep each record until a person deletes it. See Retention.