Skip to content

Commit 56ecd04

Browse files
KUBE-960: Add support for secondary ip range in gke
1 parent 28937b8 commit 56ecd04

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

castai/resource_node_configuration.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,22 @@ func resourceNodeConfiguration() *schema.Resource {
474474
Default: nil,
475475
Description: "Use ephemeral storage local SSD. Defaults to false",
476476
},
477+
"secondary_ip_range": {
478+
Type: schema.TypeList,
479+
Optional: true,
480+
MaxItems: 1,
481+
Description: "Secondary IP range configuration for pods in GKE nodes",
482+
Elem: &schema.Resource{
483+
Schema: map[string]*schema.Schema{
484+
"range_name": {
485+
Type: schema.TypeString,
486+
Required: true,
487+
Description: "Name of the secondary IP range",
488+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(1, 63)),
489+
},
490+
},
491+
},
492+
},
477493
FieldNodeConfigurationLoadbalancers: {
478494
Type: schema.TypeList,
479495
Optional: true,
@@ -1312,6 +1328,13 @@ func toGKEConfig(obj map[string]interface{}) *sdk.NodeconfigV1GKEConfig {
13121328
out.UseEphemeralStorageLocalSsd = toPtr(v)
13131329
}
13141330

1331+
if v, ok := obj["secondary_ip_range"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
1332+
secondary := v[0].(map[string]interface{})
1333+
if rangeName, ok := secondary["range_name"].(string); ok {
1334+
out.SecondaryIpRange = &sdk.NodeconfigV1SecondaryIPRange{RangeName: &rangeName}
1335+
}
1336+
}
1337+
13151338
if v, ok := obj[FieldNodeConfigurationLoadbalancers].([]interface{}); ok && len(v) > 0 {
13161339
out.LoadBalancers = toGkeLoadBalancers(v)
13171340
}
@@ -1408,6 +1431,12 @@ func flattenGKEConfig(config *sdk.NodeconfigV1GKEConfig) []map[string]interface{
14081431
m["use_ephemeral_storage_local_ssd"] = *v
14091432
}
14101433

1434+
if v := config.SecondaryIpRange; v != nil {
1435+
m["secondary_ip_range"] = []map[string]interface{}{
1436+
{"range_name": v.RangeName},
1437+
}
1438+
}
1439+
14111440
if v := config.LoadBalancers; v != nil && len(*v) > 0 {
14121441
m[FieldNodeConfigurationLoadbalancers] = fromGkeLoadBalancers(*v)
14131442
}

castai/sdk/api.gen.go

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/resources/node_configuration.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)