From 311e02aea88f5df59fd7a74c76a79583b4742631 Mon Sep 17 00:00:00 2001 From: Philip Schmid Date: Mon, 12 Feb 2024 11:10:12 +0100 Subject: [PATCH] Added architecture selection support * Added support to select the instance architecture * Bumped default Talos version from 1.5.3 to 1.6.1 * Bumped Cilium version inside the example CuTE from 1.14.3 to 1.14.6 Signed-off-by: Philip Schmid --- 00-locals.tf | 8 +++++++- 00-variables.tf | 15 +++++++++++++-- README.md | 5 +++-- example/00-variables.tf | 12 +++++++++--- example/02-talos.tf | 13 +++++++------ example/README.md | 7 ++++--- 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/00-locals.tf b/00-locals.tf index bdaf9c0..05f6099 100644 --- a/00-locals.tf +++ b/00-locals.tf @@ -1,7 +1,12 @@ data "aws_ami" "talos" { owners = ["540036508848"] # Sidero Labs most_recent = true - name_regex = "^talos-${var.talos_version}-.*-amd64$" + name_regex = "^talos-${var.talos_version}-.*-${var.cluster_architecture}$" + + filter { + name = "architecture" + values = [local.instance_architecture] + } } resource "random_string" "workspace_id" { @@ -13,6 +18,7 @@ resource "random_string" "workspace_id" { locals { + instance_architecture = var.cluster_architecture == "amd64" ? "x86_64" : var.cluster_architecture path_to_workspace_dir = "${abspath(path.root)}/.terraform/.workspace-${random_string.workspace_id.id}" path_to_kubeconfig_file = "${local.path_to_workspace_dir}/kubeconfig" path_to_talosconfig_file = "${local.path_to_workspace_dir}/talosconfig" diff --git a/00-variables.tf b/00-variables.tf index 691779c..f7a84ca 100644 --- a/00-variables.tf +++ b/00-variables.tf @@ -9,6 +9,17 @@ variable "cluster_id" { type = number } +variable "cluster_architecture" { + description = "Cluster architecture. Choose 'arm64' or 'amd64'. If you choose 'arm64', ensure to also override the control_plane.instance_type and worker_groups.instance_type with an ARM64-based instance type like 'm7g.large'." + type = string + default = "amd64" + + validation { + condition = can(regex("^a(rm|md)64$", var.cluster_architecture)) + error_message = "The cluster_architecture value must be a valid architecture. Allowed values are 'arm64' and 'amd64'." + } +} + variable "region" { description = "The region in which to create the Talos Linux cluster." type = string @@ -52,7 +63,7 @@ variable "allow_workload_on_cp_nodes" { variable "talos_version" { description = "Talos version to use for the cluster, if not set, the newest Talos version. Check https://github.com/siderolabs/talos/releases for available releases." type = string - default = "v1.5.3" + default = "v1.6.1" validation { condition = can(regex("^v\\d+\\.\\d+\\.\\d+$", var.talos_version)) @@ -61,7 +72,7 @@ variable "talos_version" { } variable "kubernetes_version" { - description = "Kubernetes version to use for the Talos cluster, if not set, the K8s version shipped with the selected Talos version will be used. Check https://www.talos.dev/v1.5/introduction/support-matrix/. For example '1.27.3'." + description = "Kubernetes version to use for the Talos cluster, if not set, the K8s version shipped with the selected Talos version will be used. Check https://www.talos.dev/v1.5/introduction/support-matrix/. For example '1.27.6'." type = string default = "" diff --git a/README.md b/README.md index eff4d57..c22dd26 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ module "talos" { |------|-------------|------|---------|:--------:| | [allocate\_node\_cidrs](#input\_allocate\_node\_cidrs) | Whether to assign PodCIDRs to Node resources or not. Only needed in case Cilium runs in 'kubernetes' IPAM mode. | `bool` | `true` | no | | [allow\_workload\_on\_cp\_nodes](#input\_allow\_workload\_on\_cp\_nodes) | Allow workloads on CP nodes or not. Allowing it means Talos Linux default taints are removed from CP nodes. More details here: https://www.talos.dev/v1.5/talos-guides/howto/workers-on-controlplane/ | `bool` | `false` | no | +| [cluster\_architecture](#input\_cluster\_architecture) | Cluster architecture. Choose 'arm64' or 'amd64'. If you choose 'arm64', ensure to also override the control\_plane.instance\_type and worker\_groups.instance\_type with an ARM64-based instance type like 'm7g.large'. | `string` | `"amd64"` | no | | [cluster\_id](#input\_cluster\_id) | The ID of the cluster. | `number` | `"1"` | no | | [cluster\_name](#input\_cluster\_name) | Name of cluster | `string` | n/a | yes | | [config\_patch\_files](#input\_config\_patch\_files) | Path to talos config path files that applies to all nodes | `list(string)` | `[]` | no | @@ -99,13 +100,13 @@ module "talos" { | [controlplane\_count](#input\_controlplane\_count) | Defines how many controlplane nodes are deployed in the cluster. | `number` | `3` | no | | [disable\_kube\_proxy](#input\_disable\_kube\_proxy) | Whether to deploy Kube-Proxy or not. By default, KP shouldn't be deployed. | `bool` | `true` | no | | [kubernetes\_api\_allowed\_cidr](#input\_kubernetes\_api\_allowed\_cidr) | The CIDR from which to allow to access the Kubernetes API | `string` | `"0.0.0.0/0"` | no | -| [kubernetes\_version](#input\_kubernetes\_version) | Kubernetes version to use for the Talos cluster, if not set, the K8s version shipped with the selected Talos version will be used. Check https://www.talos.dev/v1.5/introduction/support-matrix/. For example '1.27.3'. | `string` | `""` | no | +| [kubernetes\_version](#input\_kubernetes\_version) | Kubernetes version to use for the Talos cluster, if not set, the K8s version shipped with the selected Talos version will be used. Check https://www.talos.dev/v1.5/introduction/support-matrix/. For example '1.27.6'. | `string` | `""` | no | | [pod\_cidr](#input\_pod\_cidr) | The CIDR to use for Pods. Only required in case allocate\_node\_cidrs is set to 'true'. Otherwise, simply configure it inside Cilium's Helm values. | `string` | `"100.64.0.0/14"` | no | | [region](#input\_region) | The region in which to create the Talos Linux cluster. | `string` | n/a | yes | | [service\_cidr](#input\_service\_cidr) | The CIDR to use for services. | `string` | `"100.68.0.0/16"` | no | | [tags](#input\_tags) | The set of tags to place on the cluster. | `map(string)` | n/a | yes | | [talos\_api\_allowed\_cidr](#input\_talos\_api\_allowed\_cidr) | The CIDR from which to allow to access the Talos API | `string` | `"0.0.0.0/0"` | no | -| [talos\_version](#input\_talos\_version) | Talos version to use for the cluster, if not set, the newest Talos version. Check https://github.com/siderolabs/talos/releases for available releases. | `string` | `"v1.5.3"` | no | +| [talos\_version](#input\_talos\_version) | Talos version to use for the cluster, if not set, the newest Talos version. Check https://github.com/siderolabs/talos/releases for available releases. | `string` | `"v1.6.1"` | no | | [vpc\_cidr](#input\_vpc\_cidr) | The IPv4 CIDR block for the VPC. | `string` | `"10.0.0.0/16"` | no | | [vpc\_id](#input\_vpc\_id) | ID of the VPC where to place the VMs. | `string` | n/a | yes | | [worker\_groups](#input\_worker\_groups) | List of node worker node groups to create |
list(object({
name = string
instance_type = optional(string, "m5.large")
config_patch_files = optional(list(string), [])
tags = optional(map(string), {})
}))
|
[
{
"name": "default"
}
]
| no | diff --git a/example/00-variables.tf b/example/00-variables.tf index 009bdff..5bb73e4 100644 --- a/example/00-variables.tf +++ b/example/00-variables.tf @@ -11,6 +11,12 @@ variable "cluster_id" { type = number } +variable "cluster_architecture" { + description = "Cluster architecture. Choose 'arm64' or 'amd64'. If you choose 'arm64', ensure to also override the control_plane.instance_type and worker_groups.instance_type with an ARM64-based instance type like 'm7g.large'." + type = string + default = "amd64" +} + variable "region" { description = "The region in which to create the cluster." type = string @@ -38,13 +44,13 @@ variable "tags" { # talos module variable "talos_version" { - default = "v1.5.3" + default = "v1.6.1" type = string description = "Talos version to use for the cluster, if not set the newest Talos version. Check https://github.com/siderolabs/talos/releases for available releases." } variable "kubernetes_version" { - default = "1.27.3" + default = "1.27.6" type = string description = "Kubernetes version to use for the Talos cluster, if not set, the K8s version shipped with the selected Talos version will be used. Check https://www.talos.dev/v1.5/introduction/support-matrix/." } @@ -81,7 +87,7 @@ variable "cilium_helm_chart" { } variable "cilium_helm_version" { - default = "1.14.3" + default = "1.14.6" type = string description = "The version of the used Helm chart. Check https://github.com/cilium/cilium/releases to see available versions." } diff --git a/example/02-talos.tf b/example/02-talos.tf index 38a4dd0..85b646a 100644 --- a/example/02-talos.tf +++ b/example/02-talos.tf @@ -3,12 +3,13 @@ module "talos" { source = "../" // Supported Talos versions (and therefore K8s versions) can be found here: https://github.com/siderolabs/talos/releases - talos_version = var.talos_version - kubernetes_version = var.kubernetes_version - cluster_name = var.cluster_name - cluster_id = var.cluster_id - region = var.region - tags = local.tags + talos_version = var.talos_version + kubernetes_version = var.kubernetes_version + cluster_name = var.cluster_name + cluster_id = var.cluster_id + cluster_architecture = var.cluster_architecture + region = var.region + tags = local.tags # For single-node cluster support: #allow_workload_on_cp_nodes = true #controlplane_count = 1 diff --git a/example/README.md b/example/README.md index 5b247e9..3cb49c2 100644 --- a/example/README.md +++ b/example/README.md @@ -110,18 +110,19 @@ aws-delete-vpc -cluster-name | [cilium\_helm\_chart](#input\_cilium\_helm\_chart) | The name of the Helm chart to be used. The naming depends on the Helm repo naming on the local machine. | `string` | `"cilium/cilium"` | no | | [cilium\_helm\_values\_file\_path](#input\_cilium\_helm\_values\_file\_path) | Cilium values file | `string` | `"03-cilium-values.yaml"` | no | | [cilium\_helm\_values\_override\_file\_path](#input\_cilium\_helm\_values\_override\_file\_path) | Override Cilium values file | `string` | `""` | no | -| [cilium\_helm\_version](#input\_cilium\_helm\_version) | The version of the used Helm chart. Check https://github.com/cilium/cilium/releases to see available versions. | `string` | `"1.14.3"` | no | +| [cilium\_helm\_version](#input\_cilium\_helm\_version) | The version of the used Helm chart. Check https://github.com/cilium/cilium/releases to see available versions. | `string` | `"1.14.6"` | no | | [cilium\_namespace](#input\_cilium\_namespace) | The namespace in which to install Cilium. | `string` | `"kube-system"` | no | +| [cluster\_architecture](#input\_cluster\_architecture) | Cluster architecture. Choose 'arm64' or 'amd64'. If you choose 'arm64', ensure to also override the control\_plane.instance\_type and worker\_groups.instance\_type with an ARM64-based instance type like 'm7g.large'. | `string` | `"amd64"` | no | | [cluster\_id](#input\_cluster\_id) | The (Cilium) ID of the cluster. Must be unique for Cilium ClusterMesh and between 0-255. | `number` | `"1"` | no | | [cluster\_name](#input\_cluster\_name) | The name of the cluster. | `string` | `"talos-cute"` | no | -| [kubernetes\_version](#input\_kubernetes\_version) | Kubernetes version to use for the Talos cluster, if not set, the K8s version shipped with the selected Talos version will be used. Check https://www.talos.dev/v1.5/introduction/support-matrix/. | `string` | `"1.27.3"` | no | +| [kubernetes\_version](#input\_kubernetes\_version) | Kubernetes version to use for the Talos cluster, if not set, the K8s version shipped with the selected Talos version will be used. Check https://www.talos.dev/v1.5/introduction/support-matrix/. | `string` | `"1.27.6"` | no | | [owner](#input\_owner) | Owner for resource tagging | `string` | n/a | yes | | [pod\_cidr](#input\_pod\_cidr) | The CIDR to use for K8s Pods. Depending on if allocate\_node\_cidrs is set or not, it will either be configured on the controllerManager and assigned to Node resources or to CiliumNode CRs (in case Cilium runs with 'cluster-pool' IPAM mode). | `string` | `"100.64.0.0/14"` | no | | [pre\_cilium\_install\_script](#input\_pre\_cilium\_install\_script) | A script to be run before installing Cilium. | `string` | `""` | no | | [region](#input\_region) | The region in which to create the cluster. | `string` | n/a | yes | | [service\_cidr](#input\_service\_cidr) | The CIDR to use for K8s Services | `string` | `"100.68.0.0/16"` | no | | [tags](#input\_tags) | The set of tags to place on the created resources. These will be merged with the default tags defined via local.tags in 00-locals.tf. | `map(string)` |
{
"platform": "talos",
"usage": "cute"
}
| no | -| [talos\_version](#input\_talos\_version) | Talos version to use for the cluster, if not set the newest Talos version. Check https://github.com/siderolabs/talos/releases for available releases. | `string` | `"v1.5.3"` | no | +| [talos\_version](#input\_talos\_version) | Talos version to use for the cluster, if not set the newest Talos version. Check https://github.com/siderolabs/talos/releases for available releases. | `string` | `"v1.6.1"` | no | | [vpc\_cidr](#input\_vpc\_cidr) | The CIDR to use for the VPC. Currently it must be a /16 or /24. | `string` | `"10.0.0.0/16"` | no | ### Outputs