|
|
|
@ -12,6 +12,16 @@ variable "service_cloudkms" {
|
|
|
|
|
description = "cloudkms service."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
variable "private_network_id" {
|
|
|
|
|
description = "Private network id."
|
|
|
|
|
type = string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
variable "private_subnetwork_id" {
|
|
|
|
|
description = "Private subnetwork id."
|
|
|
|
|
type = string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output "gke_connect_command" {
|
|
|
|
|
description = "Command to run to connect to the kubernetes cluster."
|
|
|
|
|
value = "gcloud container clusters get-credentials ${google_container_cluster.primary.name} --region ${var.region} --project ${var.project}"
|
|
|
|
@ -104,10 +114,30 @@ resource "google_storage_bucket_iam_member" "gke_gcr" {
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "google_compute_global_address" "gke_cluster_range" {
|
|
|
|
|
project = var.project
|
|
|
|
|
name = "gke-cluster-range"
|
|
|
|
|
purpose = "VPC_PEERING"
|
|
|
|
|
address_type = "INTERNAL"
|
|
|
|
|
prefix_length = 16
|
|
|
|
|
network = var.private_network_id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "google_compute_global_address" "gke_services_range" {
|
|
|
|
|
project = var.project
|
|
|
|
|
name = "gke-services-range"
|
|
|
|
|
purpose = "VPC_PEERING"
|
|
|
|
|
address_type = "INTERNAL"
|
|
|
|
|
prefix_length = 20
|
|
|
|
|
network = var.private_network_id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "google_container_cluster" "primary" {
|
|
|
|
|
project = var.project
|
|
|
|
|
name = "gke-cluster"
|
|
|
|
|
location = var.region
|
|
|
|
|
project = var.project
|
|
|
|
|
name = "gke-cluster"
|
|
|
|
|
location = var.region
|
|
|
|
|
network = var.private_network_id
|
|
|
|
|
subnetwork = var.private_subnetwork_id
|
|
|
|
|
|
|
|
|
|
remove_default_node_pool = true
|
|
|
|
|
initial_node_count = 1
|
|
|
|
@ -139,8 +169,8 @@ resource "google_container_cluster" "primary" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ip_allocation_policy {
|
|
|
|
|
cluster_ipv4_cidr_block = "10.1.0.0/16"
|
|
|
|
|
services_ipv4_cidr_block = "10.2.0.0/20"
|
|
|
|
|
cluster_secondary_range_name = google_compute_global_address.gke_cluster_range.name
|
|
|
|
|
services_secondary_range_name = google_compute_global_address.gke_services_range.name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
|