Skip to content

Commit d0d58a7

Browse files
Add example for create a GKE Windows node pool to the docs. (#4000) (#2506)
Signed-off-by: Modular Magician <[email protected]>
1 parent 60bb053 commit d0d58a7

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

.changelog/4000.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```release-note:none
2+
```

website/docs/guides/using_gke_with_terraform.html.markdown

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: |-
88

99
# Using GKE with Terraform
1010

11-
-> Visit the [Provision a GKE Cluster (Google Cloud)](https://learn.hashicorp.com/tutorials/terraform/gke?in=terraform/kubernetes&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) Learn tutorial to learn how to provision and interact
11+
-> Visit the [Provision a GKE Cluster (Google Cloud)](https://learn.hashicorp.com/tutorials/terraform/gke?in=terraform/kubernetes&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) Learn tutorial to learn how to provision and interact
1212
with a GKE cluster.
1313

1414
This page is a brief overview of GKE usage with Terraform, based on the content
@@ -145,7 +145,7 @@ resource "google_container_cluster" "my_vpc_native_cluster" {
145145

146146
## Node Pool Management
147147

148-
In Terraform, we recommend managing your node pools using the
148+
In Terraform, we recommend managing your node pools using the
149149
`google_container_node_pool` resource, separate from the
150150
`google_container_cluster` resource. This separates cluster-level configuration
151151
like networking and Kubernetes features from the configuration of your nodes.
@@ -201,3 +201,65 @@ resource "google_container_cluster" "my-gke-cluster" {
201201
# other settings...
202202
}
203203
```
204+
205+
### Windows Node Pools
206+
207+
You can add
208+
[Windows Server node pools](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows)
209+
to your GKE cluster by adding `google_container_node_pool` to your Terraform
210+
configuration with `image_type=WINDOWS_LTSC` or `WINDOWS_SAC`.
211+
212+
```hcl
213+
resource "google_container_cluster" "demo_cluster" {
214+
project = "" # Replace with your Project ID, https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects
215+
name = "demo-cluster"
216+
location = "us-west1-a"
217+
218+
min_master_version = "1.16"
219+
220+
# Enable Alias IPs to allow Windows Server networking.
221+
ip_allocation_policy {
222+
cluster_ipv4_cidr_block = "/14"
223+
services_ipv4_cidr_block = "/20"
224+
}
225+
226+
# Removes the implicit default node pool, recommended when using
227+
# google_container_node_pool.
228+
remove_default_node_pool = true
229+
initial_node_count = 1
230+
}
231+
232+
# Small Linux node pool to run some Linux-only Kubernetes Pods.
233+
resource "google_container_node_pool" "linux_pool" {
234+
name = "linux-pool"
235+
project = google_container_cluster.demo_cluster.project
236+
cluster = google_container_cluster.demo_cluster.name
237+
location = google_container_cluster.demo_cluster.location
238+
239+
node_config {
240+
image_type = "COS_CONTAINERD"
241+
}
242+
}
243+
244+
# Node pool of Windows Server machines.
245+
resource "google_container_node_pool" "windows_pool" {
246+
name = "windows-pool"
247+
project = google_container_cluster.demo_cluster.project
248+
cluster = google_container_cluster.demo_cluster.name
249+
location = google_container_cluster.demo_cluster.location
250+
251+
node_config {
252+
machine_type = "e2-standard-4"
253+
image_type = "WINDOWS_LTSC" # Or WINDOWS_SAC for new features.
254+
}
255+
256+
# The Linux node pool must be created before the Windows Server node pool.
257+
depends_on = [google_container_node_pool.linux_pool]
258+
}
259+
```
260+
261+
The example above creates a cluster with a small Linux node pool and a Windows
262+
Server node pool. The Linux node pool is necessary since some critical pods are
263+
not yet supported on Windows. Please see
264+
[Limitations](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#limitations)
265+
for details on features that are not supported by Windows Server node pools.

0 commit comments

Comments
 (0)