Skip to content

Commit

Permalink
Added architecture selection support
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
PhilipSchmid committed Feb 12, 2024
1 parent b12cd6a commit 52cda06
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 18 deletions.
8 changes: 7 additions & 1 deletion 00-locals.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -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"
Expand Down
15 changes: 13 additions & 2 deletions 00-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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 = ""

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,21 @@ module "talos" {
|------|-------------|------|---------|:--------:|
| <a name="input_allocate_node_cidrs"></a> [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 |
| <a name="input_allow_workload_on_cp_nodes"></a> [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 |
| <a name="input_cluster_architecture"></a> [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 |
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | The ID of the cluster. | `number` | `"1"` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of cluster | `string` | n/a | yes |
| <a name="input_config_patch_files"></a> [config\_patch\_files](#input\_config\_patch\_files) | Path to talos config path files that applies to all nodes | `list(string)` | `[]` | no |
| <a name="input_control_plane"></a> [control\_plane](#input\_control\_plane) | Info for control plane that will be created | <pre>object({<br> instance_type = optional(string, "m5.large")<br> config_patch_files = optional(list(string), [])<br> tags = optional(map(string), {})<br> })</pre> | `{}` | no |
| <a name="input_controlplane_count"></a> [controlplane\_count](#input\_controlplane\_count) | Defines how many controlplane nodes are deployed in the cluster. | `number` | `3` | no |
| <a name="input_disable_kube_proxy"></a> [disable\_kube\_proxy](#input\_disable\_kube\_proxy) | Whether to deploy Kube-Proxy or not. By default, KP shouldn't be deployed. | `bool` | `true` | no |
| <a name="input_kubernetes_api_allowed_cidr"></a> [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 |
| <a name="input_kubernetes_version"></a> [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 |
| <a name="input_kubernetes_version"></a> [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 |
| <a name="input_pod_cidr"></a> [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 |
| <a name="input_region"></a> [region](#input\_region) | The region in which to create the Talos Linux cluster. | `string` | n/a | yes |
| <a name="input_service_cidr"></a> [service\_cidr](#input\_service\_cidr) | The CIDR to use for services. | `string` | `"100.68.0.0/16"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | The set of tags to place on the cluster. | `map(string)` | n/a | yes |
| <a name="input_talos_api_allowed_cidr"></a> [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 |
| <a name="input_talos_version"></a> [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 |
| <a name="input_talos_version"></a> [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 |
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | The IPv4 CIDR block for the VPC. | `string` | `"10.0.0.0/16"` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC where to place the VMs. | `string` | n/a | yes |
| <a name="input_worker_groups"></a> [worker\_groups](#input\_worker\_groups) | List of node worker node groups to create | <pre>list(object({<br> name = string<br> instance_type = optional(string, "m5.large")<br> config_patch_files = optional(list(string), [])<br> tags = optional(map(string), {})<br> }))</pre> | <pre>[<br> {<br> "name": "default"<br> }<br>]</pre> | no |
Expand Down
12 changes: 9 additions & 3 deletions example/00-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/."
}
Expand Down Expand Up @@ -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."
}
Expand Down
13 changes: 7 additions & 6 deletions example/02-talos.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ aws-delete-vpc -cluster-name <Name of your cluster>

| Name | Version |
|------|---------|
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.5 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.0 |

### Modules

Expand All @@ -110,18 +110,19 @@ aws-delete-vpc -cluster-name <Name of your cluster>
| <a name="input_cilium_helm_chart"></a> [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 |
| <a name="input_cilium_helm_values_file_path"></a> [cilium\_helm\_values\_file\_path](#input\_cilium\_helm\_values\_file\_path) | Cilium values file | `string` | `"03-cilium-values.yaml"` | no |
| <a name="input_cilium_helm_values_override_file_path"></a> [cilium\_helm\_values\_override\_file\_path](#input\_cilium\_helm\_values\_override\_file\_path) | Override Cilium values file | `string` | `""` | no |
| <a name="input_cilium_helm_version"></a> [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 |
| <a name="input_cilium_helm_version"></a> [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 |
| <a name="input_cilium_namespace"></a> [cilium\_namespace](#input\_cilium\_namespace) | The namespace in which to install Cilium. | `string` | `"kube-system"` | no |
| <a name="input_cluster_architecture"></a> [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 |
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | The (Cilium) ID of the cluster. Must be unique for Cilium ClusterMesh and between 0-255. | `number` | `"1"` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the cluster. | `string` | `"talos-cute"` | no |
| <a name="input_kubernetes_version"></a> [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 |
| <a name="input_kubernetes_version"></a> [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 |
| <a name="input_owner"></a> [owner](#input\_owner) | Owner for resource tagging | `string` | n/a | yes |
| <a name="input_pod_cidr"></a> [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 |
| <a name="input_pre_cilium_install_script"></a> [pre\_cilium\_install\_script](#input\_pre\_cilium\_install\_script) | A script to be run before installing Cilium. | `string` | `""` | no |
| <a name="input_region"></a> [region](#input\_region) | The region in which to create the cluster. | `string` | n/a | yes |
| <a name="input_service_cidr"></a> [service\_cidr](#input\_service\_cidr) | The CIDR to use for K8s Services | `string` | `"100.68.0.0/16"` | no |
| <a name="input_tags"></a> [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)` | <pre>{<br> "platform": "talos",<br> "usage": "cute"<br>}</pre> | no |
| <a name="input_talos_version"></a> [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 |
| <a name="input_talos_version"></a> [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 |
| <a name="input_vpc_cidr"></a> [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
Expand Down

0 comments on commit 52cda06

Please sign in to comment.