Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions pkg/blueprint/templates/default.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ local extractBaseUrl(endpoint) =
local endpoint = if std.objectHas(context.cluster, "endpoint") then context.cluster.endpoint else if firstNode != null then firstNode.endpoint else "";
local baseUrl = extractBaseUrl(endpoint);

// Build certSANs list
local certSANs = ["localhost", baseUrl] + (if std.objectHas(context.cluster, "controlplanes") && std.objectHas(context.cluster.controlplanes, "nodes") && std.length(std.objectValues(context.cluster.controlplanes.nodes)) > 0 then
local firstNode = std.objectValues(context.cluster.controlplanes.nodes)[0];
local hostname = firstNode.hostname;
local domain = if std.objectHas(context, "dns") && std.objectHas(context.dns, "domain") then context.dns.domain else "";
[hostname] + (if domain != "" then [hostname + "." + domain] else [])
else []);

// Build the mirrors dynamically, only if registries are defined
local registryMirrors = if std.objectHas(context, "docker") && std.objectHas(context.docker, "registries") then
std.foldl(
Expand Down Expand Up @@ -125,10 +133,7 @@ local terraformConfig = if platform == "local" || platform == "metal" then [
{
cluster: {
apiServer: {
certSANs: [
"localhost",
baseUrl,
],
certSANs: certSANs,
},
extraManifests: [
// renovate: datasource=github-releases depName=kubelet-serving-cert-approver package=alex1989hu/kubelet-serving-cert-approver
Expand All @@ -140,10 +145,7 @@ local terraformConfig = if platform == "local" || platform == "metal" then [
// Merge in the base `machine` config
{
machine: {
certSANs: [
"localhost",
baseUrl,
],
certSANs: certSANs,
network: if vmDriver == "docker-desktop" then {
interfaces: [
{
Expand Down
12 changes: 10 additions & 2 deletions pkg/services/talos_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func (s *TalosService) SetAddress(address string) error {
nodeType = "controlplanes"
}

if err := s.configHandler.SetContextValue(fmt.Sprintf("cluster.%s.nodes.%s.hostname", nodeType, s.name), s.name); err != nil {
if err := s.configHandler.SetContextValue(fmt.Sprintf("cluster.%s.nodes.%s.hostname", nodeType, s.name), s.GetHostname()); err != nil {
return err
}
if err := s.configHandler.SetContextValue(fmt.Sprintf("cluster.%s.nodes.%s.node", nodeType, s.name), s.name); err != nil {
if err := s.configHandler.SetContextValue(fmt.Sprintf("cluster.%s.nodes.%s.node", nodeType, s.name), s.GetHostname()); err != nil {
return err
}

Expand Down Expand Up @@ -310,6 +310,14 @@ func (s *TalosService) GetComposeConfig() (*types.Config, error) {
// Private Methods
// =============================================================================

// GetHostname returns the hostname without any TLD
func (s *TalosService) GetHostname() string {
if parts := strings.Split(s.name, "."); len(parts) > 1 {
return parts[0]
}
return s.name
}

// validateHostPort parses and validates a host port string in the format "hostPort:nodePort/protocol"
// Returns the parsed hostPort, nodePort, and protocol, or an error if validation fails
func validateHostPort(hostPortStr string) (uint32, uint32, string, error) {
Expand Down
Loading