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
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ runcmd:
- |
INSTALL_K3S_EXEC=""
TF_K3S_NODE_EXTERNAL_IP=${TF_K3S_NODE_EXTERNAL_IP}
TF_K3S_VERSION="${TF_K3S_VERSION}"
if [ -n "$TF_K3S_NODE_EXTERNAL_IP" ]; then
INSTALL_K3S_EXEC="--node-external-ip $TF_K3S_NODE_EXTERNAL_IP"
fi
curl -sfL https://get.k3s.io | K3S_URL=https://${TF_K3S_SERVER_IP_ADDRESS}:6443 K3S_TOKEN="${TF_K3S_TOKEN}" INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC" sh -
curl -sfL https://get.k3s.io | K3S_URL=https://${TF_K3S_SERVER_IP_ADDRESS}:6443 K3S_TOKEN="${TF_K3S_TOKEN}" INSTALL_K3S_VERSION="$TF_K3S_VERSION" INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC" sh -
- echo "Completed Installing K3S"
# - sudo chmod 644 /etc/rancher/k3s/k3s.yaml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ runcmd:
- |
TF_K3S_TLS_SAN=${TF_K3S_TLS_SAN}
TF_K3S_NODE_EXTERNAL_IP=${TF_K3S_NODE_EXTERNAL_IP}
TF_K3S_VERSION="${TF_K3S_VERSION}"
INSTALL_K3S_EXEC="server"
if [ -n "$TF_K3S_TLS_SAN" ]; then
INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC --tls-san $TF_K3S_TLS_SAN"
Expand All @@ -48,7 +49,7 @@ runcmd:
INTERNAL_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}')
INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC --node-external-ip $TF_K3S_NODE_EXTERNAL_IP --advertise-address $INTERNAL_IP"
fi
sudo curl -sfL https://get.k3s.io | K3S_TOKEN="${TF_K3S_TOKEN}" INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC" sh -
sudo curl -sfL https://get.k3s.io | K3S_TOKEN="${TF_K3S_TOKEN}" INSTALL_K3S_VERSION="$TF_K3S_VERSION" INSTALL_K3S_EXEC="$INSTALL_K3S_EXEC" sh -
- echo "Completed Installing K3S"
- sudo chmod 644 /etc/rancher/k3s/k3s.yaml

Expand Down
2 changes: 2 additions & 0 deletions terraform-modules/openstack-kubernetes-infra/compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ data "cloudinit_config" "init_docker" {
TF_K3S_TOKEN = random_password.k3s_token.result
TF_K3S_SERVER_IP_ADDRESS = openstack_compute_instance_v2.kubernetes_server.access_ip_v4
TF_K3S_NODE_EXTERNAL_IP = each.value.floating_ip != null && each.value.floating_ip.use_floating_ip ? each.value.floating_ip.address : ""
TF_K3S_VERSION = var.k3s_version != null ? var.k3s_version : ""
}
)
}
Expand All @@ -145,6 +146,7 @@ data "cloudinit_config" "init_docker_controller" {
TF_K3S_TOKEN = random_password.k3s_token.result
TF_K3S_TLS_SAN = local.controller_host_has_floating_ip ? local.controller_host.floating_ip.address : ""
TF_K3S_NODE_EXTERNAL_IP = local.controller_host_has_floating_ip ? local.controller_host.floating_ip.address : ""
TF_K3S_VERSION = var.k3s_version != null ? var.k3s_version : ""
}
)
}
Expand Down
7 changes: 7 additions & 0 deletions terraform-modules/openstack-kubernetes-infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ variable "ubuntu_immage_name" {
description = "Name of an available Machine Image running ubuntu in the openstack environment"
}

variable "k3s_version" {
type = string
default = null
nullable = true
description = "Optional k3s version to install (INSTALL_K3S_VERSION), for example v1.32.2+k3s1. When unset, the installer downloads from the stable channel."
}

variable "host_instances" {
description = <<EOT
Hosts to Create:
Expand Down
Loading