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

nixos/k3s: add autoDeployCharts option and use systemd-tmpfiles for content activation #374017

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rorosen
Copy link
Contributor

@rorosen rorosen commented Jan 15, 2025

Things done

The autoDeployCharts option further improves the auto deploying
capabilities of the k3s module by allowing to deploy and configure Helm charts
that are then instaled via the k3s Helm controller. Although this was
also previously possible by using auto deploying manifests, it required
some knowledge of the k3s Helm controller and led to a lot of
boilerplate code.

In the process I noticed how messy and fragile the activateK3sContent script was. Therefore a second commit replaces the script with systemd-tmpfiles.

Building the script got fairly messy and it had some footguns like
forgetting to create parent directories before linking or silent
overriding of existing links.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@NixOS/k3s


Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: k3s Kubernates distribution (https://k3s.io/) 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jan 15, 2025
@rorosen rorosen force-pushed the k3s-auto-deploy-helm branch 3 times, most recently from 9f680c6 to 5ffa146 Compare January 15, 2025 11:22
@@ -361,6 +361,8 @@
- The paperless module now has an option for regular automatic export of
documents data using the integrated document exporter.

- `services.k3s` now provides the [](#opt-services.k3s.autoDeployCharts) option that allows to automatically deploy Helm charts via the k3s Helm controller.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `services.k3s` now provides the [](#opt-services.k3s.autoDeployCharts) option that allows to automatically deploy Helm charts via the k3s Helm controller.
- `services.k3s` now provides the [](#opt-services.k3s.autoDeployCharts) option that allows to automatically deploy Helm charts via the k3s Helm controller.

[] is empty. Rendering is:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh true, now that you say it I'm not even sure that this kind of option referencing works outside of option descriptions. I changed it to autoDeployCharts for now.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/declaring-k3s-with-helm-and-cluster/56787/9

@rorosen rorosen force-pushed the k3s-auto-deploy-helm branch 2 times, most recently from 5ab580e to 2e1b724 Compare January 20, 2025 08:53
@rorosen
Copy link
Contributor Author

rorosen commented Jan 20, 2025

@ofborg test k3s.auto-deploy-charts.k3s_1_29
@ofborg test k3s.auto-deploy-charts.k3s_1_30
@ofborg test k3s.auto-deploy-charts.k3s_1_31
@ofborg test k3s.auto-deploy-charts.k3s_1_32

The `autoDeployCharts` option further improves the auto deploying
capabilities of the k3s module by allowing to deploy and configure Helm charts
that are then instaled via the k3s Helm controller. Although this was
also previously possible by using auto deploying manifests, it required
some knowledge of the k3s Helm controller and led to a lot of
boilerplate code.
Formerly a `ExecStartPre` script was used to link k3s content.
Building the script got fairly messy and it had some footguns like
forgetting to create parent directories before linking or silent
overriding of existing links.
@rorosen rorosen force-pushed the k3s-auto-deploy-helm branch from 2e1b724 to 52444bd Compare January 20, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants