Skip to content

Commit ec86f44

Browse files
committed
feat(sks): add IPv6 support in CLI
1 parent 842b57f commit ec86f44

File tree

6 files changed

+78
-44
lines changed

6 files changed

+78
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- chores: add git version/commit in user agent header #769
1414
- Prompting for validation before deleting deployments and models (dedicated-inference)
1515
- Ability to delete multiple deployments and models at once (dedicated-inference)
16+
- Add IPv6 public IP assignment support for SKS Nodepools #774
1617

1718
## 1.88.0
1819

cmd/compute/sks/sks_create.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type sksCreateCmd struct {
5858
NodepoolSecurityGroups []string `cli-flag:"nodepool-security-group" cli-usage:"default Nodepool Security Group NAME|ID (can be specified multiple times)"`
5959
NodepoolSize int64 `cli-usage:"default Nodepool size. If 0, no default Nodepool will be added to the cluster."`
6060
NodepoolTaints []string `cli-flag:"nodepool-taint" cli-usage:"Kubernetes taint to apply to default Nodepool Nodes (format: KEY=VALUE:EFFECT, can be specified multiple times)"`
61+
NodepoolIPv6 bool `cli-flag:"nodepool-ipv6" cli-usage:"assign IPv6 Public IPs to default Nodepool Nodes"`
6162
OIDCClientID string `cli-flag:"oidc-client-id" cli-usage:"OpenID client ID"`
6263
OIDCGroupsClaim string `cli-flag:"oidc-groups-claim" cli-usage:"OpenID JWT claim to use as the user's group"`
6364
OIDCGroupsPrefix string `cli-flag:"oidc-groups-prefix" cli-usage:"OpenID prefix prepended to group claims"`
@@ -224,29 +225,32 @@ func (c *sksCreateCmd) CmdRun(cmd *cobra.Command, _ []string) error { //nolint:g
224225
nodepoolName = c.NodepoolName
225226
}
226227

227-
nodepoolReq, err := createNodepoolRequest(
228-
ctx,
229-
client,
230-
CreateNodepoolOpts{
231-
Name: nodepoolName,
232-
Description: c.NodepoolDescription,
233-
DiskSize: c.NodepoolDiskSize,
234-
InstancePrefix: c.NodepoolInstancePrefix,
235-
Size: c.NodepoolSize,
236-
InstanceType: c.NodepoolInstanceType,
237-
Labels: c.NodepoolLabels,
238-
AntiAffinityGroups: c.NodepoolAntiAffinityGroups,
239-
DeployTarget: c.NodepoolDeployTarget,
240-
PrivateNetworks: c.NodepoolPrivateNetworks,
241-
SecurityGroups: c.NodepoolSecurityGroups,
242-
Taints: c.NodepoolTaints,
243-
KubeletImageGC: &v3.KubeletImageGC{
244-
MinAge: c.NodepoolImageGcMinAge,
245-
LowThreshold: c.NodepoolImageGcLowThreshold,
246-
HighThreshold: c.NodepoolImageGcHighThreshold,
247-
},
228+
opts := CreateNodepoolOpts{
229+
Name: nodepoolName,
230+
Description: c.NodepoolDescription,
231+
DiskSize: c.NodepoolDiskSize,
232+
InstancePrefix: c.NodepoolInstancePrefix,
233+
Size: c.NodepoolSize,
234+
InstanceType: c.NodepoolInstanceType,
235+
Labels: c.NodepoolLabels,
236+
AntiAffinityGroups: c.NodepoolAntiAffinityGroups,
237+
DeployTarget: c.NodepoolDeployTarget,
238+
PrivateNetworks: c.NodepoolPrivateNetworks,
239+
SecurityGroups: c.NodepoolSecurityGroups,
240+
Taints: c.NodepoolTaints,
241+
KubeletImageGC: &v3.KubeletImageGC{
242+
MinAge: c.NodepoolImageGcMinAge,
243+
LowThreshold: c.NodepoolImageGcLowThreshold,
244+
HighThreshold: c.NodepoolImageGcHighThreshold,
248245
},
249-
)
246+
}
247+
248+
if c.NodepoolIPv6 {
249+
v := v3.PublicIPAssignmentDual
250+
opts.PublicIPAssignment = &v
251+
}
252+
253+
nodepoolReq, err := createNodepoolRequest(ctx, client, opts)
250254
if err != nil {
251255
return err
252256
}

cmd/compute/sks/sks_nodepool.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type CreateNodepoolOpts struct {
6060
SecurityGroups []string
6161
Taints []string
6262
KubeletImageGC *v3.KubeletImageGC
63+
PublicIPAssignment *v3.PublicIPAssignment
6364
}
6465

6566
func createNodepoolRequest(
@@ -78,6 +79,10 @@ func createNodepoolRequest(
7879
KubeletImageGC: opts.KubeletImageGC,
7980
}
8081

82+
if opts.PublicIPAssignment != nil {
83+
nodepoolReq.PublicIPAssignment = v3.CreateSKSNodepoolRequestPublicIPAssignment(*opts.PublicIPAssignment)
84+
}
85+
8186
aaGroups, err := lookupAntiAffinityGroups(ctx, client, opts.AntiAffinityGroups)
8287
if err != nil {
8388
return nodepoolReq, err

cmd/compute/sks/sks_nodepool_add.go

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type sksNodepoolAddCmd struct {
4343
StorageLvm bool `cli-usage:"Create nodes with non-standard partitioning for persistent storage"`
4444
Taints []string `cli-flag:"taint" cli-usage:"Kubernetes taint to apply to Nodepool Nodes (format: KEY=VALUE:EFFECT, can be specified multiple times)"`
4545
Zone string `cli-short:"z" cli-usage:"SKS cluster zone"`
46+
IPv6 bool `cli-flag:"ipv6" cli-usage:"Enable public IPv6 assignment to Nodepool nodes"`
4647
}
4748

4849
func (c *sksNodepoolAddCmd) CmdAliases() []string { return nil }
@@ -87,29 +88,35 @@ func (c *sksNodepoolAddCmd) CmdRun(_ *cobra.Command, _ []string) error {
8788
}
8889
}
8990

90-
nodepoolReq, err := createNodepoolRequest(
91-
ctx,
92-
client,
93-
CreateNodepoolOpts{
94-
Name: c.Name,
95-
Description: c.Description,
96-
DiskSize: c.DiskSize,
97-
InstancePrefix: c.InstancePrefix,
98-
Size: c.Size,
99-
InstanceType: c.InstanceType,
100-
Labels: labels,
101-
AntiAffinityGroups: c.AntiAffinityGroups,
102-
DeployTarget: c.DeployTarget,
103-
PrivateNetworks: c.PrivateNetworks,
104-
SecurityGroups: c.SecurityGroups,
105-
Taints: c.Taints,
106-
KubeletImageGC: &v3.KubeletImageGC{
107-
MinAge: c.ImageGcMinAge,
108-
LowThreshold: c.ImageGcLowThreshold,
109-
HighThreshold: c.ImageGcHighThreshold,
110-
},
91+
opts := CreateNodepoolOpts{
92+
Name: c.Name,
93+
Description: c.Description,
94+
DiskSize: c.DiskSize,
95+
InstancePrefix: c.InstancePrefix,
96+
Size: c.Size,
97+
InstanceType: c.InstanceType,
98+
Labels: labels,
99+
AntiAffinityGroups: c.AntiAffinityGroups,
100+
DeployTarget: c.DeployTarget,
101+
PrivateNetworks: c.PrivateNetworks,
102+
SecurityGroups: c.SecurityGroups,
103+
Taints: c.Taints,
104+
KubeletImageGC: &v3.KubeletImageGC{
105+
MinAge: c.ImageGcMinAge,
106+
LowThreshold: c.ImageGcLowThreshold,
107+
HighThreshold: c.ImageGcHighThreshold,
111108
},
112-
)
109+
}
110+
111+
if c.IPv6 {
112+
v := v3.PublicIPAssignmentDual
113+
opts.PublicIPAssignment = &v
114+
} else {
115+
v := v3.PublicIPAssignmentInet4
116+
opts.PublicIPAssignment = &v
117+
}
118+
119+
nodepoolReq, err := createNodepoolRequest(ctx, client, opts)
113120
if err != nil {
114121
return err
115122
}

cmd/compute/sks/sks_nodepool_show.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type sksNodepoolShowOutput struct {
2424
InstanceType string `json:"instance_type"`
2525
Template string `json:"template"`
2626
DiskSize int64 `json:"disk_size"`
27+
IPv6 bool `json:"ipv6_enabled" outputLabel:"IPv6"`
2728
AntiAffinityGroups []string `json:"anti_affinity_groups"`
2829
SecurityGroups []string `json:"security_groups"`
2930
PrivateNetworks []string `json:"private_networks"`
@@ -99,6 +100,11 @@ func (c *sksNodepoolShowCmd) CmdRun(_ *cobra.Command, _ []string) error {
99100
return errors.New("nodepool not found")
100101
}
101102

103+
ipv6Enabled := false
104+
if nodepool.PublicIPAssignment == v3.SKSNodepoolPublicIPAssignmentDual {
105+
ipv6Enabled = true
106+
}
107+
102108
out := sksNodepoolShowOutput{
103109
AddOns: func() (v []string) {
104110
if nodepool.Addons != nil {
@@ -124,6 +130,7 @@ func (c *sksNodepoolShowCmd) CmdRun(_ *cobra.Command, _ []string) error {
124130
PrivateNetworks: make([]string, 0),
125131
Size: nodepool.Size,
126132
State: string(nodepool.State),
133+
IPv6: ipv6Enabled,
127134
Taints: func() (v []string) {
128135
if nodepool.Taints != nil {
129136
v = make([]string, 0)

cmd/compute/sks/sks_nodepool_update.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type sksNodepoolUpdateCmd struct {
3434
SecurityGroups []string `cli-flag:"security-group" cli-usage:"Nodepool Security Group NAME|ID (can be specified multiple times)"`
3535
Taints []string `cli-flag:"taint" cli-usage:"Kubernetes taint to apply to Nodepool Nodes (format: KEY=VALUE:EFFECT, can be specified multiple times)"`
3636
Zone v3.ZoneName `cli-short:"z" cli-usage:"SKS cluster zone"`
37+
IPv6 bool `cli-flag:"ipv6" cli-usage:"Enable public IPv6 assignment to Nodepool nodes"`
3738
}
3839

3940
func (c *sksNodepoolUpdateCmd) CmdAliases() []string { return nil }
@@ -191,6 +192,15 @@ func (c *sksNodepoolUpdateCmd) CmdRun(cmd *cobra.Command, _ []string) error { //
191192
updated = true
192193
}
193194

195+
if cmd.Flags().Changed(exocmd.MustCLICommandFlagName(c, &c.IPv6)) {
196+
if c.IPv6 {
197+
updateReq.PublicIPAssignment = v3.UpdateSKSNodepoolRequestPublicIPAssignmentDual
198+
} else {
199+
updateReq.PublicIPAssignment = v3.UpdateSKSNodepoolRequestPublicIPAssignmentInet4
200+
}
201+
updated = true
202+
}
203+
194204
if updated {
195205
op, err := client.UpdateSKSNodepool(ctx, cluster.ID, nodepool.ID, updateReq)
196206
utils.DecorateAsyncOperation(fmt.Sprintf("Updating Nodepool %q...", c.Nodepool), func() {

0 commit comments

Comments
 (0)