Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Added Windows Custom Image. Only works in dcos, but can be added to k8s #2004

Merged
merged 1 commit into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions parts/dcos/dcosWindowsAgentResourcesVmas.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
},
"type": "Microsoft.Network/networkSecurityGroups"
},
{{if HasWindowsCustomImage}}
{"type": "Microsoft.Compute/images",
"apiVersion": "2017-12-01",
"name": "{{.Name}}CustomWindowsImage",
"location": "[variables('location')]",
"properties": {
"storageProfile": {
"osDisk": {
"osType": "Windows",
"osState": "Generalized",
"blobUri": "[parameters('agentWindowsSourceUrl')]",
"storageAccountType": "Standard_LRS"
}
}
}
},
{{end}}
{
"apiVersion": "[variables('apiVersionDefault')]",
"copy": {
Expand Down Expand Up @@ -224,10 +241,14 @@
"storageProfile": {
{{GetDataDisks .}}
"imageReference": {
{{if HasWindowsCustomImage}}
"id": "[resourceId('Microsoft.Compute/images','{{.Name}}CustomWindowsImage')]"
{{else}}
"offer": "[variables('agentWindowsOffer')]",
"publisher": "[variables('agentWindowsPublisher')]",
"sku": "[variables('agentWindowsSKU')]",
"version": "[variables('agentWindowsVersion')]"
{{end}}
}
,"osDisk": {
"caching": "ReadOnly"
Expand Down
21 changes: 21 additions & 0 deletions parts/dcos/dcosWindowsAgentResourcesVmss.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
},
"type": "Microsoft.Network/networkSecurityGroups"
},
{{if HasWindowsCustomImage}}
{"type": "Microsoft.Compute/images",
"apiVersion": "2017-12-01",
"name": "{{.Name}}CustomWindowsImage",
"location": "[variables('location')]",
"properties": {
"storageProfile": {
"osDisk": {
"osType": "Windows",
"osState": "Generalized",
"blobUri": "[parameters('agentWindowsSourceUrl')]",
"storageAccountType": "Standard_LRS"
}
}
}
},
{{end}}
{{if .IsStorageAccount}}
{
"apiVersion": "[variables('apiVersionStorage')]",
Expand Down Expand Up @@ -152,10 +169,14 @@
},
"storageProfile": {
"imageReference": {
{{if HasWindowsCustomImage}}
"id": "[resourceId('Microsoft.Compute/images','{{.Name}}CustomWindowsImage')]"
{{else}}
"publisher": "[variables('agentWindowsPublisher')]",
"offer": "[variables('agentWindowsOffer')]",
"sku": "[variables('agentWindowsSku')]",
"version": "latest"
{{end}}
},
{{GetDataDisks .}}
"osDisk": {
Expand Down
9 changes: 8 additions & 1 deletion parts/windowsparams.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
"description": "Version of the Windows Server 2016 OS image to use for the agent virtual machines."
},
"type": "string"
}
},
"agentWindowsSourceUrl": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this different from WindowsImageSourceUrl?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, it isn't except its in variables() rather than parameters().

"defaultValue": "",
"metadata": {
"description": "The source of the generalized blob which will be used to create a custom windows image for the agent virtual machines."
},
"type": "string"
}
6 changes: 6 additions & 0 deletions pkg/acsengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ func getParameters(cs *api.ContainerService, isClassicMode bool, generatorCode s
if properties.WindowsProfile.ImageVersion != "" {
addValue(parametersMap, "agentWindowsVersion", properties.WindowsProfile.ImageVersion)
}
if properties.WindowsProfile.WindowsImageSourceURL != "" {
addValue(parametersMap, "agentWindowsSourceUrl", properties.WindowsProfile.WindowsImageSourceURL)
}
if properties.OrchestratorProfile.OrchestratorType == api.Kubernetes {
k8sVersion := properties.OrchestratorProfile.OrchestratorVersion
addValue(parametersMap, "kubeBinariesSASURL", cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase+KubeConfigs[k8sVersion]["windowszip"])
Expand Down Expand Up @@ -1197,6 +1200,9 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
"HasWindowsSecrets": func() bool {
return cs.Properties.WindowsProfile.HasSecrets()
},
"HasWindowsCustomImage": func() bool {
return cs.Properties.WindowsProfile.HasCustomImage()
},
"GetConfigurationScriptRootURL": func() string {
if cs.Properties.LinuxProfile.ScriptRootURL == "" {
return DefaultConfigurationScriptRootURL
Expand Down
1 change: 1 addition & 0 deletions pkg/acsengine/transform/json.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transform

import (
//fmt
"encoding/json"
"strings"

Expand Down
1 change: 1 addition & 0 deletions pkg/api/converterfromapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ func convertWindowsProfileToVLabs(api *WindowsProfile, vlabsProfile *vlabs.Windo
vlabsProfile.AdminUsername = api.AdminUsername
vlabsProfile.AdminPassword = api.AdminPassword
vlabsProfile.ImageVersion = api.ImageVersion
vlabsProfile.WindowsImageSourceURL = api.WindowsImageSourceURL
vlabsProfile.Secrets = []vlabs.KeyVaultSecrets{}
for _, s := range api.Secrets {
secret := &vlabs.KeyVaultSecrets{}
Expand Down
1 change: 1 addition & 0 deletions pkg/api/convertertoapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ func convertVLabsWindowsProfile(vlabs *vlabs.WindowsProfile, api *WindowsProfile
api.AdminUsername = vlabs.AdminUsername
api.AdminPassword = vlabs.AdminPassword
api.ImageVersion = vlabs.ImageVersion
api.WindowsImageSourceURL = vlabs.WindowsImageSourceURL
api.Secrets = []KeyVaultSecrets{}
for _, s := range vlabs.Secrets {
secret := &KeyVaultSecrets{}
Expand Down
14 changes: 10 additions & 4 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ type PublicKey struct {

// WindowsProfile represents the windows parameters passed to the cluster
type WindowsProfile struct {
AdminUsername string `json:"adminUsername"`
AdminPassword string `json:"adminPassword"`
ImageVersion string `json:"imageVersion"`
Secrets []KeyVaultSecrets `json:"secrets,omitempty"`
AdminUsername string `json:"adminUsername"`
AdminPassword string `json:"adminPassword"`
ImageVersion string `json:"imageVersion"`
WindowsImageSourceURL string `json:"windowsImageSourceURL"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend apply to whole cluster (all agent pools). or per agent pool, but not both. Which matches your scenario better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whole cluster. I beleive that is doing that. Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If "whole cluster" is your scenario, I think you can completely remove the per node pool change you made in parts/agentparams.t.

Secrets []KeyVaultSecrets `json:"secrets,omitempty"`
}

// ProvisioningState represents the current state of container service resource.
Expand Down Expand Up @@ -556,6 +557,11 @@ func (w *WindowsProfile) HasSecrets() bool {
return len(w.Secrets) > 0
}

// HasCustomImage returns true if there is a custom windows os image url specified
func (w *WindowsProfile) HasCustomImage() bool {
return len(w.WindowsImageSourceURL) > 0
}

// HasSecrets returns true if the customer specified secrets to install
func (l *LinuxProfile) HasSecrets() bool {
return len(l.Secrets) > 0
Expand Down
9 changes: 5 additions & 4 deletions pkg/api/vlabs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ type PublicKey struct {

// WindowsProfile represents the windows parameters passed to the cluster
type WindowsProfile struct {
AdminUsername string `json:"adminUsername,omitempty"`
AdminPassword string `json:"adminPassword,omitempty"`
ImageVersion string `json:"imageVersion,omitempty"`
Secrets []KeyVaultSecrets `json:"secrets,omitempty"`
AdminUsername string `json:"adminUsername,omitempty"`
AdminPassword string `json:"adminPassword,omitempty"`
ImageVersion string `json:"imageVersion,omitempty"`
WindowsImageSourceURL string `json:"WindowsImageSourceUrl"`
Secrets []KeyVaultSecrets `json:"secrets,omitempty"`
}

// ProvisioningState represents the current state of container service resource.
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func (o *OrchestratorProfile) Validate(isUpdate bool) error {
if o.OrchestratorType != DCOS && o.DcosConfig != nil && (*o.DcosConfig != DcosConfig{}) {
return fmt.Errorf("DcosConfig can be specified only when OrchestratorType is DCOS")
}

return nil
}

Expand Down Expand Up @@ -453,6 +454,12 @@ func (a *Properties) Validate(isUpdate bool) error {
}
}

if a.OrchestratorProfile.OrchestratorType != DCOS && a.WindowsProfile != nil {
if a.WindowsProfile.WindowsImageSourceURL != "" {
return fmt.Errorf("Windows Custom Images are only supported if the Orchestrator Type is DCOS")
}
}

return nil
}

Expand Down