Fix certificate validation when api_endpoint differs from hostname#434
Conversation
|
Several things:
Your problem is solved just by setting the |
- Auto-add --tls-san={{ api_endpoint }} when it differs from ansible_hostname
- Prevents 'x509: certificate is valid for hostname, not FQDN' errors
- Ensures first server generates certificate with all required SANs
- Maintains backward compatibility with existing configurations
- Fixes HA cluster bootstrap issues when using FQDNs in inventory
Closes certificate validation failures in multi-server setups where
api_endpoint (FQDN) differs from the detected hostname.
Signed-off-by: Guillaume Andre <mail@guillaumea.fr>
| # Auto-computed TLS SANs to prevent certificate validation issues | ||
| _computed_tls_sans: "{% if api_endpoint is defined and api_endpoint != ansible_hostname %}--tls-san={{ api_endpoint }}{% endif %}" | ||
| _final_server_args: "{{ extra_server_args }} {{ _computed_tls_sans }}" |
There was a problem hiding this comment.
Move the logic out of these files, we specifically want these to be very simple default files.
Signed-off-by: Guillaume Andre <mail@guillaumea.fr>
Signed-off-by: Guillaume Andre <mail@guillaumea.fr>
|
Thank you for your feedback and sorry, I had forgotten to push changes. I moved the TLS SAN logic from defaults to tasks using The code also validates that |
dereknola
left a comment
There was a problem hiding this comment.
Looks good but I want to separate this new tls-san argument from the existing extra_args. No need to handle injecting the extra_args when we don't have to.
|
I will wait on merging #442 till after this PR is merged (no need to make you deal with my merge conflict :) |
Applied suggestion from @dereknola Co-authored-by: Derek Nola <derek.nola@suse.com> Signed-off-by: Guillaume A <mail@guillaumea.fr>
Applied suggestion from @dereknola Co-authored-by: Derek Nola <derek.nola@suse.com> Signed-off-by: Guillaume A <mail@guillaumea.fr>
feat: implement chart validation
Fixes certificate validation failures in multi-server setups where api_endpoint (FQDN) differs from the detected hostname
Problem
When using FQDNs in inventory (e.g.,
server1.example.com), k3s HA clusters fail to bootstrap because:ansible_hostname(e.g.,server1)api_endpoint(e.g.,server1.example.com)x509: certificate is valid for server1, not server1.example.comThis occurs when:
api_endpointresolves to a different name than the detected hostnameSolution
Automatically add
--tls-san={{ api_endpoint }}to k3s server arguments whenapi_endpointdiffers fromansible_hostname.Changes
roles/k3s_server/defaults/main.yml: Add computed TLS SAN logicroles/k3s_server/templates/*.service.j2: Use computed server argsLogic
Testing
Verified with:
server1.example.com→ adds--tls-san=server1.example.com)server1→ no additional SAN needed)