Skip to content

Commit

Permalink
Add support for custom root disks (#600)
Browse files Browse the repository at this point in the history
This PR adds a `customRootDisk` field to the nodepool spec. If set the vms get an ephermeral cinder based root disk that is deleted when the vm is deleted.

This PR adds a `customRootDisk` field to the nodepool spec. If set the vms get an ephermeral cinder based root disk that is deleted when the vm is deleted.

Co-authored-by: Jan Knipper <9881823+jknipper@users.noreply.github.com>
  • Loading branch information
databus23 and jknipper committed Aug 16, 2021
1 parent 76409fc commit 3a693b8
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 1 deletion.
26 changes: 26 additions & 0 deletions pkg/api/models/node_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/api/spec/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion pkg/client/openstack/kluster/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/secgroups"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups"
Expand Down Expand Up @@ -119,7 +120,27 @@ func (c *klusterClient) CreateNode(kluster *v1.Kluster, pool *models.NodePool, n
}
}

server, err := compute.Create(c.ComputeClient, createOpts).Extract()
var server *servers.Server

if pool.CustomRootDiskSize > 0 {
blockDevices := []bootfromvolume.BlockDevice{{
UUID: imageID,
VolumeSize: int(pool.CustomRootDiskSize),
BootIndex: 0,
DeleteOnTermination: true,
SourceType: "image",
DestinationType: "volume",
}}
createOpts = &bootfromvolume.CreateOptsExt{
CreateOptsBuilder: createOpts,
BlockDevice: blockDevices,
}

server, err = bootfromvolume.Create(c.ComputeClient, createOpts).Extract()
} else {
server, err = compute.Create(c.ComputeClient, createOpts).Extract()
}

if err != nil {
return "", fmt.Errorf("Failed to create node: %w", err)
}
Expand Down
5 changes: 5 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ definitions:
availabilityZone:
type: string
x-nullable: false
customRootDiskSize:
type: integer
minimum: 64
maximum: 1024
description: Create servers with custom (cinder based) root disked. Size in GB
taints:
description: The specified taints will be added to members of this pool once during initial registration of the node
type: array
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3a693b8

Please sign in to comment.