Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PXE boot support to k3s_agent role #409

Merged
merged 3 commits into from
Feb 6, 2024

Conversation

l50
Copy link
Contributor

@l50 l50 commented Dec 28, 2023

Huge fan of this project, thanks for creating and maintaining it!

I'm happy to submit another PR to implement PXE boot support for the server role,
but wanted to make sure there was interest in the existing work I've done first.

Proposed Changes

  • Introduced enhancements to the k3s_agent role to address a specific issue encountered while setting up a Raspberry Pi 4 for PXE booting. This includes adding checks for PXE-boot conditions and modifying the k3s.service.j2 template to dynamically set the native snapshotter, resolving issues related to "overlayfs" snapshotter incompatibilities in such setups.
  • Improved overall maintainability and readability of the k3s_agent role by adopting idiomatic Ansible practices. This involved restructuring tasks into logical blocks, implementing conditional task execution, and transitioning to Ansible builtin modules for future-proofing and better compatibility.

Context

While adding a new Raspberry Pi 4 to the cluster and setting it up to PXE boot from a Synology NAS, I encountered an error related to the "overlayfs" snapshotter. After some investigation, I realized that specifying the "native" snapshotter could resolve this. These changes are intended to help others who might face the same issue, streamlining their setup process and enhancing the usability of this project.

Checklist

  • Tested on two Raspberry Pi 4Bs: one configured to boot from an
    external SSD and the other set up for network booting (PXE) from a NAS.
  • Ran site.yml playbook
  • Ran reset.yml playbook
  • Did not add any unnecessary changes
  • Ran pre-commit install at least once before committing
  • 🚀

@l50 l50 changed the title Add PXE boot support to k3s_agent Add PXE boot support to k3s_agent role Dec 28, 2023
@timothystewart6
Copy link
Contributor

Looks like there are conflicts that need to be resolved

@timothystewart6
Copy link
Contributor

@l50 I've love to get this in if this is still valid. There are a few small conflicts with all the changes that need to be resolved first

@l50
Copy link
Contributor Author

l50 commented Feb 5, 2024

Apologies for the delay - conflict resolved.

@timothystewart6
Copy link
Contributor

No worries at all and no rush! I just wanted to ping you just to be sure this is something you wanted to be included. My fault that the PRs got backed logged, but all caught up now that CI is working.

**Added:**

- PXE Boot Check - Introduced tasks to check if the system is PXE-booted by
  analyzing `/proc/cmdline` in `roles/k3s_agent/tasks/main.yml`.
- Conditional Snapshotter in Template - Added logic in `k3s.service.j2` template
  to conditionally set `--snapshotter native` for PXE-booted systems.

**Changed:**

- `k3s.service.j2` Template Update - Modified the `ExecStart` line to include a
  conditional check for `is_pxe_booted` fact, dynamically setting the
  `--snapshotter` option for NFS-mounted systems.
- `main.yml` Task Modification - Added tasks to set `is_pxe_booted` fact based
  on the presence of `root=/dev/nfs` in the system's boot command line.

This update allows k3s agents on PXE-booted systems to use the native snapshotter
when running on NFS, addressing compatibility issues with OverlayFS.
**Added:**

- Structured HTTP Proxy Configuration Block - Added a structured block in
  `http_proxy.yml` for managing HTTP proxy settings, aligning with Ansible's
  recommended practices. This includes creating directories and deploying
  configuration files in a clear, modular fashion.
- Conditional Execution for Proxy Setup - Implemented conditional execution
  for the proxy setup in `http_proxy.yml`, utilizing `proxy_env` to adhere
  to Ansible's best practices for conditional tasks.
- Improved PXE-Boot System Check Block - Introduced a more structured approach
  in `main.yml` for checking PXE-booted systems, enhancing readability and
  maintainability.

**Changed:**

- Adopted Ansible Builtin Modules - Transitioned existing tasks to use
  `ansible.builtin` modules, ensuring compatibility and future-proofing the
  role.
- Refined Task Grouping - Reorganized tasks into logical blocks, improving
  the overall structure and readability, and showcasing Ansible's capabilities
  for efficient task management.
- Updated K3s Service Configuration - Modified the K3s service configuration
  task in `main.yml` for a more streamlined approach using Ansible's template
  module, reflecting community-driven best practices.

**Removed:**

- Streamlined Task Definitions - Optimized task definitions to reduce
  redundancy, focusing on clarity and adherence to the evolving Ansible
  community standards.
@l50
Copy link
Contributor Author

l50 commented Feb 6, 2024

Alright, finally had a minute to sit down and actually update everything. Hopefully this'll do it with the CI.

@timothystewart6
Copy link
Contributor

Thank you!

@timothystewart6 timothystewart6 merged commit e4146b4 into techno-tim:master Feb 6, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants