Skip to content

Commit d1cc2e9

Browse files
authored
Refactor and cleanup liqo helm values (#18)
1 parent b4d153e commit d1cc2e9

File tree

14 files changed

+46
-134
lines changed

14 files changed

+46
-134
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.tfstate
77
*.tfstate.*
88
*.tfvars
9+
examples/**/**/tf.vars
910

1011
# AI
1112
CLAUDE.md

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,13 @@ module "castai-omni-cluster" {
9393
reserved_subnet_cidrs = [data.google_compute_subnetwork.gke_subnet.ip_cidr_range]
9494
}
9595
96-
module "castai_gcp_edge_location" {
97-
source = "github.com/castai/terraform-castai-omni-edge-location"
96+
module "castai_omni_edge_location_gcp" {
97+
source = "castai/omni-edge-location-gcp/castai"
9898
9999
cluster_id = var.cluster_id
100100
organization_id = var.organization_id
101101
102-
gcp = {
103-
region = "europe-west4"
104-
}
105-
106-
tags = {
107-
ManagedBy = "terraform"
108-
}
102+
region = "europe-west4"
109103
110104
depends_on = [module.castai-omni-cluster]
111105
}
@@ -139,7 +133,7 @@ locals {
139133
}
140134
141135
module "castai_omni_cluster" {
142-
source = "github.com/castai/terraform-castai-omni-cluster"
136+
source = "castai/omni-cluster/castai"
143137
144138
k8s_provider = "eks" # Specify cloud provider: "gke", "eks", or "aks"
145139
api_url = var.castai_api_url
@@ -170,7 +164,7 @@ data "azurerm_virtual_network" "aks_vnet" {
170164
}
171165
172166
module "castai_omni_cluster" {
173-
source = "github.com/castai/terraform-castai-omni-cluster"
167+
source = "castai/omni-cluster/castai"
174168
175169
k8s_provider = "aks" # Specify cloud provider: "gke", "eks", or "aks"
176170
api_url = var.castai_api_url
@@ -193,7 +187,7 @@ When using GitOps tools like ArgoCD or Flux, you can skip the Helm chart install
193187

194188
```hcl
195189
module "castai_omni_cluster" {
196-
source = "github.com/castai/terraform-castai-omni-cluster"
190+
source = "castai/omni-cluster/castai"
197191
198192
k8s_provider = "gke"
199193
api_url = var.castai_api_url
@@ -498,10 +492,13 @@ Complete working examples are available for all supported cloud providers:
498492

499493
## Related Modules
500494

501-
- [terraform-castai-omni-edge-location](https://github.com/castai/terraform-castai-omni-edge-location) - Create and manage edge locations for Omni clusters
495+
- [terraform-castai-omni-cluster](https://github.com/castai/terraform-castai-omni-cluster) - Create and manage Omni clusters
496+
- [terraform-castai-omni-edge-location-gcp](https://github.com/castai/terraform-castai-omni-edge-location-gcp) - Create and manage GCP edge locations for Omni clusters
497+
- [terraform-castai-omni-edge-location-aws](https://github.com/castai/terraform-castai-omni-edge-location-aws) - Create and manage AWS edge locations for Omni clusters
498+
- [terraform-castai-omni-edge-location-oci](https://github.com/castai/terraform-castai-omni-edge-location-oci) - Create and manage OCI edge locations for Omni clusters
502499
- [terraform-castai-gke-cluster](https://github.com/castai/terraform-castai-gke-cluster) - Onboard GKE clusters to CAST AI
503500
- [terraform-castai-eks-cluster](https://github.com/castai/terraform-castai-eks-cluster) - Onboard EKS clusters to CAST AI
504-
- [terraform-castai-aks-cluster](https://github.com/castai/terraform-castai-aks-cluster) - Onboard AKS clusters to CAST AI
501+
- [terraform-castai-aks-cluster](https://github.com/castai/terraform-castai-aks) - Onboard AKS clusters to CAST AI
505502

506503
## License
507504

@@ -522,15 +519,14 @@ MIT
522519

523520
| Name | Version |
524521
|------|---------|
525-
| <a name="provider_castai"></a> [castai](#provider\_castai) | 8.6.0 |
522+
| <a name="provider_castai"></a> [castai](#provider\_castai) | 8.8.0 |
526523
| <a name="provider_helm"></a> [helm](#provider\_helm) | 3.1.1 |
527524
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 3.0.1 |
528525

529526
## Modules
530527

531528
| Name | Source | Version |
532529
|------|--------|---------|
533-
| <a name="module_liqo_helm_values"></a> [liqo\_helm\_values](#module\_liqo\_helm\_values) | cloudposse/config/yaml//modules/deepmerge | 0.2.0 |
534530
| <a name="module_liqo_helm_values_aks"></a> [liqo\_helm\_values\_aks](#module\_liqo\_helm\_values\_aks) | ./modules/aks | n/a |
535531
| <a name="module_liqo_helm_values_eks"></a> [liqo\_helm\_values\_eks](#module\_liqo\_helm\_values\_eks) | ./modules/eks | n/a |
536532
| <a name="module_liqo_helm_values_gke"></a> [liqo\_helm\_values\_gke](#module\_liqo\_helm\_values\_gke) | ./modules/gke | n/a |
@@ -554,10 +550,8 @@ MIT
554550
| <a name="input_api_url"></a> [api\_url](#input\_api\_url) | CAST AI API URL | `string` | `"https://api.cast.ai"` | no |
555551
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | CAST AI cluster ID to enable Omni functionality for | `string` | n/a | yes |
556552
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | CAST AI cluster name | `string` | n/a | yes |
557-
| <a name="input_cluster_region"></a> [cluster\_region](#input\_cluster\_region) | K8s cluster region | `string` | n/a | yes |
558-
| <a name="input_cluster_zone"></a> [cluster\_zone](#input\_cluster\_zone) | K8s cluster zone | `string` | `""` | no |
559553
| <a name="input_k8s_provider"></a> [k8s\_provider](#input\_k8s\_provider) | Kubernetes cloud provider (gke, eks, aks) | `string` | n/a | yes |
560-
| <a name="input_omni_agent_chart_version"></a> [omni\_agent\_chart\_version](#input\_omni\_agent\_chart\_version) | OMNI agent helm chart version | `string` | `"v1.1.8"` | no |
554+
| <a name="input_omni_agent_chart_version"></a> [omni\_agent\_chart\_version](#input\_omni\_agent\_chart\_version) | OMNI agent helm chart version | `string` | `"v1.1.9"` | no |
561555
| <a name="input_organization_id"></a> [organization\_id](#input\_organization\_id) | CAST AI organization ID | `string` | n/a | yes |
562556
| <a name="input_pod_cidr"></a> [pod\_cidr](#input\_pod\_cidr) | Pod CIDR for network configuration | `string` | n/a | yes |
563557
| <a name="input_reserved_subnet_cidrs"></a> [reserved\_subnet\_cidrs](#input\_reserved\_subnet\_cidrs) | List of reserved subnet CIDR's (relevant for GKE) | `list(string)` | `[]` | no |

examples/onboarding-with-existing-aks-cluster/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module "castai_omni_cluster" {
1212
organization_id = var.organization_id
1313
cluster_id = var.cluster_id
1414
cluster_name = var.aks_cluster_name
15-
cluster_region = data.azurerm_kubernetes_cluster.aks.location
1615

1716
api_server_address = "https://${data.azurerm_kubernetes_cluster.aks.fqdn}"
1817
pod_cidr = data.azurerm_kubernetes_cluster.aks.network_profile[0].pod_cidr
@@ -22,7 +21,8 @@ module "castai_omni_cluster" {
2221
}
2322

2423
module "castai_omni_edge_location_gcp" {
25-
source = "github.com/castai/terraform-castai-omni-edge-location-gcp"
24+
source = "castai/omni-edge-location-gcp/castai"
25+
version = "~> 1"
2626

2727
cluster_id = module.castai_omni_cluster.cluster_id
2828
organization_id = module.castai_omni_cluster.organization_id

examples/onboarding-with-existing-eks-cluster/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module "castai_omni_cluster" {
1717
organization_id = var.organization_id
1818
cluster_id = var.cluster_id
1919
cluster_name = var.eks_cluster_name
20-
cluster_region = var.eks_cluster_region
2120

2221
api_server_address = data.aws_eks_cluster.eks.endpoint
2322
pod_cidr = data.aws_vpc.eks_vpc.cidr_block
@@ -26,8 +25,9 @@ module "castai_omni_cluster" {
2625
skip_helm = var.skip_helm
2726
}
2827

29-
module "castai_aws_edge_location" {
30-
source = "github.com/castai/terraform-castai-omni-edge-location-aws"
28+
module "castai_omni_edge_location_aws" {
29+
source = "castai/omni-edge-location-aws/castai"
30+
version = "~> 1"
3131

3232
providers = {
3333
aws = aws.eu_west_1
@@ -36,6 +36,7 @@ module "castai_aws_edge_location" {
3636
cluster_id = module.castai_omni_cluster.cluster_id
3737
organization_id = module.castai_omni_cluster.organization_id
3838
region = "eu-west-1"
39+
zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
3940

4041
tags = {
4142
ManagedBy = "terraform"

examples/onboarding-with-existing-gke-cluster/main.tf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ locals {
1414
# Determine region from location (if zonal, extract region; if regional, use as-is)
1515
is_zonal_cluster = length(regexall("^.*-[a-z]$", var.gke_cluster_location)) > 0
1616
cluster_region = local.is_zonal_cluster ? regex("^(.*)-[a-z]$", var.gke_cluster_location)[0] : var.gke_cluster_location
17-
cluster_zone = local.is_zonal_cluster ? var.gke_cluster_location : ""
1817
}
1918

2019
# Get subnet details to retrieve the IP CIDR range
@@ -33,8 +32,6 @@ module "castai_omni_cluster" {
3332
organization_id = var.organization_id
3433
cluster_id = var.cluster_id
3534
cluster_name = var.gke_cluster_name
36-
cluster_region = local.cluster_region
37-
cluster_zone = local.cluster_zone
3835

3936
api_server_address = "https://${data.google_container_cluster.gke.endpoint}"
4037
pod_cidr = data.google_container_cluster.gke.cluster_ipv4_cidr
@@ -45,7 +42,8 @@ module "castai_omni_cluster" {
4542
}
4643

4744
module "castai_omni_edge_location_gcp" {
48-
source = "github.com/castai/terraform-castai-omni-edge-location-gcp"
45+
source = "castai/omni-edge-location-gcp/castai"
46+
version = "~> 1"
4947

5048
cluster_id = module.castai_omni_cluster.cluster_id
5149
organization_id = module.castai_omni_cluster.organization_id

examples/onboarding-with-existing-gke-cluster/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ variable "gke_project_id" {
44
}
55

66
variable "gke_cluster_location" {
7-
description = "GKE Cluster Location"
7+
description = "GKE Cluster Location (region or zone)"
88
type = string
99
}
1010

main.tf

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ module "liqo_helm_values_gke" {
1111
source = "./modules/gke"
1212

1313
cluster_name = var.cluster_name
14-
cluster_region = var.cluster_region
15-
cluster_zone = var.cluster_zone
1614
api_server_address = var.api_server_address
1715
pod_cidr = var.pod_cidr
1816
service_cidr = var.service_cidr
@@ -25,7 +23,6 @@ module "liqo_helm_values_eks" {
2523
source = "./modules/eks"
2624

2725
cluster_name = var.cluster_name
28-
cluster_region = var.cluster_region
2926
api_server_address = var.api_server_address
3027
pod_cidr = var.pod_cidr
3128
service_cidr = var.service_cidr
@@ -37,8 +34,6 @@ module "liqo_helm_values_aks" {
3734
source = "./modules/aks"
3835

3936
cluster_name = var.cluster_name
40-
cluster_region = var.cluster_region
41-
cluster_zone = var.cluster_zone
4237
api_server_address = var.api_server_address
4338
pod_cidr = var.pod_cidr
4439
service_cidr = var.service_cidr
@@ -51,18 +46,6 @@ locals {
5146
castai_helm_repository = "https://castai.github.io/helm-charts"
5247
castai_agent_secret_ref = "castai-omni-agent-token"
5348

54-
# Common Liqo configuration as YAML
55-
common_liqo_yaml_values = {
56-
networking = {
57-
fabric = {
58-
config = {
59-
healthProbeBindAddressPort = "7071"
60-
metricsAddressPort = "7072"
61-
}
62-
}
63-
}
64-
}
65-
6649
# Select the appropriate yaml_values based on k8s_provider
6750
liqo_yaml_values = merge(
6851
{ for v in module.liqo_helm_values_gke : "gke" => v.liqo_yaml_values },
@@ -71,15 +54,6 @@ locals {
7154
)
7255
}
7356

74-
module "liqo_helm_values" {
75-
source = "cloudposse/config/yaml//modules/deepmerge"
76-
version = "0.2.0"
77-
maps = [
78-
local.common_liqo_yaml_values,
79-
local.liqo_yaml_values[var.k8s_provider].liqo,
80-
]
81-
}
82-
8357
locals {
8458
helm_yaml_values = {
8559
castai = {
@@ -89,7 +63,7 @@ locals {
8963
clusterID = var.cluster_id
9064
clusterName = var.cluster_name
9165
}
92-
liqo = module.liqo_helm_values.merged
66+
liqo = local.liqo_yaml_values[var.k8s_provider].liqo
9367
}
9468
}
9569

modules/aks/main.tf

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
locals {
22
pools_cidrs = ["10.0.0.0/8", "192.168.0.0/16", "172.16.0.0/12", var.service_cidr]
3-
provider = "aks"
43

54
liqo_yaml_values = {
65
liqo = {
@@ -11,15 +10,6 @@ locals {
1110
discovery = {
1211
config = {
1312
clusterID = var.cluster_name
14-
clusterLabels = merge(
15-
{
16-
"liqo.io/provider" = local.provider
17-
"topology.kubernetes.io/region" = var.cluster_region
18-
},
19-
var.cluster_zone != "" ? {
20-
"topology.kubernetes.io/zone" = var.cluster_zone
21-
} : {}
22-
)
2313
}
2414
}
2515
ipam = {
@@ -30,6 +20,22 @@ locals {
3020
telemetry = {
3121
enabled = false
3222
}
23+
networking = {
24+
fabric = {
25+
config = {
26+
gatewayMasqueradeBypass = true
27+
}
28+
}
29+
}
30+
virtualKubelet = {
31+
virtualNode = {
32+
extra = {
33+
labels = {
34+
"kubernetes.azure.com/managed" = "false"
35+
}
36+
}
37+
}
38+
}
3339
}
3440
}
3541
}

modules/aks/variables.tf

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
variable "cluster_name" {
2-
description = "GKE cluster name"
2+
description = "AKS cluster name"
33
type = string
44
}
55

6-
variable "cluster_region" {
7-
description = "GKE region for topology labels"
8-
type = string
9-
}
10-
11-
variable "cluster_zone" {
12-
description = "GKE zone for topology labels (optional)"
13-
type = string
14-
default = ""
15-
}
16-
176
variable "api_server_address" {
187
description = "Kubernetes API server address"
198
type = string

modules/eks/main.tf

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
locals {
22
pools_cidrs = ["10.0.0.0/8", "192.168.0.0/16", "172.16.0.0/12", var.service_cidr]
3-
provider = "eks"
43

54
liqo_yaml_values = {
65
liqo = {
@@ -11,10 +10,6 @@ locals {
1110
discovery = {
1211
config = {
1312
clusterID = var.cluster_name
14-
clusterLabels = {
15-
"liqo.io/provider" = local.provider
16-
"topology.kubernetes.io/region" = var.cluster_region
17-
}
1813
}
1914
}
2015
ipam = {
@@ -25,25 +20,16 @@ locals {
2520
telemetry = {
2621
enabled = false
2722
}
28-
virtualKubelet = {
29-
extra = {
30-
args = ["--certificate-type=aws"]
31-
}
32-
}
3323
networking = {
3424
fabric = {
3525
config = {
3626
fullMasquerade = true
3727
}
3828
}
39-
gatewayTemplates = {
40-
server = {
41-
service = {
42-
annotations = {
43-
"service.beta.kubernetes.io/aws-load-balancer-type" = "nlb"
44-
}
45-
}
46-
}
29+
}
30+
virtualKubelet = {
31+
extra = {
32+
args = ["--certificate-type=aws"]
4733
}
4834
}
4935
}

0 commit comments

Comments
 (0)