How to apply kubernetes DaemonSet using Terraform in Google Cloud

11/18/2019

I'm create k8s in Google Cloud using Terraform, several node pools contains GPU, according documentation there should be applied DaemonSet with GPU drivers. It's possible to do it with Terraform or this operation requires my attention?

-- Alexander Tolkachev
google-cloud-platform
kubernetes
terraform

1 Answer

11/19/2019

As @Patric W and Google Cloud documentation mentioned:

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.

So all We have to do is to apply DaemonSet provided by Google.

For Container-Optimized OS (COS) nodes:

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

For Ubuntu Nodes:

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

Based on Terraform documentation You can use provisioner "local-exec" to run kubectl apply command for DaemonSet after successful cluster deployment.

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

Note that example above is for COS node version.

-- Piotr Malec
Source: StackOverflow