Difference between revisions of "Terraform resource: google container node pool"
Jump to navigation
Jump to search
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool | https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool | ||
google_container_node_pool | google_container_node_pool | ||
+ | |||
+ | == Official example == | ||
+ | |||
+ | resource "google_service_account" "default" { | ||
+ | account_id = "service-account-id" | ||
+ | display_name = "Service Account" | ||
+ | } | ||
+ | |||
+ | resource "google_container_cluster" "primary" { | ||
+ | name = "my-gke-cluster" | ||
+ | [[location]] = "us-central1" | ||
+ | |||
+ | # We can't create a cluster with no node pool defined, but we want to only use | ||
+ | # separately managed node pools. So we create the smallest possible default | ||
+ | # node pool and immediately delete it. | ||
+ | remove_default_node_pool = true | ||
+ | initial_node_count = 1 | ||
+ | } | ||
+ | |||
+ | resource "google_container_node_pool" "primary_preemptible_nodes" { | ||
+ | name = "my-node-pool" | ||
+ | cluster = google_container_cluster.primary.id | ||
+ | node_count = 1 | ||
+ | |||
+ | node_config { | ||
+ | preemptible = true | ||
+ | [[machine_type]] = "[[e2-medium]]" | ||
+ | |||
+ | # Google recommends custom service accounts that have cloud-platform scope and | ||
+ | permissions granted via IAM Roles. | ||
+ | service_account = google_service_account.default.email | ||
+ | oauth_scopes = [ | ||
+ | "https://www.googleapis.com/auth/cloud-platform" | ||
+ | ] | ||
+ | } | ||
+ | } | ||
== Related == | == Related == | ||
* <code>[[machine type]]</code> | * <code>[[machine type]]</code> | ||
+ | * [[Deploy GKE cluster using Terraform]] | ||
== See also == | == See also == | ||
* {{tf gcp}} | * {{tf gcp}} | ||
− | * {{GKE}} | + | * {{tf GKE}} |
[[Category:GKE]] | [[Category:GKE]] | ||
[[Category:Terraform]] | [[Category:Terraform]] |
Latest revision as of 17:55, 7 December 2023
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool
google_container_node_pool
Official example[edit]
resource "google_service_account" "default" { account_id = "service-account-id" display_name = "Service Account" } resource "google_container_cluster" "primary" { name = "my-gke-cluster" location = "us-central1" # We can't create a cluster with no node pool defined, but we want to only use # separately managed node pools. So we create the smallest possible default # node pool and immediately delete it. remove_default_node_pool = true initial_node_count = 1 } resource "google_container_node_pool" "primary_preemptible_nodes" { name = "my-node-pool" cluster = google_container_cluster.primary.id node_count = 1 node_config { preemptible = true machine_type = "e2-medium" # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. service_account = google_service_account.default.email oauth_scopes = [ "https://www.googleapis.com/auth/cloud-platform" ] } }
Related[edit]
See also[edit]
- Terraform GCP: [
google_storage_bucket| default_object_access_control | default_object_acl | object_access_control | object_acl | google_container_node_pool | google_compute_address | google_compute_network | google_compute_subnetwork | google_iam_policy | google_project_service | google_service_account | google_compute_router | google_compute_router_nat | google_sql_database_instance
] - Deploy GKE cluster using Terraform,
addons_config, gke.tf, google_container_cluster, google_container_node_pool
Advertising: