Skip to content

Commit 13c9f48

Browse files
authored
Merge pull request #34 from dataiku/feature/dss13-sc-194130-gke-support-channel-for-standard-cluster
Adding support for release channels on standard clusters and cluster versions on autopilot clusters
2 parents cdd6d0a + e7c9780 commit 13c9f48

File tree

3 files changed

+63
-15
lines changed

3 files changed

+63
-15
lines changed

python-clusters/create-gke-cluster/cluster.json

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,50 @@
1818
"parameterSetId" : "connection-info",
1919
"mandatory" : true
2020
},
21-
{
22-
"name": "clusterVersion",
23-
"label": "Kubernetes version",
24-
"type": "STRING",
25-
"defaultValue": "latest",
26-
"visibilityCondition": "!model.isAutopilot"
27-
},
2821
{
2922
"name": "releaseChannel",
3023
"label": "Release Channel",
3124
"type": "SELECT",
3225
"defaultValue": "STABLE",
3326
"selectChoices": [
34-
{"label":"Stable", "value":"STABLE"},
35-
{"label":"Regular", "value":"REGULAR"},
36-
{"label":"Rapid", "value":"RAPID"}
27+
{ "label": "Stable", "value": "STABLE" },
28+
{ "label": "Regular", "value": "REGULAR" },
29+
{ "label": "Rapid", "value": "RAPID" }
3730
],
31+
"description": "Find more information on the release channels here: https://cloud.google.com/kubernetes-engine/docs/concepts/release-channels",
3832
"visibilityCondition": "model.isAutopilot"
3933
},
34+
{
35+
"name": "releaseChannelEnrollment",
36+
"label": "Enroll into a release channel",
37+
"type": "BOOLEAN",
38+
"defaultValue": true,
39+
"description": "Whether the cluster should be enrolled in a release channel (recommended).",
40+
"visibilityCondition": "!model.isAutopilot"
41+
},
42+
{
43+
"name": "standardReleaseChannel",
44+
"label": "Release Channel",
45+
"type": "SELECT",
46+
"defaultValue": "DEFAULT",
47+
"selectChoices": [
48+
{ "label": "Default (recommended)", "value": "DEFAULT" },
49+
{ "label": "Stable", "value": "STABLE" },
50+
{ "label": "Regular", "value": "REGULAR" },
51+
{ "label": "Rapid", "value": "RAPID" },
52+
{ "label": "Extended", "value": "EXTENDED" }
53+
],
54+
"description": "Default will enroll you in the most stable channel for the version you have selected.\nIf you have defined 'latest' for your cluster version, you will be enrolled in the 'Regular' channel.\nFind more information on the release channels here: https://cloud.google.com/kubernetes-engine/docs/concepts/release-channels",
55+
"visibilityCondition": "!model.isAutopilot && model.releaseChannelEnrollment"
56+
},
57+
{
58+
"name": "clusterVersion",
59+
"label": "Kubernetes version",
60+
"type": "STRING",
61+
"defaultValue": "latest",
62+
"description": "Defaults to the latest version of the configured release channel (or if not enrolled, to a default version in the Regular channel). Find more information on the available versions here: https://cloud.google.com/kubernetes-engine/docs/release-notes",
63+
"visibilityCondition": "!model.isAutopilot"
64+
},
4065
{
4166
"name": "isRegional",
4267
"label": "Regional",

python-clusters/create-gke-cluster/cluster.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ def start(self):
3232
cluster_builder.with_name(self.cluster_name)
3333
if is_autopilot:
3434
cluster_builder.with_regional(True, []) # autopilot => regional
35-
cluster_builder.with_autopilot(True, self.config.get("releaseChannel", "STABLE"))
35+
cluster_builder.with_autopilot(True)
36+
cluster_builder.with_release_channel(self.config.get("releaseChannel", "STABLE"))
3637
else:
3738
cluster_builder.with_version(self.config.get("clusterVersion", "latest"))
39+
cluster_builder.with_release_channel_enrollment(self.config.get("releaseChannelEnrollment", True))
40+
cluster_builder.with_release_channel(self.config.get("standardReleaseChannel", "DEFAULT"))
3841
cluster_builder.with_initial_node_count(self.config.get("numNodes", 3))
42+
43+
3944
cluster_builder.with_network(self.config.get("inheritFromDSSHost", True),
4045
self.config.get("network", "").strip(),
4146
self.config.get("subNetwork", "").strip())

python-lib/dku_google/clusters.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def __init__(self, clusters):
210210
self.locations = []
211211
self.is_autopilot = False
212212
self.release_channel = 'STABLE'
213+
self.release_channel_enrollment = True
213214
self.settings_valve = None
214215

215216
def with_name(self, name):
@@ -220,11 +221,18 @@ def with_version(self, version):
220221
self.version = version
221222
return self
222223

223-
def with_autopilot(self, is_autopilot, release_channel):
224+
def with_autopilot(self, is_autopilot):
224225
self.is_autopilot = is_autopilot
225-
self.release_channel = release_channel
226226
return self
227227

228+
def with_release_channel(self, release_channel):
229+
self.release_channel = release_channel
230+
return self
231+
232+
def with_release_channel_enrollment(self, release_channel_enrollment):
233+
self.release_channel_enrollment = release_channel_enrollment
234+
return self
235+
228236
def with_regional(self, is_regional, locations=[]):
229237
self.is_regional = is_regional
230238
self.locations = locations
@@ -347,8 +355,18 @@ def build(self):
347355

348356
if self.is_autopilot:
349357
create_cluster_request_body['cluster']['autopilot'] = {"enabled":True}
350-
create_cluster_request_body['cluster']['releaseChannel'] = {"channel":self.release_channel}
351-
358+
359+
if not self.is_autopilot and not self.release_channel_enrollment:
360+
# We can prevent the cluster from being enrolled into a release channel by not specifying the channel to enroll into.
361+
# However, the release channel object must be specified otherwise the cluster will be enrolled into the most stable release channel that supports the cluster version.
362+
# Note that autopilot clusters must be enrolled into either of the Rapid, Regular or Stable release channels (Extended not supported)
363+
create_cluster_request_body['cluster']['releaseChannel'] = {}
364+
elif self.release_channel != "DEFAULT":
365+
# Specify the release channel to enroll into.
366+
# If the channel is default (only possible with standard clusters),
367+
# the cluster will be automatically enrolled in the most stable channel possible for the defined cluster version (Regular if the version is 'latest')
368+
create_cluster_request_body['cluster']['releaseChannel'] = {"channel": self.release_channel}
369+
352370
if not _is_none_or_blank(self.settings_valve):
353371
valve = json.loads(self.settings_valve)
354372
create_cluster_request_body["cluster"] = _merge_objects(create_cluster_request_body["cluster"], valve)

0 commit comments

Comments
 (0)