Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for passing os partition size when creating nodes #4955

Merged
merged 5 commits into from
Jun 14, 2022
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
1 change: 1 addition & 0 deletions cluster-autoscaler/cloudprovider/cherryservers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ In the above file you can modify the following fields:
| cluster-autoscaler-cloud-config | Global/cloudinit | The base64 encoded user data submitted when provisioning servers. In the example file, the default value has been tested with Ubuntu 18.04 to install Docker & kubelet and then to bootstrap the node into the cluster using kubeadm. The kubeadm, kubelet, kubectl are pinned to version 1.17.4. For a different base OS or bootstrap method, this needs to be customized accordingly. It will use go templates to inject runtime information; see below.|
| cluster-autoscaler-cloud-config | Global/reservation | The values "require" or "prefer" will request the next available hardware reservation for new servers in selected region & plan. If no hardware reservations match, "require" will trigger a failure, while "prefer" will launch on-demand servers instead (default: none) |
| cluster-autoscaler-cloud-config | Global/hostname-pattern | The pattern for the names of new Cherry Servers servers (default: "k8s-{{.ClusterName}}-{{.NodeGroup}}-{{.RandString8}}" ) |
| cluster-autoscaler-cloud-config | Global/os-partition-size | The OS partition size in gigabytes for new nodes in the nodepool (eg: `60`, default: `none`) |

You can always update the secret with more nodepool definitions (with different plans etc.) as shown in the example, but you should always provide a default nodepool configuration.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type cherryManagerNodePool struct {
cloudinit string
hostnamePattern string
sshKeyIDs []int
osPartitionSize int
waitTimeStep time.Duration
}

Expand All @@ -94,6 +95,7 @@ type ConfigNodepool struct {
SSHKeys []string `gcfg:"ssh-key-ids"`
CloudInit string `gcfg:"cloudinit"`
HostnamePattern string `gcfg:"hostname-pattern"`
OsPartitionSize int `gcfg:"os-partition-size"`
}

// IsEmpty determine if this is an empty config
Expand Down Expand Up @@ -235,6 +237,7 @@ func createCherryManagerRest(configReader io.Reader, discoverOpts cloudprovider.
cloudinit: nodepool.CloudInit,
sshKeyIDs: sshKeyIDs,
hostnamePattern: nodepool.HostnamePattern,
osPartitionSize: nodepool.OsPartitionSize,
}
}

Expand Down Expand Up @@ -427,14 +430,15 @@ func (mgr *cherryManagerRest) createNode(ctx context.Context, cloudinit, nodegro
return fmt.Errorf("failed to create hostname from template: %w", err)
}
cr := &CreateServer{
Hostname: hn,
Region: mgr.getNodePoolDefinition(nodegroup).region,
PlanID: mgr.getNodePoolDefinition(nodegroup).plan,
Image: mgr.getNodePoolDefinition(nodegroup).os,
ProjectID: mgr.getNodePoolDefinition(nodegroup).projectID,
UserData: base64.StdEncoding.EncodeToString([]byte(ud)),
SSHKeys: mgr.getNodePoolDefinition(nodegroup).sshKeyIDs,
Tags: &map[string]string{"k8s-cluster": mgr.getNodePoolDefinition(nodegroup).clusterName, "k8s-nodepool": nodegroup},
Hostname: hn,
Region: mgr.getNodePoolDefinition(nodegroup).region,
PlanID: mgr.getNodePoolDefinition(nodegroup).plan,
Image: mgr.getNodePoolDefinition(nodegroup).os,
ProjectID: mgr.getNodePoolDefinition(nodegroup).projectID,
UserData: base64.StdEncoding.EncodeToString([]byte(ud)),
SSHKeys: mgr.getNodePoolDefinition(nodegroup).sshKeyIDs,
Tags: &map[string]string{"k8s-cluster": mgr.getNodePoolDefinition(nodegroup).clusterName, "k8s-nodepool": nodegroup},
OSPartitionSize: mgr.getNodePoolDefinition(nodegroup).osPartitionSize,
}

if err := mgr.createServerRequest(ctx, cr, nodegroup); err != nil {
Expand Down
21 changes: 11 additions & 10 deletions cluster-autoscaler/cloudprovider/cherryservers/cherry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,15 @@ type IPAddressCreateRequest struct {

// CreateServer represents a request to create a new Cherry Servers server. Used by createNodes
type CreateServer struct {
ProjectID int `json:"project_id,omitempty"`
PlanID int `json:"plan_id,omitempty"`
Hostname string `json:"hostname,omitempty"`
Image string `json:"image,omitempty"`
Region string `json:"region,omitempty"`
SSHKeys []int `json:"ssh_keys"`
IPAddresses []string `json:"ip_addresses"`
UserData string `json:"user_data,omitempty"`
Tags *map[string]string `json:"tags,omitempty"`
SpotInstance int `json:"spot_market,omitempty"`
ProjectID int `json:"project_id,omitempty"`
PlanID int `json:"plan_id,omitempty"`
Hostname string `json:"hostname,omitempty"`
Image string `json:"image,omitempty"`
Region string `json:"region,omitempty"`
SSHKeys []int `json:"ssh_keys"`
IPAddresses []string `json:"ip_addresses"`
UserData string `json:"user_data,omitempty"`
Tags *map[string]string `json:"tags,omitempty"`
SpotInstance int `json:"spot_market,omitempty"`
OSPartitionSize int `json:"os_partition_size,omitempty"`
}