nodegroup

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package nodegroup provides the ability to retrieve and manage cluster nodegroups through the MKS V1 API.

Example of getting a single cluster nodegroup referenced by its id

clusterNodegroup, _, err := nodegroup.Get(ctx, mksClient, clusterID, nodegroupID)
if err != nil {
  log.Fatal(err)
}
fmt.Printf("%+v\n", clusterNodegroup)

Example of getting all cluster nodegroups

clusterNodegroups, _, err := nodegroup.List(ctx, mksClient, clusterID)
if err != nil {
  log.Fatal(err)
}
for _, clusterNodegroup := range clusterNodegroups {
  fmt.Printf("%+v\n", clusterNodegroup)
}

Example of creating a new cluster nodegroup

createOpts := &nodegroup.CreateOpts{
  Count:            1,
  CPUs:             1,
  RAMMB:            2048,
  VolumeGB:         10,
  VolumeType:       "fast.ru-3a",
  KeypairName:      "ssh-key",
  AvailabilityZone: "ru-3a",
}
_, err := nodegroup.Create(ctx, mksClient, clusterID, createOpts)
if err != nil {
  log.Fatal(err)
}

Example of deleting a single cluster nodegroup

_, err := nodegroup.Delete(ctx, mksClient, clusterID, nodegroupID)
if err != nil {
  log.Fatal(err)
}

Example of resizing a single cluster nodegroup

resizeOpts := &nodegroup.ResizeOpts{
  Desired: 1,
}
_, err := nodegroup.Resize(ctx, mksClient, clusterID, nodegroupID, resizeOpts)
if err != nil {
  log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, client *v1.ServiceClient, clusterID string, opts *CreateOpts) (*v1.ResponseResult, error)

Create requests a creation of a new cluster nodegroup.

func Delete

func Delete(ctx context.Context, client *v1.ServiceClient, clusterID, nodegroupID string) (*v1.ResponseResult, error)

Delete deletes a cluster nodegroup by its id.

func Resize

func Resize(ctx context.Context, client *v1.ServiceClient, clusterID, nodegroupID string, opts *ResizeOpts) (*v1.ResponseResult, error)

Resize requests a resize of a cluster nodegroup by its id.

Types

type CreateOpts

type CreateOpts struct {
	// Count represents nodes count for this nodegroup.
	Count int `json:"count,omitempty"`

	// FlavorID contains reference to a pre-created flavor.
	// It can be omitted in most cases.
	FlavorID string `json:"flavor_id,omitempty"`

	// CPUs represents CPU count for each node.
	// It can be omitted only in cases when flavor_id is set.
	CPUs int `json:"cpus,omitempty"`

	// RAMMB represents RAM count in MB for each node.
	// It can be omitted only in cases when flavor_id is set.
	RAMMB int `json:"ram_mb,omitempty"`

	// VolumeGB represents volume size in GB for each node.
	// It can be omitted only in cases when flavor_id is set and volume is local.
	VolumeGB int `json:"volume_gb,omitempty"`

	// VolumeType represents blockstorage volume type for each node.
	// It can be omitted only in cases when flavor_id is set and volume is local.
	VolumeType string `json:"volume_type,omitempty"`

	// LocalVolume represents if nodes will use local volume.
	LocalVolume bool `json:"local_volume,omitempty"`

	// KeypairName contains name of the SSH key that will be added to all nodes.
	KeypairName string `json:"keypair_name,omitempty"`

	// AffinityPolicy is an optional parameter to tune nodes affinity.
	AffinityPolicy string `json:"affinity_policy,omitempty"`

	// AvailabilityZone should contain the valid zone in the selected region of the created cluster.
	AvailabilityZone string `json:"availability_zone,omitempty"`
}

CreateOpts represents options for the nodegroup Create request.

type ResizeOpts

type ResizeOpts struct {
	// Desired represents desired amount of nodes for this nodegroup.
	Desired int `json:"desired"`
}

ResizeOpts represents options for the nodegroup Resize request.

type View

type View struct {
	// ID is the identifier of the nodegroup.
	ID string `json:"id"`

	// CreatedAt is the timestamp in UTC timezone of when the nodegroup has been created.
	CreatedAt *time.Time `json:"created_at"`

	// UpdatedAt is the timestamp in UTC timezone of when the nodegroup has been updated.
	UpdatedAt *time.Time `json:"updated_at"`

	// ClusterID contains cluster identifier.
	ClusterID string `json:"cluster_id"`

	// FlavorID contains OpenStack flavor identifier for all nodes in the nodegroup.
	FlavorID string `json:"flavor_id"`

	// VolumeGB represents initial volume size in GB for each node.
	VolumeGB int `json:"volume_gb"`

	// VolumeType represents initial blockstorage volume type for each node.
	VolumeType string `json:"volume_type"`

	// LocalVolume represents if nodes use local volume.
	LocalVolume bool `json:"local_volume"`

	// AvailabilityZone represents OpenStack availability zone for all nodes in the nodegroup.
	AvailabilityZone string `json:"availability_zone"`

	// Nodes contains list of all nodes in the nodegroup.
	Nodes []*node.View `json:"nodes"`
}

View represents an unmarshalled nodegroup body from an API response.

func Get

func Get(ctx context.Context, client *v1.ServiceClient, clusterID, nodegroupID string) (*View, *v1.ResponseResult, error)

Get returns a cluster nodegroup by its id.

func List

func List(ctx context.Context, client *v1.ServiceClient, clusterID string) ([]*View, *v1.ResponseResult, error)

List gets a list of all cluster nodegroups.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL