Skip to content

fix: download kubeconfig after nodes join the cluster - #413

Open
izerecord wants to merge 1 commit into
lablabs:mainfrom
izerecord:fix/download-kubeconfig-after-node-join
Open

fix: download kubeconfig after nodes join the cluster#413
izerecord wants to merge 1 commit into
lablabs:mainfrom
izerecord:fix/download-kubeconfig-after-node-join

Conversation

@izerecord

@izerecord izerecord commented Aug 27, 2026

Copy link
Copy Markdown

Description

When replacing the first server node I realized, that it's not working, because the task for extracting the kubeconfig is hard-wired to the first server node, runs too early and therefore fails.

Swapping the the two tasks seems, at least for me, the easiest fix. I don't know, if there is more refactoring needed, where the first node is potentially hard-wired with groups[rke2_servers_group_name].0.


tasks/main.yml fetched /etc/rancher/rke2/rke2.yaml from
groups[rke2_servers_group_name].0, before remaining_nodes.yml ran.
But that file only exists once that host's rke2-server has actually
started, which is true for a fresh bootstrap (first_server.yml) but
not when the node at index 0 is instead rejoining an existing cluster -
in that case 'remaining_nodes.yml' is what starts rke2-server on it, and
it runs after the kubeconfig fetch, so the fetch fails.

Move the kubeconfig download after "Prepare and join remaining nodes of
the cluster" so it runs once the index-0 host has a running rke2-server
regardless of which path (bootstrap or join) it took.

Type of change

  • [ x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Small minor change not affecting the Ansible Role code (GitHub Actions Workflow, Documentation etc.)

How Has This Been Tested?

I tested it with a running cluster, replacing the first server node, and with a fresh cluster, with rke2_api_ip set for kube-vip.


It is my first Pull Request on GitHub. Hopefully I did nothing wrong and provided all the information you need.

`tasks/main.yml` fetched `/etc/rancher/rke2/rke2.yaml` from
`groups[rke2_servers_group_name].0`, before `remaining_nodes.yml` ran.
But that file only exists once that host's rke2-server has actually
started, which is true for a fresh bootstrap (`first_server.yml`) but
not when the node at index 0 is instead rejoining an existing cluster -
in that case 'remaining_nodes.yml' is what starts rke2-server on it, and
it runs after the kubeconfig fetch, so the fetch fails.

Move the kubeconfig download after "Prepare and join remaining nodes of
the cluster" so it runs once the index-0 host has a running rke2-server
regardless of which path (bootstrap or join) it took.
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.

1 participant