-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cicd): Improve terraform and finish gateway
* Improve terraform artifacts * Try to implement native vpc cluster * use native vpc cluster fix the gateway * Finish gateway * update readme * ubncomment gateway tetraform * improve comments
- Loading branch information
1 parent
09681da
commit 9c98fd8
Showing
24 changed files
with
163 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
data "kubectl_filename_list" "api_gateway_manifests" { | ||
pattern = "../api-gateway/*.yaml" | ||
} | ||
|
||
resource "kubectl_manifest" "api_gateway" { | ||
count = length(data.kubectl_filename_list.api_gateway_manifests.matches) | ||
yaml_body = file(element(data.kubectl_filename_list.api_gateway_manifests.matches, count.index)) | ||
|
||
depends_on = [ | ||
google_container_cluster.primary, | ||
google_compute_network.vpc, | ||
google_compute_subnetwork.subnet, | ||
google_compute_subnetwork.managed_proxy_subnet, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
terraform { | ||
backend "gcs" { | ||
bucket = "state-bucket-tfstate-chat1" | ||
bucket = "state-bucket-tfstate-chat3" | ||
prefix = "terraform/state" | ||
# credentials = "/Users/carlosazuaje/.config/gcloud/application_default_credentials.json" | ||
# impersonate_service_account = "terraform-admin@chat1-405416.iam.gserviceaccount.com" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
resource "google_service_account" "github_action" { | ||
account_id = "github-action" | ||
display_name = "GitHub Action Service Account" | ||
} | ||
|
||
resource "google_project_iam_binding" "container_admin" { | ||
project = var.project_id | ||
role = "roles/container.admin" | ||
|
||
members = [ | ||
"serviceAccount:${google_service_account.github_action.email}", | ||
] | ||
|
||
depends_on = [google_service_account.github_action] | ||
} | ||
|
||
resource "google_project_iam_binding" "storage_admin" { | ||
project = var.project_id | ||
role = "roles/storage.admin" | ||
|
||
members = [ | ||
"serviceAccount:${google_service_account.github_action.email}", | ||
] | ||
depends_on = [google_service_account.github_action] | ||
} | ||
|
||
resource "google_project_iam_binding" "cluster_viewer" { | ||
project = var.project_id | ||
role = "roles/container.clusterViewer" | ||
|
||
members = [ | ||
"serviceAccount:${google_service_account.github_action.email}", | ||
] | ||
|
||
depends_on = [google_service_account.github_action] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
project_id = "chat1-405416" | ||
region = "us-central1" | ||
project_id = "chat3-407706" | ||
region = "us-central1" | ||
gke_config_context = "gke_chat3-407706_us-central1_chat3-407706-gke" | ||
managed_proxy_subnet = "my-gke-proxy-subnet" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,44 @@ | ||
# VPC | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/using_gke_with_terraform | ||
# https://cloud.google.com/kubernetes-engine/docs/how-to/deploying-gateways | ||
|
||
# Important: | ||
# The Gateway API is supported on VPC-native clusters only. | ||
# I needs a proxy-only subnet | ||
|
||
# VPC main for GLE Cluster | ||
resource "google_compute_network" "vpc" { | ||
name = "${var.project_id}-vpc" | ||
auto_create_subnetworks = "false" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
# Subnet | ||
# Subnet config for VPC-native in GKE Cluster | ||
resource "google_compute_subnetwork" "subnet" { | ||
name = "${var.project_id}-subnet" | ||
region = var.region | ||
ip_cidr_range = "10.2.0.0/16" | ||
network = google_compute_network.vpc.id | ||
secondary_ip_range { | ||
range_name = "services-range" | ||
ip_cidr_range = "192.168.1.0/24" | ||
} | ||
|
||
secondary_ip_range { | ||
range_name = "pod-ranges" | ||
ip_cidr_range = "192.168.64.0/22" | ||
} | ||
} | ||
|
||
# Proxy-Only Subnet | ||
resource "google_compute_subnetwork" "managed_proxy_subnet" { | ||
role = "ACTIVE" | ||
purpose = "REGIONAL_MANAGED_PROXY" | ||
name = var.managed_proxy_subnet | ||
region = var.region | ||
network = google_compute_network.vpc.name | ||
ip_cidr_range = "10.10.0.0/24" | ||
ip_cidr_range = "10.0.32.0/20" | ||
|
||
depends_on = [google_compute_network.vpc] | ||
} | ||
|
||
# Verify your proxy-only subnet | ||
# gcloud compute networks subnets describe my-gke-proxy-subnet --region=us-central1 |