Skip to content

Commit df03e2b

Browse files
committed
update modules
1 parent c0fe535 commit df03e2b

File tree

13 files changed

+73
-48
lines changed

13 files changed

+73
-48
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Ensure the following tasks are completed.
99
- [ ] Are tests included?
1010
- [ ] Are the tests running?
1111
- [ ] Are the names of the files correct?
12-
- [ ] Add PR/Issue to opsZero Project and set to `Review` column
12+
- [ ] Add PR/Issue to opsZero project and set to `Review` column
1313

1414
# Reviewer Checklist
1515

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ gcloud container clusters get-credentials <clustername> --region us-central1
3636
|------|-------------|------|---------|:--------:|
3737
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | The minimum version of the master | `string` | `"1.27"` | no |
3838
| <a name="input_csi_secrets_store_enabled"></a> [csi\_secrets\_store\_enabled](#input\_csi\_secrets\_store\_enabled) | Specify whether the CSI driver is enabled | `bool` | `true` | no |
39-
| <a name="input_name"></a> [environment\_name](#input\_environment\_name) | The name of the environment to create resources | `string` | n/a | yes |
40-
| <a name="input_project"></a> [project](#input\_project) | The Google Project that will host the cluster | `string` | n/a | yes |
39+
| <a name="input_environment_name"></a> [environment\_name](#input\_environment\_name) | The name of the environment to create resources | `string` | n/a | yes |
40+
| <a name="input_project"></a> [project](#input\_project) | The Google project that will host the cluster | `string` | n/a | yes |
4141
| <a name="input_redis_enabled"></a> [redis\_enabled](#input\_redis\_enabled) | Specify whether the redis cluster is enabled | `bool` | `false` | no |
4242
| <a name="input_redis_ha_enabled"></a> [redis\_ha\_enabled](#input\_redis\_ha\_enabled) | Specify whether HA is enabled for redis | `bool` | `false` | no |
4343
| <a name="input_redis_memory_in_gb"></a> [redis\_memory\_in\_gb](#input\_redis\_memory\_in\_gb) | Redis memory size in GiB | `number` | `1` | no |
@@ -105,4 +105,4 @@ Please [schedule a call](https://calendly.com/opszero-llc/discovery) if you need
105105
<img src="https://opszero.com/wp-content/uploads/2024/07/AWS-public-sector.png" width="150px" />
106106
<img src="https://opszero.com/wp-content/uploads/2024/07/AWS-eks.png" width="150px" />
107107
</div>
108-
<!-- END_TF_DOCS -->
108+
<!-- END_TF_DOCS -->

examples/gcp/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/gcp/main.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
provider "google" {
22
region = "us-central1"
3-
project = "xx-xxxx-xxxx-xx"
3+
project = "xx-xx-xx-xx"
44
}
55

66
module "gke" {
77
source = "../../"
8-
project = "xx-xxxx-xxxx-xx"
9-
name = "dev"
8+
project = "xx-xx-xx-xx"
9+
environment_name = "example"
1010
machine_type = "e2-medium"
1111
image_type = "UBUNTU_CONTAINERD"
1212
location = "us-central1-a"
13-
min_master_version = "1.29.14-gke.1018000"
13+
min_master_version = "1.30.9-gke.1046000"
14+
sql_master_username = "root"
15+
sql_master_password = "pass"
1416
initial_node_count = 1
1517
min_node_count = 1
1618
max_node_count = 1
1719
disk_size_gb = 20
20+
csi_secrets_store_enabled = true
21+
kms_enabled = true
22+
sql_enabled = true
23+
redis_enabled = true
1824
}

gcp_csi_secrets_store.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
resource "helm_release" "csi_secrets_store" {
22
count = var.csi_secrets_store_enabled ? 1 : 0
33

4-
name = "csi-secrets-store"
5-
repository = "https://kubernetes-sigs.github.io/secrets-store-csi-driver/charts"
6-
chart = "secrets-store-csi-driver"
7-
4+
name = "csi-secrets-store"
5+
repository = "https://kubernetes-sigs.github.io/secrets-store-csi-driver/charts"
6+
chart = "secrets-store-csi-driver"
87
namespace = "csi"
98
create_namespace = true
9+
depends_on = [google_container_cluster.primary, google_container_node_pool.node_pool]
1010
}
1111

1212
data "http" "csi_secrets_store_gcp_provider" {

kms.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "google_kms_key_ring" "keyring" {
22
count = var.kms_enabled ? 1 : 0
3-
name = var.name
3+
name = var.environment_name
44
project = var.project
55

66
location = "global"
@@ -12,7 +12,7 @@ resource "google_kms_key_ring" "keyring" {
1212

1313
resource "google_kms_crypto_key" "key" {
1414
count = var.kms_enabled ? 1 : 0
15-
name = var.name
15+
name = var.environment_name
1616

1717
key_ring = join("", google_kms_key_ring.keyring.*.id)
1818

locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
22
tags = merge(var.tags, {
3-
"kubespot_env" = var.name
3+
"kubespot_env" = var.environment_name
44
})
55
}

main.tf

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1+
data "google_client_config" "default" {}
2+
3+
provider "helm" {
4+
kubernetes {
5+
host = "https://${google_container_cluster.primary.endpoint}"
6+
token = data.google_client_config.default.access_token
7+
cluster_ca_certificate = base64decode(google_container_cluster.primary.master_auth.0.cluster_ca_certificate)
8+
}
9+
}
10+
11+
provider "kubernetes" {
12+
host = "https://${google_container_cluster.primary.endpoint}"
13+
token = data.google_client_config.default.access_token
14+
cluster_ca_certificate = base64decode(google_container_cluster.primary.master_auth.0.cluster_ca_certificate)
15+
}
16+
17+
118
resource "google_container_cluster" "primary" {
2-
name = var.name
19+
name = var.environment_name
320
project = var.project
421
network = google_compute_network.network.id
522
subnetwork = google_compute_subnetwork.subnet.id
6-
remove_default_node_pool = var.remove_default_node_pool
723
location = var.location
24+
remove_default_node_pool = var.remove_default_node_pool
825
initial_node_count = var.initial_node_count
926
min_master_version = var.min_master_version
1027

@@ -13,14 +30,6 @@ resource "google_container_cluster" "primary" {
1330
enable_private_endpoint = false
1431
}
1532

16-
node_config {
17-
preemptible = true
18-
machine_type = var.machine_type
19-
}
20-
21-
lifecycle {
22-
ignore_changes = [initial_node_count]
23-
}
2433
deletion_protection = false
2534
ip_allocation_policy {}
2635

@@ -36,7 +45,7 @@ resource "google_container_cluster" "primary" {
3645
}
3746

3847
resource "google_container_node_pool" "node_pool" {
39-
name = "${var.name}-node-pool"
48+
name = "${var.environment_name}-node-pool"
4049
project = var.project
4150
location = var.location
4251
cluster = google_container_cluster.primary.id
@@ -66,7 +75,6 @@ resource "google_container_node_pool" "node_pool" {
6675
ignore_changes = [initial_node_count]
6776
create_before_destroy = false
6877
}
69-
7078
timeouts {
7179
create = var.cluster_create_timeouts
7280
update = var.cluster_update_timeouts
@@ -76,7 +84,7 @@ resource "google_container_node_pool" "node_pool" {
7684

7785
resource "null_resource" "configure_kubectl" {
7886
provisioner "local-exec" {
79-
command = "gcloud container clusters get-credentials ${var.name} --zone ${var.location} --project ${var.project}"
87+
command = "gcloud container clusters get-credentials ${var.environment_name} --zone ${var.location} --project ${var.project}"
8088
environment = {
8189
KUBECONFIG = var.kubectl_config_path != "" ? var.kubectl_config_path : ""
8290
}

redis.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "google_redis_instance" "cache" {
22
count = var.redis_enabled ? 1 : 0
33
project = var.project
4-
name = var.name
4+
name = var.environment_name
55
memory_size_gb = var.redis_memory_in_gb
66

77
authorized_network = google_compute_network.network.self_link

sql.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ resource "google_sql_database_instance" "default" {
88
project = var.project
99
region = var.region
1010

11-
name = "${var.name}-${random_id.server.hex}"
11+
name = "${var.environment_name}-${random_id.server.hex}"
1212
database_version = var.sql_engine
1313
depends_on = [null_resource.sql_vpc_lock]
1414
settings {

0 commit comments

Comments
 (0)