Skip to content

Conversation

@ksuderman
Copy link
Collaborator

This replaces PR #48

The certificates that are generated for the kubeconfig file are only valid for for localhost (127.0.0.1) and cannot be downloaded and used from a remote machine. This PR adds two things to address this problem:

  1. Adds {{ ansible_ssh_host }} to the tls-san section of the rke_config.j2 template so that the certificates generated are also valid for the instance's public IP address, and
  2. Adds a new playbook (fetch.yml) that can be used to download a copy of the kubeconfig (/etc/rancher/rke2/rke2.yaml) and save it locally so it can be used to manage the cluster with kubectl and helm commands.

This PR has not been tested yet.

Copy link
Contributor

@nuwang nuwang left a comment

Choose a reason for hiding this comment

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

Also, perhaps we could rename fetch.yml to fetch_kube_config.yml?

lineinfile:
path: "{{ temp_file }}"
regexp: 'server: https://127\.0\.0\.1:6443'
line: " server: https://{{ ansible_ssh_host }}:6443"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can cluster_hostname be used for this instead of ansible_ssh_host? If I recall correctly, cluster_hostname defaults to ansible_ssh_host if it's not specified.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can test it, but I want the kubeconfig to be valid for the public IP address not just the hostname.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, in which case you can specify the ip for cluster_hostname, which is what happens by default.

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.

2 participants