Skip to content

Commit

Permalink
Merge pull request #1395 from kranich/configurable-kubeconfig_server_…
Browse files Browse the repository at this point in the history
…address

Make kubeconfig_server_address configurable
  • Loading branch information
mysticaltech authored Jul 3, 2024
2 parents eb39273 + 943f733 commit 730d4c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions kube.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,11 @@ module "kube-hetzner" {
# In which case, you need to define that hostname in the k3s TLS-SANs config to allow connection through it. It can be hostnames or IP addresses.
# additional_tls_sans = ["cp.cluster.my.org"]

# If you create a hostname with multiple A records pointing to all of your
# control-plane nodes ips, you may want to use that hostname in the generated
# kubeconfig.
# kubeconfig_server_address = "cp.cluster.my.org"

# lb_hostname Configuration:
#
# Purpose:
Expand Down
4 changes: 2 additions & 2 deletions kubeconfig.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ data "remote_file" "kubeconfig" {
}

locals {
kubeconfig_server_address = var.use_control_plane_lb ? hcloud_load_balancer.control_plane.*.ipv4[0] : (
kubeconfig_server_address = var.kubeconfig_server_address != "" ? var.kubeconfig_server_address : (var.use_control_plane_lb ? hcloud_load_balancer.control_plane.*.ipv4[0] : (
can(module.control_planes[keys(module.control_planes)[0]].ipv4_address) ? module.control_planes[keys(module.control_planes)[0]].ipv4_address : "unknown"
)
))
kubeconfig_external = replace(replace(data.remote_file.kubeconfig.content, "127.0.0.1", local.kubeconfig_server_address), "default", var.cluster_name)
kubeconfig_parsed = yamldecode(local.kubeconfig_external)
kubeconfig_data = {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,12 @@ variable "lb_hostname" {
}
}

variable "kubeconfig_server_address" {
type = string
default = ""
description = "The hostname used for kubeconfig."
}

variable "rancher_registration_manifest_url" {
type = string
description = "The url of a rancher registration manifest to apply. (see https://rancher.com/docs/rancher/v2.6/en/cluster-provisioning/registered-clusters/)."
Expand Down

0 comments on commit 730d4c0

Please sign in to comment.