Skip to content

Commit 0e18130

Browse files
authored
Add osSku field to NodePoolConfig (#209)
1 parent f4bbb95 commit 0e18130

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

cli/internal/install/cloudinstall/cloudconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type ClusterConfig struct {
9898
type NodePoolConfig struct {
9999
Name string `json:"name"`
100100
VMSize string `json:"vmSize"`
101+
OsSku string `json:"osSku"`
101102
MinCount int32 `json:"minCount"`
102103
MaxCount int32 `json:"maxCount"`
103104
}

cli/internal/install/cloudinstall/compute.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (inst *Installer) createCluster(ctx context.Context, clusterConfig *Cluster
143143
MinCount: &clusterConfig.SystemNodePool.MinCount,
144144
MaxCount: &clusterConfig.SystemNodePool.MaxCount,
145145
OSType: Ptr(armcontainerservice.OSTypeLinux),
146-
OSSKU: Ptr(armcontainerservice.OSSKUAzureLinux),
146+
OSSKU: Ptr(armcontainerservice.OSSKU(clusterConfig.SystemNodePool.OsSku)),
147147
Tags: tags,
148148
},
149149
}
@@ -159,7 +159,7 @@ func (inst *Installer) createCluster(ctx context.Context, clusterConfig *Cluster
159159
MinCount: &np.MinCount,
160160
MaxCount: &np.MaxCount,
161161
OSType: Ptr(armcontainerservice.OSTypeLinux),
162-
OSSKU: Ptr(armcontainerservice.OSSKUAzureLinux),
162+
OSSKU: Ptr(armcontainerservice.OSSKU(np.OsSku)),
163163
NodeLabels: map[string]*string{
164164
"tyger": Ptr("run"),
165165
},
@@ -293,6 +293,11 @@ func (inst *Installer) createCluster(ctx context.Context, clusterConfig *Cluster
293293

294294
poller, err = clustersClient.BeginCreateOrUpdate(ctx, inst.Config.Cloud.ResourceGroup, clusterConfig.Name, cluster, nil)
295295
if err != nil {
296+
var respErr *azcore.ResponseError
297+
if errors.As(err, &respErr) && respErr.ErrorCode == "InvalidOSSKU" {
298+
return nil, fmt.Errorf("failed to create cluster: adjust the `osSku` field on the node pool: %w", err)
299+
}
300+
296301
return nil, fmt.Errorf("failed to create cluster: %w", err)
297302
}
298303

cli/internal/install/cloudinstall/config.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ cloud:
3030
vmSize: Standard_DS12_v2
3131
minCount: {{ .CpuNodePoolMinCount }}
3232
maxCount: 10
33+
# osSku: defaults to AzureLinux
3334
- name: gpunp
3435
vmSize: Standard_NC6s_v3
3536
minCount: {{ .GpuNodePoolMinCount }}
3637
maxCount: 10
38+
# osSku: defaults to AzureLinux
3739

3840
# These are the principals that will have the ability to run `tyger api install`.
3941
# They will have access to the "tyger" namespace in each cluster and will have

cli/internal/install/cloudinstall/validation.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ func quickValidateNodePoolConfig(success *bool, np *NodePoolConfig, minNodeCount
200200
if np.MinCount > np.MaxCount {
201201
validationError(success, "The `minCount` field must be less than or equal to the `maxCount` field")
202202
}
203+
204+
if np.OsSku == "" {
205+
np.OsSku = string(armcontainerservice.OSSKUAzureLinux)
206+
} else {
207+
supportedValues := []string{string(armcontainerservice.OSSKUAzureLinux), string(armcontainerservice.OSSKUUbuntu)}
208+
if !slices.Contains(supportedValues, np.OsSku) {
209+
validationError(success, "The `osSku` field must be one of [%s]", strings.Join(supportedValues, ", "))
210+
}
211+
}
203212
}
204213

205214
func quickValidateStorageConfig(success *bool, cloudConfig *CloudConfig) {

docs/introduction/installation/cloud-installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ cloud:
7979
vmSize: Standard_DS12_v2
8080
minCount: 1
8181
maxCount: 10
82+
# osSku: defaults to AzureLinux
8283
- name: gpunp
8384
vmSize: Standard_NC6s_v3
8485
minCount: 0
8586
maxCount: 10
87+
# osSku: defaults to AzureLinux
8688

8789
# These are the principals that will have the ability to run `tyger api install`.
8890
# They will have access to the "tyger" namespace in each cluster and will have

0 commit comments

Comments
 (0)