Skip to content
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
5 changes: 5 additions & 0 deletions .changes/next-release/api-change-vks-4yuiroep.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "api-change",
"category": "vks",
"description": "Align node group commands with latest API: remove --image-id (no longer in the API), add --os (ubuntu/linux, default ubuntu) for create-cluster/create-nodegroup; update-nodegroup no longer requires/sends image"
}
12 changes: 6 additions & 6 deletions docs/commands/vks/create-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ grn vks create-cluster
--subnet-id <value>
--node-group-name <value>
--flavor-id <value>
--image-id <value>
[--os <value>]
--disk-type <value>
--ssh-key-id <value>
[--cidr <value>]
Expand Down Expand Up @@ -92,8 +92,8 @@ grn vks create-cluster
`--flavor-id` (required)
: Flavor (instance type) ID for the nodes.

`--image-id` (required)
: OS image ID for the nodes.
`--os` (optional, default `ubuntu`)
: Node group OS image. Supported values: `ubuntu`, `linux`.

`--disk-type` (required)
: Disk type ID for the node boot volumes.
Expand Down Expand Up @@ -135,7 +135,7 @@ grn vks create-cluster \
--subnet-id sub-abc12345-0000-0000-0000-000000000001 \
--node-group-name default-ng \
--flavor-id flv-2c4g \
--image-id img-ubuntu-22-04-k8s \
--os ubuntu \
--disk-type SSD \
--ssh-key-id key-abc12345-0000-0000-0000-000000000001
```
Expand All @@ -152,7 +152,7 @@ grn vks create-cluster \
--subnet-id sub-abc12345-0000-0000-0000-000000000001 \
--node-group-name prod-ng \
--flavor-id flv-4c8g \
--image-id img-ubuntu-22-04-k8s \
--os ubuntu \
--disk-type SSD \
--disk-size 200 \
--num-nodes 3 \
Expand All @@ -172,7 +172,7 @@ grn vks create-cluster \
--subnet-id sub-abc12345-0000-0000-0000-000000000001 \
--node-group-name default-ng \
--flavor-id flv-2c4g \
--image-id img-ubuntu-22-04-k8s \
--os ubuntu \
--disk-type SSD \
--ssh-key-id key-abc12345-0000-0000-0000-000000000001 \
--dry-run
Expand Down
12 changes: 6 additions & 6 deletions docs/commands/vks/create-nodegroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Use `--dry-run` to validate parameters (name format, disk size range, node count
grn vks create-nodegroup
--cluster-id <value>
--name <value>
--image-id <value>
[--os <value>]
--flavor-id <value>
--disk-type <value>
--ssh-key-id <value>
Expand All @@ -35,8 +35,8 @@ grn vks create-nodegroup
`--name` (required)
: Node group name. Must be 5–15 characters, lowercase alphanumeric and hyphens, starting and ending with an alphanumeric character.

`--image-id` (required)
: OS image ID for the nodes.
`--os` (optional, default `ubuntu`)
: Node group OS image. Supported values: `ubuntu`, `linux`.

`--flavor-id` (required)
: Flavor (instance type) ID for the nodes.
Expand Down Expand Up @@ -82,7 +82,7 @@ Create a basic node group:
grn vks create-nodegroup \
--cluster-id cls-abc12345-6789-def0-1234-abcdef012345 \
--name worker-ng \
--image-id img-ubuntu-22-04-k8s \
--os ubuntu \
--flavor-id flv-4c8g \
--disk-type SSD \
--ssh-key-id key-abc12345-0000-0000-0000-000000000001
Expand All @@ -94,7 +94,7 @@ Create a GPU node group with taints and labels:
grn vks create-nodegroup \
--cluster-id cls-abc12345-6789-def0-1234-abcdef012345 \
--name gpu-ng \
--image-id img-ubuntu-22-04-k8s-gpu \
--os ubuntu \
--flavor-id flv-8c32g-gpu \
--disk-type SSD \
--disk-size 200 \
Expand All @@ -111,7 +111,7 @@ Validate parameters without creating:
grn vks create-nodegroup \
--cluster-id cls-abc12345-6789-def0-1234-abcdef012345 \
--name worker-ng \
--image-id img-ubuntu-22-04-k8s \
--os ubuntu \
--flavor-id flv-4c8g \
--disk-type SSD \
--ssh-key-id key-abc12345-0000-0000-0000-000000000001 \
Expand Down
12 changes: 2 additions & 10 deletions docs/commands/vks/update-nodegroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

Update a node group's image, node count, security groups, labels, taints, auto-scaling configuration, and upgrade strategy. The image ID is always required by the API, even when the intent is to update only other fields.
Update a node group's node count, security groups, labels, taints, auto-scaling configuration, and upgrade strategy.

Use `--dry-run` to preview the update payload without executing it.

Expand All @@ -12,7 +12,6 @@ Use `--dry-run` to preview the update payload without executing it.
grn vks update-nodegroup
--cluster-id <value>
--nodegroup-id <value>
--image-id <value>
[--num-nodes <value>]
[--security-groups <value>]
[--labels <value>]
Expand All @@ -33,9 +32,6 @@ grn vks update-nodegroup
`--nodegroup-id` (required)
: ID of the node group to update.

`--image-id` (required)
: OS image ID. Always required by the API — pass the current image ID to leave it unchanged.

`--num-nodes` (optional)
: New desired number of nodes for the node group.

Expand Down Expand Up @@ -74,17 +70,15 @@ Scale a node group to 5 nodes:
grn vks update-nodegroup \
--cluster-id cls-abc12345-6789-def0-1234-abcdef012345 \
--nodegroup-id ng-abc12345-6789-def0-1234-abcdef012345 \
--image-id img-ubuntu-22-04-k8s \
--num-nodes 5
```

Update node image and set auto-scaling limits:
Set auto-scaling limits:

```bash
grn vks update-nodegroup \
--cluster-id cls-abc12345-6789-def0-1234-abcdef012345 \
--nodegroup-id ng-abc12345-6789-def0-1234-abcdef012345 \
--image-id img-ubuntu-22-04-k8s-v2 \
--auto-scale-min 2 \
--auto-scale-max 10
```
Expand All @@ -95,7 +89,6 @@ Update labels and taints:
grn vks update-nodegroup \
--cluster-id cls-abc12345-6789-def0-1234-abcdef012345 \
--nodegroup-id ng-abc12345-6789-def0-1234-abcdef012345 \
--image-id img-ubuntu-22-04-k8s \
--labels env=prod,tier=app \
--taints dedicated=gpu:NoSchedule
```
Expand All @@ -106,7 +99,6 @@ Preview the update payload (dry run):
grn vks update-nodegroup \
--cluster-id cls-abc12345-6789-def0-1234-abcdef012345 \
--nodegroup-id ng-abc12345-6789-def0-1234-abcdef012345 \
--image-id img-ubuntu-22-04-k8s \
--num-nodes 3 \
--dry-run
```
2 changes: 1 addition & 1 deletion docs/usage/dry-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ grn vks create-nodegroup --dry-run --cluster-id k8s-xxxxx --name workers ...

# Preview update parameters
grn vks update-cluster --dry-run --cluster-id k8s-xxxxx --k8s-version v1.31 --whitelist-node-cidrs 0.0.0.0/0
grn vks update-nodegroup --dry-run --cluster-id k8s-xxxxx --nodegroup-id ng-xxxxx --image-id img-xxxxx
grn vks update-nodegroup --dry-run --cluster-id k8s-xxxxx --nodegroup-id ng-xxxxx --num-nodes 3

# Preview what will be deleted
grn vks delete-cluster --dry-run --cluster-id k8s-xxxxx
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ grn vks create-cluster \
--cidr 192.168.0.0/16 \
--node-group-name default \
--flavor-id flav-xxxxx \
--image-id img-xxxxx \
--os ubuntu \
--disk-type vtype-xxxxx \
--ssh-key-id ssh-xxxxx

Expand Down
2 changes: 1 addition & 1 deletion docs/usage/shell-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ grn completion powershell | Out-String | Invoke-Expression
Beyond commands and flags, `grn` completes flag *values*:

- Global: `--region`, `--output`, `--color`, `--profile`
- VKS: `--cluster-id`, `--nodegroup-id`, `--k8s-version`, `--image-id`, `--network-type`, `--release-channel`
- VKS: `--cluster-id`, `--nodegroup-id`, `--k8s-version`, `--os`, `--network-type`, `--release-channel`
- vserver resources used by VKS: `--vpc-id`, `--subnet-id`, `--ssh-key-id`, `--security-groups`, `--disk-type`

Resource-id completions call the API using your configured credentials and
Expand Down
14 changes: 1 addition & 13 deletions go/cmd/vks/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,12 @@ func fetchK8sVersions(_ context.Context, cmd *cobra.Command) ([]string, error) {
return cli.ExtractIDs(res, "version", "name", "id"), nil
}

func fetchImageIDs(_ context.Context, cmd *cobra.Command) ([]string, error) {
c, err := createClient(cmd)
if err != nil {
return nil, err
}
res, err := c.Get("/v1/node-group-images", nil)
if err != nil {
return nil, err
}
return cli.ExtractIDs(res, "id", "name"), nil
}

func flagCompleters() map[string]cli.CompFunc {
return map[string]cli.CompFunc{
"cluster-id": cli.FlagFromAPI(fetchClusterIDs),
"nodegroup-id": cli.FlagFromAPI(fetchNodegroupIDs),
"k8s-version": cli.FlagFromAPI(fetchK8sVersions),
"image-id": cli.FlagFromAPI(fetchImageIDs),
"os": cli.FlagValues("ubuntu", "linux"),
"network-type": cli.FlagValues("CALICO", "CILIUM_OVERLAY", "CILIUM_NATIVE_ROUTING"),
"release-channel": cli.FlagValues("RAPID", "STABLE"),
"vpc-id": cli.ResourceCompletion("vserver:network"),
Expand Down
8 changes: 4 additions & 4 deletions go/cmd/vks/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func init() {
// Node group settings (required)
f.String("node-group-name", "", "Default node group name (required)")
f.String("flavor-id", "", "Flavor ID for node group (required)")
f.String("image-id", "", "Image ID for node group (required)")
f.String("os", "ubuntu", "Node group OS image (ubuntu, linux)")
f.String("disk-type", "", "Disk type ID (required)")
f.String("ssh-key-id", "", "SSH key ID for node group (required)")

for _, name := range []string{"name", "k8s-version", "network-type", "vpc-id", "subnet-id", "node-group-name", "flavor-id", "image-id", "disk-type", "ssh-key-id"} {
for _, name := range []string{"name", "k8s-version", "network-type", "vpc-id", "subnet-id", "node-group-name", "flavor-id", "disk-type", "ssh-key-id"} {
createClusterCmd.MarkFlagRequired(name)
}

Expand Down Expand Up @@ -67,7 +67,7 @@ func runCreateCluster(cmd *cobra.Command, args []string) error {

ngName, _ := cmd.Flags().GetString("node-group-name")
flavorID, _ := cmd.Flags().GetString("flavor-id")
imageID, _ := cmd.Flags().GetString("image-id")
osImage, _ := cmd.Flags().GetString("os")
diskType, _ := cmd.Flags().GetString("disk-type")
sshKeyID, _ := cmd.Flags().GetString("ssh-key-id")
diskSize, _ := cmd.Flags().GetInt("disk-size")
Expand All @@ -82,7 +82,7 @@ func runCreateCluster(cmd *cobra.Command, args []string) error {
nodeGroup := map[string]interface{}{
"name": ngName,
"flavorId": flavorID,
"imageId": imageID,
"os": osImage,
"diskSize": diskSize,
"diskType": diskType,
"numNodes": numNodes,
Expand Down
8 changes: 4 additions & 4 deletions go/cmd/vks/create_nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func init() {
f := createNodegroupCmd.Flags()
f.String("cluster-id", "", "Cluster ID (required)")
f.String("name", "", "Node group name (required)")
f.String("image-id", "", "Image ID (required)")
f.String("os", "ubuntu", "Node group OS image (ubuntu, linux)")
f.String("flavor-id", "", "Flavor ID (required)")
f.String("disk-type", "", "Disk type ID (required)")
f.String("ssh-key-id", "", "SSH key ID (required)")
Expand All @@ -33,15 +33,15 @@ func init() {
f.Bool("enable-encryption-volume", false, "Enable volume encryption")
f.Bool("dry-run", false, "Validate parameters without creating")

for _, name := range []string{"cluster-id", "name", "image-id", "flavor-id", "disk-type", "ssh-key-id"} {
for _, name := range []string{"cluster-id", "name", "flavor-id", "disk-type", "ssh-key-id"} {
createNodegroupCmd.MarkFlagRequired(name)
}
}

func runCreateNodegroup(cmd *cobra.Command, args []string) error {
clusterID, _ := cmd.Flags().GetString("cluster-id")
name, _ := cmd.Flags().GetString("name")
imageID, _ := cmd.Flags().GetString("image-id")
osImage, _ := cmd.Flags().GetString("os")
flavorID, _ := cmd.Flags().GetString("flavor-id")
diskType, _ := cmd.Flags().GetString("disk-type")
sshKeyID, _ := cmd.Flags().GetString("ssh-key-id")
Expand All @@ -62,7 +62,7 @@ func runCreateNodegroup(cmd *cobra.Command, args []string) error {
body := map[string]interface{}{
"name": name,
"numNodes": numNodes,
"imageId": imageID,
"os": osImage,
"flavorId": flavorID,
"diskSize": diskSize,
"diskType": diskType,
Expand Down
11 changes: 5 additions & 6 deletions go/cmd/vks/update_nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func init() {
f := updateNodegroupCmd.Flags()
f.String("cluster-id", "", "Cluster ID (required)")
f.String("nodegroup-id", "", "Node group ID (required)")
f.String("image-id", "", "Image ID (required)")
f.String("num-nodes", "", "New number of nodes")
f.String("security-groups", "", "Security group IDs (comma-separated)")
f.String("labels", "", "Node labels as key=value pairs (comma-separated)")
Expand All @@ -32,13 +31,11 @@ func init() {

updateNodegroupCmd.MarkFlagRequired("cluster-id")
updateNodegroupCmd.MarkFlagRequired("nodegroup-id")
updateNodegroupCmd.MarkFlagRequired("image-id")
}

func runUpdateNodegroup(cmd *cobra.Command, args []string) error {
clusterID, _ := cmd.Flags().GetString("cluster-id")
nodegroupID, _ := cmd.Flags().GetString("nodegroup-id")
imageID, _ := cmd.Flags().GetString("image-id")
numNodes, _ := cmd.Flags().GetString("num-nodes")
securityGroups, _ := cmd.Flags().GetString("security-groups")
labelsStr, _ := cmd.Flags().GetString("labels")
Expand All @@ -57,9 +54,7 @@ func runUpdateNodegroup(cmd *cobra.Command, args []string) error {
return err
}

body := map[string]interface{}{
"imageId": imageID,
}
body := map[string]interface{}{}

if numNodes != "" {
body["numNodes"] = toInt(numNodes)
Expand Down Expand Up @@ -99,6 +94,10 @@ func runUpdateNodegroup(cmd *cobra.Command, args []string) error {
body["upgradeConfig"] = upgradeConfig
}

if len(body) == 0 {
return fmt.Errorf("nothing to update: provide at least one of --num-nodes, --security-groups, --labels, --taints, --auto-scale-min/max, or --upgrade-strategy/max-surge/max-unavailable")
}

if dryRun {
fmt.Println("=== DRY RUN: Update node group ===")
fmt.Println()
Expand Down
Loading