Skip to content

Commit 3ddf7fd

Browse files
author
French Ben
committed
Added LB rules for ucp and dtr
Signed-off-by: French Ben <[email protected]>
1 parent 4add5bb commit 3ddf7fd

File tree

2 files changed

+116
-25
lines changed

2 files changed

+116
-25
lines changed

azure/release/files/release.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ def main():
5757
flat_edition_version = edition_version.replace(" ", "")
5858
vhd_sku = args.vhd_sku
5959
vhd_version = args.vhd_version
60+
offer_id = args.offer_id
6061
cs_vhd_sku = args.cs_vhd_sku
6162
cs_vhd_version = args.cs_vhd_version
63+
cs_offer_id = args.cs_offer_id
6264

6365
docker_for_azure_version = u"azure-v{}".format(flat_edition_version)
6466
image_name = u"Moby Linux {}".format(docker_for_azure_version)
@@ -76,14 +78,14 @@ def main():
7678

7779
print("Create CloudFormation template..")
7880
template_name = u"{}.json".format(docker_for_azure_version)
79-
base_url = create_rg_template(vhd_sku, vhd_version, release_channel, docker_version,
81+
base_url = create_rg_template(vhd_sku, vhd_version, offer_id, release_channel, docker_version,
8082
docker_for_azure_version, edition_version, CFN_TEMPLATE, template_name)
8183
cloud_template_name = u"{}-cloud.json".format(docker_for_azure_version)
8284
cloud_url = create_rg_cloud_template(release_cloud_channel, docker_version,
8385
docker_for_azure_version, edition_version, base_url, cloud_template_name)
8486

8587
ddc_template_name = u"{}-ddc.json".format(docker_for_azure_version)
86-
ddc_url = create_rg_ddc_template(cs_vhd_sku, cs_vhd_version, release_ddc_channel, docker_version,
88+
ddc_url = create_rg_ddc_template(cs_vhd_sku, cs_vhd_version, cs_offer_id, release_ddc_channel, docker_version,
8789
docker_for_azure_version, edition_version, base_url, ddc_template_name)
8890

8991
print("------------------")

azure/release/files/utils.py

Lines changed: 112 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def upload_rg_template(release_channel, cloudformation_template_name, tempfile,
7373

7474
return s3_full_url
7575

76-
def create_rg_template(vhd_sku, vhd_version, release_channel, docker_version,
76+
def create_rg_template(vhd_sku, vhd_version, offer_id, release_channel, docker_version,
7777
docker_for_azure_version, edition_version, cfn_template, cloudformation_template_name):
7878
# check if file exists before opening.
7979
flat_edition_version = edition_version.replace(" ", "").replace("_", "").replace("-", "")
@@ -85,6 +85,7 @@ def create_rg_template(vhd_sku, vhd_version, release_channel, docker_version,
8585
data['variables']['Description'] = u"Docker for Azure {0} ({1})".format(docker_version, edition_version)
8686
data['variables']['imageSku'] = vhd_sku
8787
data['variables']['imageVersion'] = vhd_version
88+
data['variables']['imageOffer'] = offer_id
8889
data['variables']['dockerForIAASVersion'] = docker_for_azure_version
8990

9091
# Updated Manager custom data
@@ -185,7 +186,7 @@ def create_rg_cloud_template(release_channel, docker_version,
185186

186187
return outfile
187188

188-
def create_rg_ddc_template(vhd_sku, vhd_version, release_channel, docker_version,
189+
def create_rg_ddc_template(vhd_sku, vhd_version, offer_id, release_channel, docker_version,
189190
docker_for_azure_version, edition_version, cfn_template, cloudformation_template_name):
190191
with open(cfn_template) as data_file:
191192
data = json.load(data_file)
@@ -199,9 +200,21 @@ def create_rg_ddc_template(vhd_sku, vhd_version, release_channel, docker_version
199200

200201
data['variables']['imageSku'] = vhd_sku
201202
data['variables']['imageVersion'] = vhd_version
203+
data['variables']['imageOffer'] = offer_id
202204

205+
# Use multiple steps to keep order
203206
parameters = data.get('parameters')
204207
if parameters:
208+
new_parameters = {
209+
"DDCUsername": {
210+
"defaultValue": "admin",
211+
"type": "String",
212+
"metadata": {
213+
"description": "Please enter the username you want to use for Docker Datacenter."
214+
}
215+
}
216+
}
217+
parameters.update(new_parameters)
205218
new_parameters = {
206219
"DDCPassword": {
207220
"minLength": 8,
@@ -210,13 +223,6 @@ def create_rg_ddc_template(vhd_sku, vhd_version, release_channel, docker_version
210223
"metadata": {
211224
"description": "Please enter the password you want to use for Docker Datacenter."
212225
}
213-
},
214-
"DDCUsername": {
215-
"defaultValue": "admin",
216-
"type": "String",
217-
"metadata": {
218-
"description": "Please enter the username you want to use for Docker Datacenter."
219-
}
220226
}
221227
}
222228
parameters.update(new_parameters)
@@ -232,22 +238,105 @@ def create_rg_ddc_template(vhd_sku, vhd_version, release_channel, docker_version
232238
for key, val in enumerate(data.get('resources')):
233239
if val['name'] == "[variables('managerNSGName')]":
234240
security_rules = val['properties']['securityRules']
235-
new_security_rule = {
236-
"name": "ddc",
237-
"properties": {
238-
"description": "Allow UCP",
239-
"protocol": "Tcp",
240-
"sourcePortRange": "*",
241-
"destinationPortRange": "443",
242-
"sourceAddressPrefix": "*",
243-
"destinationAddressPrefix": "*",
244-
"access": "Allow",
245-
"priority": 206,
246-
"direction": "Inbound"
241+
new_security_rule = [
242+
{
243+
"name": "ucp",
244+
"properties": {
245+
"description": "Allow UCP",
246+
"protocol": "Tcp",
247+
"sourcePortRange": "*",
248+
"destinationPortRange": "443",
249+
"sourceAddressPrefix": "*",
250+
"destinationAddressPrefix": "*",
251+
"access": "Allow",
252+
"priority": 206,
253+
"direction": "Inbound"
254+
}
255+
},
256+
{
257+
"name": "dtr",
258+
"properties": {
259+
"description": "Allow DTR",
260+
"protocol": "Tcp",
261+
"sourcePortRange": "*",
262+
"destinationPortRange": "8443",
263+
"sourceAddressPrefix": "*",
264+
"destinationAddressPrefix": "*",
265+
"access": "Allow",
266+
"priority": 207,
267+
"direction": "Inbound"
268+
}
247269
}
270+
]
271+
security_rules.extend(new_security_rule)
272+
if val['name'] == "[variables('lbSSHName')]":
273+
properties = val['properties']
274+
275+
loadbalancing_rules = {
276+
"loadBalancingRules": [
277+
{
278+
"name": "ucpLbRule",
279+
"properties": {
280+
"frontendIPConfiguration": {
281+
"id": "[variables('lbSSHFrontEndIPConfigID')]"
282+
},
283+
"backendAddressPool": {
284+
"id": "[concat(variables('lbSSHID'), '/backendAddressPools/default')]"
285+
},
286+
"protocol": "tcp",
287+
"frontendPort": 443,
288+
"backendPort": 443,
289+
"enableFloatingIP": False,
290+
"idleTimeoutInMinutes": 5,
291+
"probe": {
292+
"id": "[concat(variables('lbSSHID'),'/probes/ucp')]"
293+
}
294+
}
295+
},
296+
{
297+
"name": "dtrLbRule",
298+
"properties": {
299+
"frontendIPConfiguration": {
300+
"id": "[variables('lbSSHFrontEndIPConfigID')]"
301+
},
302+
"backendAddressPool": {
303+
"id": "[concat(variables('lbSSHID'), '/backendAddressPools/default')]"
304+
},
305+
"protocol": "tcp",
306+
"frontendPort": 8443,
307+
"backendPort": 8443,
308+
"enableFloatingIP": False,
309+
"idleTimeoutInMinutes": 5,
310+
"probe": {
311+
"id": "[concat(variables('lbSSHID'),'/probes/dtr')]"
312+
}
313+
}
314+
},
315+
]
248316
}
249-
security_rules.append(new_security_rule)
250-
break
317+
properties.update(loadbalancing_rules)
318+
probes = val['properties']['probes']
319+
new_probe = [
320+
{
321+
"name": "ucp",
322+
"properties": {
323+
"intervalInSeconds": 10,
324+
"numberOfProbes": 2,
325+
"port": 443,
326+
"protocol": "Tcp"
327+
}
328+
},
329+
{
330+
"name": "dtr",
331+
"properties": {
332+
"intervalInSeconds": 10,
333+
"numberOfProbes": 2,
334+
"port": 8443,
335+
"protocol": "Tcp"
336+
}
337+
}
338+
]
339+
probes.extend(new_probe)
251340
outputs = data.get('outputs')
252341
if outputs:
253342
new_outputs = {

0 commit comments

Comments
 (0)