|
| 1 | +/** |
| 2 | +* Copyright 2025 Google LLC |
| 3 | +* |
| 4 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +* you may not use this file except in compliance with the License. |
| 6 | +* You may obtain a copy of the License at |
| 7 | +* |
| 8 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +* |
| 10 | +* Unless required by applicable law or agreed to in writing, software |
| 11 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +* See the License for the specific language governing permissions and |
| 14 | +* limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +# NOTE: Locations are different in these examples to satisfy the tests. |
| 18 | +# These are intended to represent sequential steps on the same cluster. |
| 19 | + |
| 20 | +# [START gke_standard_release_channel_none] |
| 21 | +resource "google_container_cluster" "rc_none" { |
| 22 | + name = "cluster-zonal-example-none-to-rc" |
| 23 | + location = "us-central1-a" |
| 24 | + |
| 25 | + release_channel { |
| 26 | + channel = "UNSPECIFIED" |
| 27 | + } |
| 28 | + |
| 29 | + remove_default_node_pool = true |
| 30 | + initial_node_count = 1 |
| 31 | + |
| 32 | + # Set `deletion_protection` to `true` will ensure that one cannot |
| 33 | + # accidentally delete this instance by use of Terraform. |
| 34 | + deletion_protection = false |
| 35 | +} |
| 36 | + |
| 37 | +resource "google_container_node_pool" "rc_none" { |
| 38 | + name = "cluster-zonal-example-none-to-rc-np" |
| 39 | + cluster = google_container_cluster.rc_none.id |
| 40 | + |
| 41 | + node_count = 2 |
| 42 | + |
| 43 | + management { |
| 44 | + auto_repair = false |
| 45 | + auto_upgrade = false |
| 46 | + } |
| 47 | +} |
| 48 | +# [END gke_standard_release_channel_none] |
| 49 | + |
| 50 | +# [START gke_standard_release_channel_no_upgrade] |
| 51 | +resource "google_container_cluster" "no_upgrade" { |
| 52 | + name = "cluster-zonal-example-none-to-rc" |
| 53 | + location = "us-central1-b" |
| 54 | + |
| 55 | + release_channel { |
| 56 | + channel = "UNSPECIFIED" |
| 57 | + } |
| 58 | + |
| 59 | + maintenance_policy { |
| 60 | + # A recurring window must be set to use maintenance exclusions in Terraform. |
| 61 | + recurring_window { |
| 62 | + start_time = "2025-02-11T19:16:39Z" |
| 63 | + end_time = "2025-02-11T23:16:39Z" |
| 64 | + recurrence = "FREQ=DAILY" |
| 65 | + } |
| 66 | + maintenance_exclusion { |
| 67 | + exclusion_name = "no_upgrades_exclusion" |
| 68 | + start_time = "2025-02-11T23:16:39Z" |
| 69 | + # NO_UPGRADES exclusions are limited to 30 days. |
| 70 | + end_time = "2025-03-11T23:16:39Z" |
| 71 | + exclusion_options { |
| 72 | + scope = "NO_UPGRADES" |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + remove_default_node_pool = true |
| 78 | + initial_node_count = 1 |
| 79 | + |
| 80 | + # Set `deletion_protection` to `true` will ensure that one cannot |
| 81 | + # accidentally delete this instance by use of Terraform. |
| 82 | + deletion_protection = false |
| 83 | +} |
| 84 | + |
| 85 | +resource "google_container_node_pool" "no_upgrade" { |
| 86 | + name = "cluster-zonal-example-none-to-rc-np" |
| 87 | + cluster = google_container_cluster.no_upgrade.id |
| 88 | + |
| 89 | + node_count = 2 |
| 90 | + |
| 91 | + management { |
| 92 | + auto_repair = false |
| 93 | + auto_upgrade = false |
| 94 | + } |
| 95 | +} |
| 96 | +# [END gke_standard_release_channel_no_upgrade] |
| 97 | + |
| 98 | +# [START gke_standard_release_channel_rc_regular] |
| 99 | +resource "google_container_cluster" "rc_regular" { |
| 100 | + name = "cluster-zonal-example-none-to-rc" |
| 101 | + location = "us-central1-c" |
| 102 | + |
| 103 | + release_channel { |
| 104 | + channel = "REGULAR" |
| 105 | + } |
| 106 | + |
| 107 | + maintenance_policy { |
| 108 | + recurring_window { |
| 109 | + start_time = "2025-02-11T19:16:39Z" |
| 110 | + end_time = "2025-02-11T23:16:39Z" |
| 111 | + recurrence = "FREQ=DAILY" |
| 112 | + } |
| 113 | + maintenance_exclusion { |
| 114 | + exclusion_name = "no_upgrades_exclusion" |
| 115 | + start_time = "2025-02-11T23:16:39Z" |
| 116 | + end_time = "2025-03-11T23:16:39Z" |
| 117 | + exclusion_options { |
| 118 | + scope = "NO_UPGRADES" |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + remove_default_node_pool = true |
| 124 | + initial_node_count = 1 |
| 125 | + |
| 126 | + # Set `deletion_protection` to `true` will ensure that one cannot |
| 127 | + # accidentally delete this instance by use of Terraform. |
| 128 | + deletion_protection = false |
| 129 | +} |
| 130 | + |
| 131 | +resource "google_container_node_pool" "rc_regular" { |
| 132 | + name = "cluster-zonal-example-none-to-rc-np" |
| 133 | + cluster = google_container_cluster.rc_regular.id |
| 134 | + |
| 135 | + node_count = 2 |
| 136 | + |
| 137 | + management { |
| 138 | + # Auto-repair and auto-upgrade should be set to true when moving to a |
| 139 | + # release channel. |
| 140 | + auto_repair = true |
| 141 | + auto_upgrade = true |
| 142 | + } |
| 143 | +} |
| 144 | +# [END gke_standard_release_channel_rc_regular] |
| 145 | + |
| 146 | +# [START gke_standard_release_channel_no_minor_or_node_upgrade] |
| 147 | +resource "google_container_cluster" "no_minor_or_node_upgrade" { |
| 148 | + name = "cluster-zonal-example-none-to-rc" |
| 149 | + location = "us-central1-f" |
| 150 | + |
| 151 | + release_channel { |
| 152 | + channel = "REGULAR" |
| 153 | + } |
| 154 | + |
| 155 | + maintenance_policy { |
| 156 | + recurring_window { |
| 157 | + start_time = "2025-02-11T19:16:39Z" |
| 158 | + end_time = "2025-02-11T23:16:39Z" |
| 159 | + recurrence = "FREQ=DAILY" |
| 160 | + } |
| 161 | + maintenance_exclusion { |
| 162 | + exclusion_name = "no_minor_or_node_upgrades_exclusion" |
| 163 | + start_time = "2025-02-11T23:16:39Z" |
| 164 | + # This the end of standard support for 1.31. |
| 165 | + end_time = "2025-12-22T00:00:00Z" |
| 166 | + exclusion_options { |
| 167 | + scope = "NO_MINOR_OR_NODE_UPGRADES" |
| 168 | + } |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + remove_default_node_pool = true |
| 173 | + initial_node_count = 1 |
| 174 | + |
| 175 | + # Set `deletion_protection` to `true` will ensure that one cannot |
| 176 | + # accidentally delete this instance by use of Terraform. |
| 177 | + deletion_protection = false |
| 178 | +} |
| 179 | + |
| 180 | +resource "google_container_node_pool" "no_minor_or_node_upgrade" { |
| 181 | + name = "cluster-zonal-example-none-to-rc-np" |
| 182 | + cluster = google_container_cluster.no_minor_or_node_upgrade.id |
| 183 | + |
| 184 | + node_count = 2 |
| 185 | + |
| 186 | + management { |
| 187 | + auto_repair = true |
| 188 | + auto_upgrade = true |
| 189 | + } |
| 190 | +} |
| 191 | +# [END gke_standard_release_channel_no_minor_or_node_upgrade] |
0 commit comments