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

Support generating single file for all nodes #344

Closed
budimanjojo opened this issue Feb 18, 2024 · 5 comments · Fixed by #346
Closed

Support generating single file for all nodes #344

budimanjojo opened this issue Feb 18, 2024 · 5 comments · Fixed by #346

Comments

@budimanjojo
Copy link
Owner

Currently, IP address of controlplane node is being appended to the generated talosconfig file.
And hostname of each node is being used to set the machine.network.hostname in the generated node config file.

There's a use case where you want to have one config file for all your nodes. I.e you're using DHCP server to manage the hostname of your nodes, and using PXE boot to load Talos into your nodes.
With combination of all your nodes being identical hardware wise, this is something that has been done by @onedr0p (https://github.com/onedr0p/home-ops/tree/cd103c4543cd177ca6e0d6ba06d4a420cef42834/kubernetes/main/bootstrap)

To support this use case, I'm thinking about adding overrideClientEndpoints (default to empty slice to not break current behavior) so you can provide your own endpoints in the generated talosconfig.
And then also adding per node ignoreHostname (default to false to not break current behavior) so there's no node specific key in the generated config file.

This will allow you to do something like this:

  • You want to create config file for a 6 nodes (3 controlplane nodes with IP of 1.1.1.1-1.1.1.3 and 3 worker nodes with IP of 1.1.1.4-1.1.1.6).
  • All of the nodes are of the same hardware specs.
  • The endpoint is a VIP of 1.1.1.10.

Your talconfig.yaml file should looks something like this:

---
clusterName: main
endpoint: https://1.1.1.10:6443
overrideClientEndpoints:
  - 1.1.1.1
  - 1.1.1.2
  - 1.1.1.3
nodes:
  - hostname: controlplane
    ipAddress: 1.1.1.1 # this is needed although not being used. you'll still use this to do other `talhelper` commands like `gencommand`
    controlPlane: true
    ignoreHostname: true
    ...
  - hostname: worker
    ipAddress: 1.1.1.4 # not needed like above
    controlPlane: false
    ignoreHostname: true

This will create a structure like this in the current working directory:

clusterconfig/
  - main-controlplane.yaml
  - main-worker.yaml
  - talosconfig

The talosconfig will look something like this:

context: main
contexts:
  main:
    endpoints:
      - 1.1.1.1
      - 1.1.1.2
      - 1.1.1.3
...

And there will be no machine.network.hostname field in the generated main-controlplane.yaml and main-worker.yaml.

You can then do talosctl apply-config command to all your nodes.

@budimanjojo budimanjojo changed the title Add overrideClientEndpoints and per node ignoreHostname Support generating single file for all nodes Feb 19, 2024
@budimanjojo
Copy link
Owner Author

Thanks to the suggestion from @onedr0p, the linked PR should fix this problem more beautifully.

You can now have something like this instead:

---
clusterName: main
endpoint: https://1.1.1.10:6443
nodes:
  - hostname: controlplane
    ipAddress: 1.1.1.1, 1.1.1.2, 1.1.1.3
    controlPlane: true
    ignoreHostname: true
    ...
  - hostname: worker
    ipAddress: 1.1.1.4, 1.1.1.5, 1.1.1.6
    controlPlane: false
    ignoreHostname: true

All the other talhelper subcommands are also updated to support this behavior, i.e:
talhelper gencommand apply -n controlplane will gives you all the commands like so:

talosctl apply-config --talosconfig=./clusterconfig/talosconfig --nodes=1.1.1.1 --file=./clusterconfig/main-controlplane.yaml
talosctl apply-config --talosconfig=./clusterconfig/talosconfig --nodes=1.1.1.2 --file=./clusterconfig/main-controlplane.yaml
talosctl apply-config --talosconfig=./clusterconfig/talosconfig --nodes=1.1.1.3 --file=./clusterconfig/main-controlplane.yaml

To get only the the specific command for the IP, use -n <IP> instead of -n <hostname>.

@onedr0p
Copy link

onedr0p commented Feb 19, 2024

One additional thing that would be nice is when generating the talosconfig file it puts the nodes in the file like this:

context: main
contexts:
    main:
        endpoints: # Controlplane nodes
            - 192.168.42.10
            - 192.168.42.11
            - 192.168.42.12
        nodes: # Controlplane and worker nodes with control plane nodes listed first
            - 192.168.42.10
            - 192.168.42.11
            - 192.168.42.12
            - 192.168.42.13
            - 192.168.42.14
            - 192.168.42.15

I am not sure if there is any downsides to adding in the nodes block though

@budimanjojo
Copy link
Owner Author

@onedr0p That seems to be unrelated to this issue, so I'll open another issue (or you want to open it instead?).

But, adding nodes to the talosconfig has been something I considered doing before but decided not to. Not sure what made me decided that but I did had a reason,

And funnily enough my own talosconfig has them configured too.

Also, why should the controlplane nodes be listed first?

@onedr0p
Copy link

onedr0p commented Feb 19, 2024

Also, why should the controlplane nodes be listed first?

Probably for predictability, you'll always know the first node in the list is a controller.

@budimanjojo
Copy link
Owner Author

The order should be the same as the order of the nodes slice in talconfig.yaml. So you can basically order it as you want.

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 a pull request may close this issue.

2 participants