@@ -82,42 +82,44 @@ type Model struct {
8282
8383// Struct corresponding to Model.NodePools[i]
8484type nodePool struct {
85- Name types.String `tfsdk:"name"`
86- MachineType types.String `tfsdk:"machine_type"`
87- OSName types.String `tfsdk:"os_name"`
88- OSVersionMin types.String `tfsdk:"os_version_min"`
89- OSVersion types.String `tfsdk:"os_version"`
90- OSVersionUsed types.String `tfsdk:"os_version_used"`
91- Minimum types.Int64 `tfsdk:"minimum"`
92- Maximum types.Int64 `tfsdk:"maximum"`
93- MaxSurge types.Int64 `tfsdk:"max_surge"`
94- MaxUnavailable types.Int64 `tfsdk:"max_unavailable"`
95- VolumeType types.String `tfsdk:"volume_type"`
96- VolumeSize types.Int64 `tfsdk:"volume_size"`
97- Labels types.Map `tfsdk:"labels"`
98- Taints types.List `tfsdk:"taints"`
99- CRI types.String `tfsdk:"cri"`
100- AvailabilityZones types.List `tfsdk:"availability_zones"`
85+ Name types.String `tfsdk:"name"`
86+ MachineType types.String `tfsdk:"machine_type"`
87+ OSName types.String `tfsdk:"os_name"`
88+ OSVersionMin types.String `tfsdk:"os_version_min"`
89+ OSVersion types.String `tfsdk:"os_version"`
90+ OSVersionUsed types.String `tfsdk:"os_version_used"`
91+ Minimum types.Int64 `tfsdk:"minimum"`
92+ Maximum types.Int64 `tfsdk:"maximum"`
93+ MaxSurge types.Int64 `tfsdk:"max_surge"`
94+ MaxUnavailable types.Int64 `tfsdk:"max_unavailable"`
95+ VolumeType types.String `tfsdk:"volume_type"`
96+ VolumeSize types.Int64 `tfsdk:"volume_size"`
97+ Labels types.Map `tfsdk:"labels"`
98+ Taints types.List `tfsdk:"taints"`
99+ CRI types.String `tfsdk:"cri"`
100+ AvailabilityZones types.List `tfsdk:"availability_zones"`
101+ AllowSystemComponents types.Bool `tfsdk:"allow_system_components"`
101102}
102103
103104// Types corresponding to nodePool
104105var nodePoolTypes = map [string ]attr.Type {
105- "name" : basetypes.StringType {},
106- "machine_type" : basetypes.StringType {},
107- "os_name" : basetypes.StringType {},
108- "os_version_min" : basetypes.StringType {},
109- "os_version" : basetypes.StringType {},
110- "os_version_used" : basetypes.StringType {},
111- "minimum" : basetypes.Int64Type {},
112- "maximum" : basetypes.Int64Type {},
113- "max_surge" : basetypes.Int64Type {},
114- "max_unavailable" : basetypes.Int64Type {},
115- "volume_type" : basetypes.StringType {},
116- "volume_size" : basetypes.Int64Type {},
117- "labels" : basetypes.MapType {ElemType : types .StringType },
118- "taints" : basetypes.ListType {ElemType : types.ObjectType {AttrTypes : taintTypes }},
119- "cri" : basetypes.StringType {},
120- "availability_zones" : basetypes.ListType {ElemType : types .StringType },
106+ "name" : basetypes.StringType {},
107+ "machine_type" : basetypes.StringType {},
108+ "os_name" : basetypes.StringType {},
109+ "os_version_min" : basetypes.StringType {},
110+ "os_version" : basetypes.StringType {},
111+ "os_version_used" : basetypes.StringType {},
112+ "minimum" : basetypes.Int64Type {},
113+ "maximum" : basetypes.Int64Type {},
114+ "max_surge" : basetypes.Int64Type {},
115+ "max_unavailable" : basetypes.Int64Type {},
116+ "volume_type" : basetypes.StringType {},
117+ "volume_size" : basetypes.Int64Type {},
118+ "labels" : basetypes.MapType {ElemType : types .StringType },
119+ "taints" : basetypes.ListType {ElemType : types.ObjectType {AttrTypes : taintTypes }},
120+ "cri" : basetypes.StringType {},
121+ "availability_zones" : basetypes.ListType {ElemType : types .StringType },
122+ "allow_system_components" : basetypes.BoolType {},
121123}
122124
123125// Struct corresponding to nodePool.Taints[i]
@@ -391,6 +393,12 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
391393 Required : true ,
392394 ElementType : types .StringType ,
393395 },
396+ "allow_system_components" : schema.BoolAttribute {
397+ Description : "Allow system components to run on this node pool." ,
398+ Optional : true ,
399+ Computed : true ,
400+ Default : booldefault .StaticBool (true ),
401+ },
394402 "minimum" : schema.Int64Attribute {
395403 Description : "Minimum number of nodes in the pool." ,
396404 Required : true ,
@@ -994,16 +1002,32 @@ func toNodepoolsPayload(ctx context.Context, m *Model, availableMachineVersions
9941002 Type : conversion .StringValueToPointer (nodePool .VolumeType ),
9951003 Size : conversion .Int64ValueToPointer (nodePool .VolumeSize ),
9961004 },
997- Taints : & ts ,
998- Cri : & cn ,
999- Labels : ls ,
1000- AvailabilityZones : & zs ,
1005+ Taints : & ts ,
1006+ Cri : & cn ,
1007+ Labels : ls ,
1008+ AvailabilityZones : & zs ,
1009+ AllowSystemComponents : conversion .BoolValueToPointer (nodePool .AllowSystemComponents ),
10011010 }
10021011 cnps = append (cnps , cnp )
10031012 }
1013+
1014+ if err := verifySystemComponentsInNodePools (cnps ); err != nil {
1015+ return nil , nil , err
1016+ }
1017+
10041018 return cnps , deprecatedVersionsUsed , nil
10051019}
10061020
1021+ // verifySystemComponentsInNodePools checks if at least one node pool has the allow_system_components attribute set to true.
1022+ func verifySystemComponentsInNodePools (nodePools []ske.Nodepool ) error {
1023+ for _ , nodePool := range nodePools {
1024+ if nodePool .AllowSystemComponents != nil && * nodePool .AllowSystemComponents {
1025+ return nil // A node pool allowing system components was found
1026+ }
1027+ }
1028+ return fmt .Errorf ("at least one node_pool must allow system components" )
1029+ }
1030+
10071031// latestMatchingMachineVersion determines the latest machine image version for the create/update payload.
10081032// It considers the available versions for the specified OS (OSName), the minimum version configured by the user,
10091033// and the current version in the cluster. The function's behavior is as follows:
@@ -1374,20 +1398,21 @@ func mapNodePools(ctx context.Context, cl *ske.Cluster, m *Model) error {
13741398 nodePools := []attr.Value {}
13751399 for i , nodePoolResp := range * cl .Nodepools {
13761400 nodePool := map [string ]attr.Value {
1377- "name" : types .StringPointerValue (nodePoolResp .Name ),
1378- "machine_type" : types .StringPointerValue (nodePoolResp .Machine .Type ),
1379- "os_name" : types .StringNull (),
1380- "os_version_min" : modelNodePoolOSVersionMin [* nodePoolResp .Name ],
1381- "os_version" : modelNodePoolOSVersion [* nodePoolResp .Name ],
1382- "minimum" : types .Int64PointerValue (nodePoolResp .Minimum ),
1383- "maximum" : types .Int64PointerValue (nodePoolResp .Maximum ),
1384- "max_surge" : types .Int64PointerValue (nodePoolResp .MaxSurge ),
1385- "max_unavailable" : types .Int64PointerValue (nodePoolResp .MaxUnavailable ),
1386- "volume_type" : types .StringNull (),
1387- "volume_size" : types .Int64PointerValue (nodePoolResp .Volume .Size ),
1388- "labels" : types .MapNull (types .StringType ),
1389- "cri" : types .StringNull (),
1390- "availability_zones" : types .ListNull (types .StringType ),
1401+ "name" : types .StringPointerValue (nodePoolResp .Name ),
1402+ "machine_type" : types .StringPointerValue (nodePoolResp .Machine .Type ),
1403+ "os_name" : types .StringNull (),
1404+ "os_version_min" : modelNodePoolOSVersionMin [* nodePoolResp .Name ],
1405+ "os_version" : modelNodePoolOSVersion [* nodePoolResp .Name ],
1406+ "minimum" : types .Int64PointerValue (nodePoolResp .Minimum ),
1407+ "maximum" : types .Int64PointerValue (nodePoolResp .Maximum ),
1408+ "max_surge" : types .Int64PointerValue (nodePoolResp .MaxSurge ),
1409+ "max_unavailable" : types .Int64PointerValue (nodePoolResp .MaxUnavailable ),
1410+ "volume_type" : types .StringNull (),
1411+ "volume_size" : types .Int64PointerValue (nodePoolResp .Volume .Size ),
1412+ "labels" : types .MapNull (types .StringType ),
1413+ "cri" : types .StringNull (),
1414+ "availability_zones" : types .ListNull (types .StringType ),
1415+ "allow_system_components" : types .BoolPointerValue (nodePoolResp .AllowSystemComponents ),
13911416 }
13921417
13931418 if nodePoolResp .Machine != nil && nodePoolResp .Machine .Image != nil {
0 commit comments