Command · pk-metal
pk-metal approve
changes machinesneeds the cluster
pk-metal approve shows what a proposed HostOperation does to a machine. Then it asks you, and it approves the operation as your cluster user.
The operator does not act on a machine before a person approves the plan.
Synopsis
Section titled “Synopsis”pk-metal approve [-n namespace] [--yes] [<operation> | <namespace>/<operation> ...]- No argument
- The command lists the operations that wait for approval.
<operation>- The name of the operation, as pk-metal status prints it:
pk-metal/<name>, or the name only with-n. <operation> ...- Several operations. The command shows the plan of each one and asks about each one. Refer to Several operations.
| Flag | Default | Description |
|---|---|---|
-n<string> | pk-metal | Namespace of the operation. |
--yes | false | Approve without asking (for scripts); the plan is still printed. |
This command also accepts the global flags --kubeconfig and --context.
What it does
Section titled “What it does”Approve one operation
1 / 7
Read
approve reads the operation, its Host, the BMC paths, the boot assets and the TalosNodes. It asks the API server for your user name.
pk-metal approve pk-metal/provision-simhw2288v5000397-1a2b3c4dRead. approve reads the operation, its Host, the BMC paths, the boot assets and the TalosNodes. It asks the API server for your user name.
pk-metal approve pk-metal/provision-simhw2288v5000397-1a2b3c4dRefuse. approve stops here if the operation is approved, is finished, needs no approval, or if you proposed it.
Show the plan. approve prints the plan: the machine, its BMC, each step in order, and the disk that the install overwrites.
Ask. approve asks "Approve as <user>? [y/N]". The question waits five minutes. Without an answer, nothing changes.
Approve as alice? [y/N] yRead again. After a yes, approve reads the operation again. It must be the same object (same UID) and the plan must read the same.
Approve. approve writes your user name into the operation. The patch carries the UID and the resource version, so the API server refuses it if the object changed.
spec.approval.approvedBy: aliceRun. The HostOperation controller sees the approval and starts the first action. Follow it with pk-metal status.
pk-metal status
- The command asks the API server for your user name.
- It reads the operation. It stops if one of these conditions is true:
- A person approved the operation before. An approval cannot change.
- The operation has a result.
- The operation needs no approval.
- You proposed the operation, and your site forbids self-approval. The command can see this only if you can read the ConfigMap
hostoperation-approval. If you cannot, the API server refuses the approval.
- It reads the Host, its BMC paths, the boot assets and the TalosNodes that the plan names.
- It prints the plan: the machine, the BMC, each action in order, the media and the boot target. For an install, the plan also shows the node, its address and the disk that the install overwrites. If an annotation lifts a guard for the operation, the plan shows the annotation, its reason and the rule that it lifts. Refer to Lifted guards. If you proposed the operation, it says so. The record then names you as proposer and as approver.
- It asks
Approve as <user>? [y/N]. The question waits five minutes. - After a yes, it reads the operation again. The operation must be the same object, and the plan must read the same.
- It writes your user name into
spec.approval.approvedBy. The patch carries the UID and the resource version of the object that you saw. - The HostOperation controller starts the operation.
If the operation changed after the command showed the plan, nothing changes. Run the command again and read the new plan.
Lifted guards
Section titled “Lifted guards”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. |
metal.platform-kit.org/ignore-window |
The operation starts only in a MaintenanceWindow. |
pk-metal restore sets both on each operation that it proposes.
The plan shows each annotation that is set, in the section guards lifted for this operation. Each line names the person who lifted the guard, and the reason. A value that names nobody shows as lifted by nobody named.
If a person adds an annotation after the command showed the plan, the command does not approve. Run it again and read the new plan.
Several operations
Section titled “Several operations”Give several names to approve several operations, one after the other:
- The command shows the plan of the first operation and asks about it.
- It approves the operation after a yes. After a different answer, it does not change the operation.
- It continues with the next operation.
The command also continues when it cannot approve an operation, for example when the name is wrong.
It stops when it cannot ask: in a script without --yes, after five minutes without an answer, or after Ctrl-C.
It then shows no more plans and approves no more operations.
At the end, the command names each operation that it did not approve.
Without a terminal
Section titled “Without a terminal”In a script or a pipe, the command cannot ask. It prints the plan and refuses, unless you give --yes.
With --yes, the command does not read the operation a second time. The patch still fails if the object changed.
Examples
Section titled “Examples”List the operations that wait for approval.
pk-metal approve
OPERATION HOST WHY STEPS PROPOSED BY AGE
pk-metal/provision-simhw2288v5000397-1a2b3c4d simhw2288v5000397 Provisioning 6 system:serviceaccount:pk-metal:pk-metal 4m
pk-metal/reboot-w-1-x7k2p simhw2288v5000401 Reboot 5 alice 30s
Nothing was approved. Name the operations to see their plans and approve them, for example:
pk-metal approve pk-metal/provision-simhw2288v5000397-1a2b3c4d
Read the plan of an install and approve it. This machine has one virtual media slot.
pk-metal approve pk-metal/provision-simhw2288v5000397-1a2b3c4d
operation pk-metal/provision-simhw2288v5000397-1a2b3c4d
why: Provisioning
proposed by: system:serviceaccount:pk-metal:pk-metal
host simhw2288v5000397 (asset asset-07, serial SIMHW2288V5000397)
BMC: https://192.0.2.11 (endpoint asset-07)
steps, in this order:
1. eject whatever is mounted on virtual media slot CD
2. mount the Talos v1.14.6 installer with the machine config of TalosNode cp-1 built in (boot asset cp-1-embedded) on virtual media slot CD (content sha256:9f2c41d07ab3…)
3. boot from Cd at the next start only, in UEFI mode
4. power cycle: if the machine is on, force it off (no clean shutdown) and on again; if it is off, power it on
5. wait up to 30m for TalosNode cp-1 to report in at 10.0.0.11
6. eject whatever is mounted on virtual media slot CD
note: the installer on slot CD carries the machine config of TalosNode cp-1, with its keys and tokens. It is built for this node only, the BMC fetches it under a grant made for this boot, and it is ejected when the node reports in
boots TalosNode cp-1: address 10.0.0.11, role controlplane
installs Talos onto the disk that matches serial=SIMDISK000397; everything on that disk is overwritten
Approve as bob? [y/N] y
approved pk-metal/provision-simhw2288v5000397-1a2b3c4d as bob; the operator starts it now. Follow it with: pk-metal status
Approve two reboots. The command asks about each one.
pk-metal approve pk-metal/reboot-w-1-x7k2p pk-metal/reboot-w-2-q9r4sApprove in a script. The command prints the plan and does not ask.
pk-metal approve --yes provision-simhw2288v5000397-1a2b3c4dMessages
Section titled “Messages”| Message | Cause | What to do |
|---|---|---|
was proposed by you, this site forbids approving your own proposal |
You proposed the operation, for example with pk-metal reboot, and your site sets selfApproval: Forbidden. |
Ask a different person to approve it. |
the cluster refused the approval |
An admission policy refused the approval. The rest of the message is the rule. | Do what the message says. See Admission policies. |
the operator approves nothing |
You run the command as the operator service account. | Approve as a person with pk-metal-approver. |
is already approved by |
A person approved it before. | Follow it with pk-metal status. |
changed since its plan was shown |
The object or its plan changed while you read. | Run the command again and read the new plan. |
no answer within 5m |
The question got no answer in five minutes. | Run the command again. |
interrupted; nothing changed |
You pressed Ctrl-C at the question. | Run the command again when you are ready. |
operations not approved |
You gave several names, and the command did not approve some of them. The message names them. | Read the message of each one above. Run the command again for those that you want to approve. |
stdin is not a terminal |
The command cannot ask in a script. | Read the plan, then give --yes. |
no operation ... in namespace |
The name or the namespace is wrong. | Use the name that the message or pk-metal status shows. |
Objects
Section titled “Objects”| Object | Access | Purpose |
|---|---|---|
SelfSubjectReview |
create | Gets your user name from the API server. |
| HostOperation | get, list, patch | Reads the plan. Writes spec.approval.approvedBy. |
| Host, ManagementEndpoint | get | Shows the machine and its BMC paths in the plan. |
| BootAsset, TalosNode | get | Shows the media, the node, its address and its install disk. |
ConfigMap pk-metal/hostoperation-approval |
get, optional | Only for your own proposal: reads selfApproval. Without access, the API server decides. |
If you have no permission to read one of the last four kinds, the plan says that the object is not found.
Exit status
Section titled “Exit status”An answer other than y or yes gives code 1 and the message not approved; nothing changed.
With several names, the code is 1 if the command did not approve one or more of the operations.
Related
Section titled “Related”- Approval explains why a person approves each plan.
- Approval flow shows the full path from proposal to result.
- Approve, hold, retry and abort is the procedure.
- pk-metal rollout approves a TalosRollout, which covers the operations of all its nodes.
- pk-metal top approves with the key
a. - pk-metal abort stops an approved operation.