<p>I am looking for terraform code to use sole tenant nodes in GKE cluster.</p>
<p>I found the below reference on Google Cloud Docs, but I am unable to find the code in terraform.</p>
<p><a href="https://cloud.google.com/kubernetes-engine/docs/how-to/sole-tenancy" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/sole-tenancy</a></p>
<p>Here is the snippet of the code I want to convert :</p>
<pre class="lang-sh prettyprint-override"><code>gcloud container node-pools create NODE_POOL_NAME \    
--node-group GROUP_NAME --cluster CLUSTER_NAME \    
--zone COMPUTE_ZONE --machine-type=MACHINE_TYPE \    
--node-locations=COMPUTE_ZONE,COMPUTE_ZONE1
</code></pre>

Mukund Gohil
<p>For GCP sole tenant comes under the node template you can check this out</p>
<pre><code>resource &quot;google_compute_node_template&quot; &quot;template&quot; {
  name      = &quot;soletenant-tmpl&quot;
  region    = &quot;us-central1&quot;
  node_type = &quot;n1-node-96-624&quot;
}
</code></pre>
<p>now adding the template to the node group</p>
<pre><code>resource &quot;google_compute_node_template&quot; &quot;soletenant-tmpl&quot; {
  name      = &quot;soletenant-tmpl&quot;
  region    = &quot;us-central1&quot;
  node_type = &quot;n1-node-96-624&quot;
}

resource &quot;google_compute_node_group&quot; &quot;nodes&quot; {
  name        = &quot;soletenant-group&quot;
  zone        = &quot;us-central1-a&quot;
  description = &quot;example google_compute_node_group for Terraform Google Provider&quot;
  maintenance_policy = &quot;RESTART_IN_PLACE&quot;
  size          = 1
  node_template = google_compute_node_template.soletenant-tmpl.id
  autoscaling_policy {
    mode      = &quot;ONLY_SCALE_OUT&quot;
    min_nodes = 1
    max_nodes = 10
  }
}
</code></pre>
<p>you can check : <a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_node_group" rel="nofollow noreferrer">https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_node_group</a></p>
