Skip to content

Commit 8ecadef

Browse files
committed
feat(infrastructure-templates): accepts tags from variable sets, and
accomodates updates in terraform/modules
1 parent 5aeef00 commit 8ecadef

24 files changed

Lines changed: 258 additions & 89 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
terraform {
2+
backend "kubernetes" {
3+
namespace = "default"
4+
secret_suffix = "state"
5+
config_path = "~/.kube/configs/kloudlite-dev.yml"
6+
}
7+
}

examples-infra/test-aws-dev-cluster/varfile.template.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ aws_assume_role:
88
enabled: true
99
role_arn: "${AWS_ASSUME_ROLE_ARN}"
1010
external_id: "${AWS_ASSUME_ROLE_PARAM_EXTERNAL_ID}"
11-
#
1211

1312
k3s_masters:
1413
image_id: ami-06d146e85d1709abb
@@ -99,6 +98,11 @@ kloudlite_params:
9998
install_crds: true
10099
install_csi_driver: true
101100
install_operators: true
101+
agent_vars:
102+
cluster_token: "asdfafa"
103+
cluster_name: "tetaa"
104+
account_name: "asdfasfasf"
105+
message_office_grpc_addr: "message-office:443"
102106

103107
extra_server_args:
104108
- --snapshotter

examples-infra/test-aws-dev-cluster/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ variable "aws_access_key" {
22
description = "AWS Access Key"
33
type = string
44
}
5+
56
variable "aws_secret_key" {
67
description = "AWS Secret Key"
78
type = string
@@ -13,5 +14,4 @@ variable "aws_assume_role" {
1314
role_arn = string
1415
external_id = optional(string, null)
1516
})
16-
}
17-
17+
}

infrastructure-templates/dns-records-management/variable-cloudflare-dns.tf

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,23 @@ variable "cloudflare_zone_id" {
1414
type = string
1515
}
1616

17-
variable "A_records" {
18-
description = "DNS A records to add. It is a map of IP => { value: domain name }"
19-
type = map(object({
20-
value = string
21-
ttl = optional(number, 120),
17+
variable "DNS_records" {
18+
description = "DNS Records to add"
19+
type = list(object({
20+
record_type = string
21+
domain = string
22+
value = string
23+
ttl = optional(number, 120)
2224
}))
23-
}
24-
25-
variable "TXT_records" {
26-
description = "DNS TXT records to add, It is map of key => { value: answer }"
27-
type = map(object({
28-
value = string
29-
ttl = optional(number, 120),
30-
}))
31-
}
3225

33-
variable "CNAME_records" {
34-
description = "DNS CNAME records to add, it is a map of domain => { value: cname }"
35-
type = map(object({
36-
value = string
37-
ttl = optional(number, 120),
38-
}))
26+
validation {
27+
error_message = "record_type should be a valid DNS record type"
28+
condition = alltrue([for item in var.DNS_records : contains(["A", "MX", "CNAME", "TXT"], item.record_type)])
29+
}
3930
}
4031

4132
variable "use_cloudflare_proxy" {
4233
description = "should we use cloudflare proxy for provided domain"
4334
type = bool
4435
default = false
45-
g
36+
}

infrastructure-templates/kl-target-cluster-aws-only-masters/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ module "kl-master-nodes-on-aws" {
88
save_ssh_key_to_path = var.save_ssh_key_to_path
99
save_kubeconfig_to_path = var.save_kubeconfig_to_path
1010
extra_server_args = var.extra_server_args
11+
tags = var.tags
1112
}

infrastructure-templates/kl-target-cluster-aws-only-masters/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ output "k3s_agent_token" {
1919
output "kubeconfig" {
2020
sensitive = true
2121
value = module.kl-master-nodes-on-aws.kubeconfig
22+
}
23+
24+
output "kloudlite-k3s-params" {
25+
value = module.kl-master-nodes-on-aws.k3s-params
2226
}
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
#terraform {
2+
# required_version = ">= 1.2.0"
3+
#
4+
# backend "s3" {
5+
# bucket = "${AWS_S3_BUCKET_NAME}"
6+
# key = "${AWS_S3_BUCKET_FILEPATH}"
7+
# region = "${AWS_S3_BUCKET_REGION}"
8+
# }
9+
#}
10+
111
terraform {
212
required_version = ">= 1.2.0"
313
4-
backend "s3" {
5-
bucket = "${AWS_S3_BUCKET_NAME}"
6-
key = "${AWS_S3_BUCKET_FILEPATH}"
7-
region = "${AWS_S3_BUCKET_REGION}"
14+
backend "kubernetes" {
15+
# read more at https://developer.hashicorp.com/terraform/language/settings/backends/kubernetes#configuration-variables
16+
secret_suffix = "state"
17+
18+
# when running on a kubernetes cluster, specify env-vars:
19+
# - KUBE_IN_CLUSTER_CONFIG="true"
20+
# - KUBE_NAMESPACE="some namespace"
21+
22+
# when running on local machine, uncomment the following, and pass appropriate values
23+
# namespace = "default"
24+
# config_path = "~/.kube/configs/kloudlite-dev.yml"
825
}
9-
}
26+
}

infrastructure-templates/kl-target-cluster-aws-only-masters/variables-kl-master-nodes-on-aws.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,10 @@ variable "save_kubeconfig_to_path" {
122122
type = string
123123
default = ""
124124
}
125+
126+
variable "tags" {
127+
description = "a map of key values , that will be attached to cloud provider resources, for easier referencing"
128+
type = map(string)
129+
default = {}
130+
}
131+

infrastructure-templates/kl-target-cluster-aws-only-workers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ module "kl-worker-nodes-on-aws" {
99
tracker_id = "${var.tracker_id}-workers"
1010
extra_agent_args = var.extra_agent_args
1111
save_ssh_key_to_path = var.save_ssh_key_to_path
12+
tags = var.tags
1213
}
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
#terraform {
2+
# required_version = ">= 1.2.0"
3+
#
4+
# backend "s3" {
5+
# bucket = "${AWS_S3_BUCKET_NAME}"
6+
# key = "${AWS_S3_BUCKET_FILEPATH}"
7+
# region = "${AWS_S3_BUCKET_REGION}"
8+
# }
9+
#}
10+
111
terraform {
212
required_version = ">= 1.2.0"
313
4-
backend "s3" {
5-
bucket = "${AWS_S3_BUCKET_NAME}"
6-
key = "${AWS_S3_BUCKET_FILEPATH}"
7-
region = "${AWS_S3_BUCKET_REGION}"
14+
backend "kubernetes" {
15+
# read more at https://developer.hashicorp.com/terraform/language/settings/backends/kubernetes#configuration-variables
16+
secret_suffix = "state"
17+
18+
# when running on a kubernetes cluster, specify env-vars:
19+
# - KUBE_IN_CLUSTER_CONFIG="true"
20+
# - KUBE_NAMESPACE="some namespace"
21+
22+
# when running on local machine, uncomment the following, and pass appropriate values
23+
# namespace = "default"
24+
# config_path = "~/.kube/configs/kloudlite-dev.yml"
825
}
9-
}
26+
}

0 commit comments

Comments
 (0)