Skip to content

Command · pk-metal

pk-metal pivot

changes machinesneeds the cluster

pk-metal pivot moves the operator from the cluster that it runs in to a different cluster. The usual case: the operator ran in a kind cluster and installed a Talos cluster. Now it moves onto that Talos cluster.

Nothing on the machines changes. The operator in the source cluster stops, and its objects stay there.

pk-metal pivot --to <kubeconfig> [--to-context name] [--yes] [flags]

The command takes no arguments. The Global flags select the source cluster. --to selects the target cluster.

FlagDefaultDescription
--force-waitingfalseMove operations that wait for approval; they wait on the new cluster instead.
--image<string>-Manager image on the new cluster (default: the image the operator runs now).
--media-store<string>copyWhat the media store becomes on the new cluster: copy (a claim made there from its StorageClass, or the one already there) or ephemeral (an emptyDir: no installer for a one-slot BMC is built there).
--media-url<string>-Address the BMCs fetch boot media from on the new cluster, for example https://<node address>:30443 (default: the current one).
--settle<duration>1m30sHow long to watch the new operator for operations it must not propose.
--timeout<duration>5m0sHow long to wait for each step.
--to<string>required-Kubeconfig file of the cluster to move to.
--to-context<string>-Context in the --to kubeconfig (default: its current context).
--yesfalseMove without asking (for scripts); the checks are still printed.

This command also accepts the global flags --kubeconfig and --context.

The steps have the names of the steps in Pivot the operator.

  1. Preflight. No operation runs or waits for approval, and the target cluster runs no operator. The command prints what the target cluster must reach, and asks Move? [y/N].
  2. Pause. It sets the operator in the source cluster to zero replicas and waits until it stops.
  3. Install. It installs the operator in the target cluster: CRDs, admission policies, RBAC, the namespace and the claim for the media store.
  4. Copy. It copies the objects of the operator with their status, and the Secrets in the namespace pk-metal.
  5. Start. It starts the operator in the target cluster.
  6. Settle. For the time of --settle, it makes sure that the new operator proposes no new operation.

The command cannot test the network. Before you answer, make sure that the target cluster can reach the BMCs, the Talos API and the media service.

If the command fails, run it again. It continues where it stopped.

The media store holds the installers for BMCs with one virtual media slot. Its files do not move. The new operator builds the installers again.

--media-store=copy
The default. The target cluster needs the claim, or a default StorageClass to make it. Without storage, the command refuses.
--media-store=ephemeral
The operator mounts an emptyDir. It starts empty, and each restart deletes it. The operator builds no installer for a one-slot BMC until the claim exists.

The check refuses when an operation waits for approval. With --force-waiting, the command moves such operations, and they wait in the target cluster.

pk-metal pivot
pk-metal --context kind-pk-metal pivot --to mgmt.kubeconfig
pk-metal pivot: move the operator from kind-pk-metal to admin@lab

From admin@lab, the operator must reach (pivot cannot test this):
  ...

The operator on kind-pk-metal stops now. No machine is touched.
Move? [y/N] y
  paused the manager on kind-pk-metal
  installed 17 CRDs
  installed the operator in namespace pk-metal (Deployment pk-metal-manager at 0 replicas)
  started the manager on admin@lab (1 replica)
  the manager on admin@lab settled: no new operation in 1m30s

The operator runs on admin@lab now.

To move back, run the command from the new cluster with --to set to the kubeconfig of the old cluster.

Terminal window
pk-metal --kubeconfig mgmt.kubeconfig pivot --to kind.kubeconfig
Object Source cluster Target cluster
Deployment of the operator Set to zero replicas. Made, then started.
CRDs, admission policies, RBAC, namespace Read. Made.
All kinds of the operator, for example Host, HostClaim, HostOperation and TalosCluster Read. They stay. Made, with their status.
Secrets in pk-metal Read. Made.
PersistentVolumeClaim of the media store Not moved. Made empty, or an emptyDir.

If the target cluster holds an older copy of the objects, the command removes the objects that the source cluster no longer has.

  • An approval is set again by its approver, and a guard lift by the person that it names. The command impersonates them.
  • The command writes an object as the person that its metal.platform-kit.org/requested-by names. Such an object without the annotation gets pk-metal-pivot, and the command writes it as that user. See Admission policies › Requested by.

The command writes audit lines to standard error, in the format of the operator. They name you as the user who ran the move:

  • An approved or guard.lifted line with "replayed":true and replayedBy for each approval and guard lift that it sets again. A replayed line is a copy of a decision. The original line is in the logs of the source cluster.
  • A deleted line with the reason PivotPruned for each object that it removes from the target cluster.

The operator in the target cluster does not write these lines. Keep the standard error of the command with your audit logs:

Terminal window
pk-metal pivot --to mgmt.kubeconfig 2> >(tee -a pivot-audit.jsonl >&2)
CodeMeaning
0Success.
1Error; the message is on stderr, as "pk-metal: <message>".

An answer other than y or yes gives code 1. Nothing changed.