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

feat(talos): Allow users to include talhelper patches #1320

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

wasurerarenai
Copy link
Contributor

Talhelper allows us to include external patch files outside of the main talconfig.yaml. We can use this feature to allow the user to create patches that can be maintained separately from the template generated talconfig. This can be used similarly to this PR for talos specific overrides.

When enabling distribution.talos.user_patches the includes for the following files are added to the generated talconfig.yaml. These patches are applied to the talconfig file's sections of the same name.

  • kubernetes/talos/patches/controlPlane.yaml
  • kubernetes/talos/patches/global.yaml
  • kubernetes/talos/patches/node_name.yaml (name from nodes.inventory.[].name)
  • kubernetes/talos/patches/worker.yaml

I haven't figured out how to get makejinja (or similar like ansible/go-task) to optionally generate these as empty files if they don't already exist. The goal is to not stomp these files each time we update our local repo with the latest changes from the template repo. These are particularly useful for nodes that have specific differences from the global defaults due to different worker hardware, existance as a virtual machine, or similar.

@github-actions github-actions bot added the area/bootstrap Changes made in the bootstrap directory label Feb 14, 2024
@onedr0p
Copy link
Owner

onedr0p commented Feb 14, 2024

Looks like the CI is not happy with the worker patches.

@wasurerarenai
Copy link
Contributor Author

Added the missing logic check. This is one way we can do this with regards to @wouterbouvy's earlier patch. This only generates the "worker.patches" node if the user_patches option is now enabled.

The other option would be separating the logic checks which when user_patches is not enabled would generate an "empty" worker.patches block which doesn't affect talhelper's genconfig run, but looks messier. This however isolates the user_patches check.

Other option looks like:

{% if nodes.inventory | selectattr('controller', 'equalto', False) | list | length %}
worker:
  patches:
    {% if distribution.talos.user_patches %}
    # User specified worker patches
    - "@./patches/worker.yaml"
    {% endif %}
{% endif %}

Either way, I'd prefer it if other code in the template knew how to generate the empty patch files like running mkdir kubernetes/talos/patches && touch kubernetes/talos/patches/{controlPlane,global,worker,node_name}.yaml does. We could separate out the different patch blocks with more config.yaml, but I was afraid of adding too much more cruft...

distribution:
  type: talos
  talos:
    user_patches:
      global: true
      controlPanel: true
      worker: true
      node: true

@onedr0p onedr0p merged commit 025f5dd into onedr0p:main Feb 15, 2024
4 checks passed
@onedr0p
Copy link
Owner

onedr0p commented Feb 15, 2024

I think you current change here is good, thanks!

@wasurerarenai wasurerarenai deleted the talhelper-patches branch February 16, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bootstrap Changes made in the bootstrap directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants