Editing Gke.tf

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{lc}}
 
* https://github.com/hashicorp/learn-terraform-provision-gke-cluster/blob/main/gke.tf
 
  
[[location]] = [[var.region]] or location = [[us-central1-a]]
 
 
== Code ==
 
 
* https://github.com/hashicorp/learn-terraform-provision-gke-cluster/blob/main/gke.tf
 
* https://github.com/hashicorp/learn-terraform-provision-gke-cluster/blob/main/gke.tf
  
variable "gke_username" {
 
  default    = ""
 
  description = "gke username"
 
}
 
 
variable "gke_password" {
 
  default    = ""
 
  description = "gke password"
 
}
 
 
variable "gke_num_nodes" {
 
  default    = 2
 
  description = "number of gke nodes"
 
}
 
 
# GKE cluster
 
resource "[[google_container_cluster]]" "primary" {
 
  name    = "${var.project_id}-gke"
 
  location = var.region
 
 
 
  # 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
 
 
  network    = google_compute_network.vpc.name
 
  subnetwork = google_compute_subnetwork.subnet.name
 
}
 
 
# Separately Managed Node Pool
 
resource "[[google_container_node_pool]]" "primary_nodes" {
 
  name      = "${google_container_cluster.primary.name}"
 
  location  = var.region
 
  cluster    = google_container_cluster.primary.name
 
  node_count = var.gke_num_nodes
 
 
  [[node_config]] {
 
    oauth_scopes = [
 
      "https://www.googleapis.com/auth/logging.write",
 
      "https://www.googleapis.com/auth/monitoring",
 
    ]
 
 
    labels = {
 
      env = var.project_id
 
    }
 
 
    # preemptible  = true
 
    [[machine_type]] = "[[n1-standard-1]]"
 
    tags        = ["gke-node", "${var.project_id}-gke"]
 
    metadata = {
 
      disable-legacy-endpoints = "true"
 
    }
 
  }
 
}
 
 
<pre>
 
# # Kubernetes provider
 
# # The Terraform Kubernetes Provider configuration below is used as a learning reference only.
 
# # It references the variables and resources provisioned in this file.
 
# # We recommend you put this in another file -- so you can have a more modular configuration.
 
# # https://learn.hashicorp.com/terraform/kubernetes/provision-gke-cluster#optional-configure-terraform-kubernetes-provider
 
# # To learn how to schedule deployments and services using the provider, go here: https://learn.hashicorp.com/tutorials/terraform/kubernetes-provider.
 
 
# provider "kubernetes" {
 
#  load_config_file = "false"
 
 
#  host    = google_container_cluster.primary.endpoint
 
#  username = var.gke_username
 
#  password = var.gke_password
 
 
#  client_certificate    = google_container_cluster.primary.master_auth.0.client_certificate
 
#  client_key            = google_container_cluster.primary.master_auth.0.client_key
 
#  cluster_ca_certificate = google_container_cluster.primary.master_auth.0.cluster_ca_certificate
 
# }
 
</pre>
 
 
== Related ==
 
* <code>[[machine_type]]</code>: <code>[[n1-standard-1]], [[g1-small]]</code>
 
* <code>[[google_compute_instance]]</code>
 
* <code>[[eks-cluster.tf]]</code>
 
* <code>[[gcloud container clusters describe your-cluster-name --region us-central1-a]]</code>
 
  
== See also ==
 
* {{gke.tf}}
 
* {{tf GKE}}
 
  
[[Category:GKE]]
+
[[Deploy GKE cluster using Terraform]]

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Advertising: