This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled preprovisioning on windows dcos agents (#2228)
- Loading branch information
1 parent
79a057f
commit e7b78ce
Showing
9 changed files
with
235 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# hello-world-dcos Extension | ||
|
||
Sample hello-world extension. Calls the following on the master: | ||
|
||
``` | ||
curl -X post http://localhost:8080/v2/apps -d "{ \"id\": \"hello-marathon\", \"cmd\": \"while [ true ] ; do echo 'Hello World' ; sleep 5 ; done\", \"cpus\": 0.1, \"mem\": 10.0, \"instances\": 1 }" -H "Content-type:application/json" | ||
``` | ||
|
||
You can validate that the extension was run by running (make sure you have tunneled into the master): | ||
``` | ||
dcos auth login | ||
dcos task log hello-marathon | ||
``` | ||
|
||
# Configuration | ||
|Name|Required|Acceptable Value| | ||
|---|---|---| | ||
|name|yes|hello-world-k8s| | ||
|version|yes|v1| | ||
|extensionParameters|no|| | ||
|rootURL|optional|| | ||
|
||
# Example | ||
``` javascript | ||
"masterProfile": { | ||
... | ||
"extensions": [ | ||
{ | ||
"name": "hello-world-dcos", | ||
"singleOrAll": "single" | ||
} | ||
] | ||
}, | ||
... | ||
"extensionProfiles": [ | ||
{ | ||
"name": "hello-world-dcos", | ||
"version": "v1" | ||
} | ||
] | ||
|
||
|
||
``` | ||
|
||
# Supported Orchestrators | ||
"DCOS", "DCOS173", "DCOS184", "DCOS188" |
20 changes: 20 additions & 0 deletions
20
extensions/hello-world-dcos-windows/v1/hello-world-dcos.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Script file to run hello-world in dcos | ||
|
||
#!/usr/bin/pwsh | ||
|
||
|
||
Write-Host "$(date) - Starting Script" | ||
|
||
# Deploy container | ||
Write-Host "$(date) - Deploying hello-world" | ||
|
||
$uri = "http://"+($env:DCOS_AGENT_IP)+":5051/metrics/snapshot" | ||
while($true) { | ||
$obj = ((Invoke-Webrequest -Method GET -URI $uri ).Content | ConvertFrom-JSON ) | ||
Write-Host "$(date) - system/cpus_total = " ($obj.'system/cpus_total') ", mem free bytes = " ($obj.'system/mem_free_bytes') ", mem total bytes = " ($obj.'system/mem_total_bytes') | ||
sleep 5 | ||
} | ||
|
||
Write-Host "$(date) - view resources in mesos UI to validate" | ||
Write-Host "$(date) - Script complete" | ||
|
1 change: 1 addition & 0 deletions
1
extensions/hello-world-dcos-windows/v1/supported-orchestrators.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["DCOS", "DCOS173", "DCOS184", "DCOS188", "DCOS190"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "[concat(EXTENSION_TARGET_VM_NAME_PREFIX, copyIndex(EXTENSION_LOOP_OFFSET), 'HelloWorldDcos')]", | ||
"type": "Microsoft.Resources/deployments", | ||
"apiVersion": "[variables('apiVersionLinkDefault')]", | ||
"dependsOn": [ | ||
"[resourceId('Microsoft.Compute/virtualMachines/extensions', concat(variables('masterVMNamePrefix'), sub(variables('masterCount'), 1)), 'waitforleader')]" | ||
], | ||
"copy": { | ||
"count": "EXTENSION_LOOP_COUNT", | ||
"name": "helloWorldExtensionLoop" | ||
}, | ||
"properties": { | ||
"mode": "Incremental", | ||
"templateLink": { | ||
"uri": "EXTENSION_URL_REPLACEextensions/hello-world-dcos-windows/v1/template.json", | ||
"contentVersion": "1.0.0.0" | ||
}, | ||
"parameters": { | ||
"artifactsLocation": { | ||
"value": "EXTENSION_URL_REPLACE" | ||
}, | ||
"apiVersionDefault": { | ||
"value": "[variables('apiVersionDefault')]" | ||
}, | ||
"targetVMName": { | ||
"value": "[concat(EXTENSION_TARGET_VM_NAME_PREFIX, copyIndex(EXTENSION_LOOP_OFFSET))]" | ||
}, | ||
"extensionParameters": { | ||
"value": "EXTENSION_PARAMETERS_REPLACE" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"artifactsLocation": { | ||
"type": "string", | ||
"minLength": 1, | ||
"metadata": { | ||
"description": "Artifacts Location - URL" | ||
} | ||
}, | ||
"apiVersionDefault": { | ||
"type": "string", | ||
"minLength": 1, | ||
"metadata": { | ||
"description": "Compute API Version" | ||
} | ||
}, | ||
"targetVMName":{ | ||
"type": "string", | ||
"minLength": 1, | ||
"metadata": { | ||
"description": "Name of the vm to run the " | ||
} | ||
}, | ||
"extensionParameters": { | ||
"type": "securestring", | ||
"minLength": 0, | ||
"metadata": { | ||
"description": "Custom Parameter for Extension - for hello-world, this is empty" | ||
} | ||
} | ||
}, | ||
"variables": { | ||
"singleQuote": "'", | ||
"initScriptUrl": "[concat(parameters('artifactsLocation'), 'extensions/hello-world-dcos-windows/v1/hello-world-dcos.ps1')]" | ||
}, | ||
"resources": [ | ||
{ | ||
"apiVersion": "[parameters('apiVersionDefault')]", | ||
"dependsOn": [], | ||
"location": "[resourceGroup().location]", | ||
"type": "Microsoft.Compute/virtualMachines/extensions", | ||
"name": "[concat(parameters('targetVMName'),'/waitforleader')]", | ||
"properties": { | ||
"publisher": "Microsoft.OSTCExtensions", | ||
"type": "CustomScriptForLinux", | ||
"typeHandlerVersion": "1.5", | ||
"autoUpgradeMinorVersion": true, | ||
"settings": { | ||
"fileUris": [ | ||
"[variables('initScriptUrl')]" | ||
] | ||
}, | ||
"protectedSettings": { | ||
"commandToExecute": "[concat('powershell \"./hello-world-dcos.ps1 ', variables('singleQuote'), parameters('extensionParameters'), variables('singleQuote'), ' >> c:/azuredata/hello-world-dcos-provision.log 2>&1 &\" &')]" | ||
} | ||
} | ||
} | ||
], | ||
"outputs": { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters