Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

baremetal: integrate automated (re-)provisioning logic #1502

Merged
merged 3 commits into from
Jun 22, 2021

Conversation

pothos
Copy link
Member

@pothos pothos commented Jun 17, 2021

  • baremetal: introduce CLC snippets for the installer
    The installer OS needs to be able to get its network configuration as
    CLC snippet if DHCP is not used.

    Add CLC snippets for the installer and migrate the matchbox-specific
    CLC template to the normal CLC template which is needed for CLC
    snippets. The request template variable is replaced by the actually
    used "mac" parameter.

  • baremetal: use ignition.config.url kernel parameter
    The Ignition configuration currently gets written out only once to the
    OEM partition and any updates to it in the matchbox store are not
    propagated to the node's Ignition environment when Ignition is forced
    to run again.

    Use the Ignition kernel parameter to point the node's Ignition
    environment directly to matchbox where the userdata lies.

  • baremetal: integrate automated (re-)provisioning logic
    The bare-metal platform currently lacks any understanding of whether an
    instance is actually running the configuration that lokoctl put into
    matchbox, because, when the configuration was updated, there is no
    notification to the user that PXE booting has to be done again for this
    instance.
    Also, it is not clear to the user when to boot from PXE because the PXE
    boot must happen after lokoctl populated matchbox with the (new)
    configuration but before any other steps time out.
    The goal of this patch is to bring the baremetal platform to an
    actually usable level and support automated provisioning and
    reprovisioning, in a configurable way regardless if IPMI is used or VMs
    are created. In addition, we don't want to require a complicated PXE
    boot for each configuration update because it is slow, fragile and
    needs a special DHCP infrastructure which may be lacking in a
    production environment.

    Add user-defined commands in the "pxe_commands" variable to perform
    automated PXE provisioning at the right time, i.e. initally at the
    first run or when recreating a node.
    To address the problem that PXE booting is a long and maybe even manual
    process, or even impossible at production side, we can rely on Ignition
    to simulate reprovisioning by creating the "first_boot" flag file via
    SSH and issuing a reboot, which makes Ignition fetch the configuration
    from matchbox, and if we make sure to clean the root filesystem by
    formatting it, the result is the same as if reprovisioned was done with
    a PXE boot.
    The logic is achieved by a "null resource" in Terraform that executes a
    helper script which either does a PXE boot or uses SSH to trigger a
    reprovisioning with Ignition. It also handles the case of ignoring
    userdata changes for controller nodes to prevent losing etcd state.
    Since there is no notion of a baremetal node on the Terraform level
    (reminder: all this exercise here is done because we don't have a
    Terraform provider doing this for us) a local flag file is created
    under the asset directory on the machine which runs lokoctl. If it
    exists, the node was provisioned with PXE and SSH will be used for
    reprovisioning, if it does not exist, it will be provisioned with PXE
    during inital setup and for the next reprovisioning because the user
    forced recreating the node by deleting the flag file.
    Another flag file on the node is used to check whether a node was
    successfully reprovisioned.
    When SSH is used to reprovision, the kernel parameters for GRUB are
    updated directly because they are not part of the Ignition
    configuration.
    The "copy-controller-secrets" step is run after recreating a controller
    node, again since there is no notion of a node object this is solved by
    depending on the variables itself which define the node state.
    Also add user-defined commands in the "install_pre_reboot_cmds"
    variable to run after the PXE OS installation and before booting into
    the final OS, needed to set up persistent booting from disk after the
    PXE booting was configured in "pxe_commands".
    The whole patch is used by Racker (https://github.com/kinvolk/racker),
    and can be tested either with the "bootstrap/prepare.sh" script to
    create VMs with lokoctl or by running Racker in the QEMU IPMI simulator
    environment through the "racker-sim/ipmi-env.sh" script and a Racker
    Docker image built with "installer/conf.yaml" pointing to this
    Lokomotive branch.

@pothos pothos requested a review from ipochi June 17, 2021 17:28
@pothos pothos force-pushed the kai/bare-metal-reprovisioning branch 3 times, most recently from 745cdfd to ba98bc5 Compare June 17, 2021 18:45
@pothos pothos force-pushed the kai/bare-metal-reprovisioning branch 2 times, most recently from ff32e74 to 69a44ff Compare June 18, 2021 13:58
pothos added a commit to kinvolk/racker that referenced this pull request Jun 18, 2021
TODO: switch to "master" once kinvolk/lokomotive#1502 is merged.

Users should follow the update guides under when updating from Racker 0.1:
  https://github.com/kinvolk/lokomotive/releases/tag/v0.7.0
  https://github.com/kinvolk/lokomotive/releases/tag/v0.8.0
and add `wipe_additional_disks = true` to their baremetal.lokocfg file.
pothos added 2 commits June 22, 2021 14:07
The installer OS needs to be able to get its network configuration as
CLC snippet if DHCP is not used.

Add CLC snippets for the installer and migrate the matchbox-specific
CLC template to the normal CLC template which is needed for CLC
snippets. The request template variable is replaced by the actually
used "mac" parameter.
The Ignition configuration currently gets written out only once to the
OEM partition and any updates to it in the matchbox store are not
propagated to the node's Ignition environment when Ignition is forced
to run again.

Use the Ignition kernel parameter to point the node's Ignition
environment directly to matchbox where the userdata lies.
ipochi
ipochi previously approved these changes Jun 22, 2021
Copy link
Member

@ipochi ipochi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can provide some more explanation that would be easy for others to review.

@pothos pothos force-pushed the kai/bare-metal-reprovisioning branch from 69a44ff to 3f11380 Compare June 22, 2021 12:26
@pothos pothos requested a review from ipochi June 22, 2021 12:28
@pothos pothos force-pushed the kai/bare-metal-reprovisioning branch from 3f11380 to faba3ce Compare June 22, 2021 13:19
The bare-metal platform currently lacks any understanding of whether an
instance is actually running the configuration that lokoctl put into
matchbox, because, when the configuration was updated, there is no
notification to the user that PXE booting has to be done again for this
instance.
Also, it is not clear to the user when to boot from PXE because the PXE
boot must happen after lokoctl populated matchbox with the (new)
configuration but before any other steps time out.
The goal of this patch is to bring the baremetal platform to an
actually usable level and support automated provisioning and
reprovisioning, in a configurable way regardless if IPMI is used or VMs
are created. In addition, we don't want to require a complicated PXE
boot for each configuration update because it is slow, fragile and
needs a special DHCP infrastructure which may be lacking in a
production environment.

Add user-defined commands in the "pxe_commands" variable to perform
automated PXE provisioning at the right time, i.e. initally at the
first run or when recreating a node.
To address the problem that PXE booting is a long and maybe even manual
process, or even impossible at production side, we can rely on Ignition
to simulate reprovisioning by creating the "first_boot" flag file via
SSH and issuing a reboot, which makes Ignition fetch the configuration
from matchbox, and if we make sure to clean the root filesystem by
formatting it, the result is the same as if reprovisioned was done with
a PXE boot.
The logic is achieved by a "null resource" in Terraform that executes a
helper script which either does a PXE boot or uses SSH to trigger a
reprovisioning with Ignition. It also handles the case of ignoring
userdata changes for controller nodes to prevent losing etcd state.
Since there is no notion of a baremetal node on the Terraform level
(reminder: all this exercise here is done because we don't have a
Terraform provider doing this for us) a local flag file is created
under the asset directory on the machine which runs lokoctl. If it
exists, the node was provisioned with PXE and SSH will be used for
reprovisioning, if it does not exist, it will be provisioned with PXE
during inital setup and for the next reprovisioning because the user
forced recreating the node by deleting the flag file.
Another flag file on the node is used to check whether a node was
successfully reprovisioned.
When SSH is used to reprovision, the kernel parameters for GRUB are
updated directly because they are not part of the Ignition
configuration.
The "copy-controller-secrets" step is run after recreating a controller
node, again since there is no notion of a node object this is solved by
depending on the variables itself which define the node state.
Also add user-defined commands in the "install_pre_reboot_cmds"
variable to run after the PXE OS installation and before booting into
the final OS, needed to set up persistent booting from disk after the
PXE booting was configured in "pxe_commands".
The whole patch is used by Racker (https://github.com/kinvolk/racker),
and can be tested either with the "bootstrap/prepare.sh" script to
create VMs with lokoctl or by running Racker in the QEMU IPMI simulator
environment through the "racker-sim/ipmi-env.sh" script and a Racker
Docker image built with "installer/conf.yaml" pointing to this
Lokomotive branch.
@pothos pothos force-pushed the kai/bare-metal-reprovisioning branch from faba3ce to bbb13a6 Compare June 22, 2021 13:21
Copy link
Member

@ipochi ipochi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pothos pothos merged commit b0da2a1 into master Jun 22, 2021
@pothos pothos deleted the kai/bare-metal-reprovisioning branch June 22, 2021 14:14
@invidian invidian added kind/enhancement New feature or request platform/bare-metal Bare-metal-related labels Jul 16, 2021
@invidian invidian added this to the v0.9.0 milestone Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/enhancement New feature or request platform/bare-metal Bare-metal-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants