<p>I'm create k8s in Google Cloud using Terraform, several node pools contains GPU, according <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/gpus" rel="nofollow noreferrer">documentation</a> there should be applied DaemonSet with GPU drivers. It's possible to do it with Terraform or this operation requires my attention?</p>

Alexander Tolkachev
<p>As @Patric W and Google Cloud <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/gpus#installing_drivers" rel="nofollow noreferrer">documentation</a> mentioned:  </p>

<blockquote>
  <p>After adding GPU nodes to your cluster, you need to install NVIDIA's device drivers to the nodes. Google provides a DaemonSet that automatically installs the drivers for you.</p>
</blockquote>

<p>So all We have to do is to apply <a href="https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/nvidia-driver-installer/ubuntu/daemonset-preloaded.yaml" rel="nofollow noreferrer">DaemonSet</a> provided by Google.</p>

<p>For Container-Optimized OS (COS) nodes:</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/nvidia-driver-installer/cos/daemonset-preloaded.yaml
</code></pre>

<p>For Ubuntu Nodes:</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/nvidia-driver-installer/ubuntu/daemonset-preloaded.yaml
</code></pre>

<hr>

<p>Based on Terraform <a href="https://www.terraform.io/docs/provisioners/local-exec.html" rel="nofollow noreferrer">documentation</a> You can use <code>provisioner "local-exec"</code> to run kubectl apply command for DaemonSet after successful cluster deployment.</p>

<pre><code>provisioner "local-exec" {
    command = "kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/nvidia-driver-installer/cos/daemonset-preloaded.yaml"
  }
}
</code></pre>

<p>Note that example above is for COS node version.</p>
