nodegroup

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 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",
  Labels: map[string]string{
    "label-key0": "label-value0",
    "label-key1": "label-value1",
    "label-key2": "label-value2",
  },
  Taints: []nodegroup.Taint{
    {
      Key:    "test-key-0",
      Value:  "test-value-0",
      Effect: nodegroup.NoScheduleEffect,
    },
  },
}
_, 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)
}

Example of updating nodegroup labels

updateOpts := &nodegroup.UpdateOpts{
  Labels: map[string]string{
    "label-key0": "label-value0",
    "label-key1": "label-value1",
    "label-key2": "label-value2",
  },
}
_, err := nodegroup.Update(ctx, mksClient, clusterID, nodegroupID, updateOpts)
if err != nil {
  log.Fatal(err)
}

Example of updating nodegroup taints

updateOpts := &nodegroup.UpdateOpts{
  Taints: []nodegroup.Taint{
    {
      Key:    "new-key-0",
      Value:  "new-value-0",
      Effect: nodegroup.NoScheduleEffect,
    },
  },
}
_, err := nodegroup.Update(ctx, mksClient, clusterID, nodegroupID, updateOpts)
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.

func Update added in v0.3.0

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

Update requests a update 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"`

	// Labels represents an object containing a set of Kubernetes labels that will be applied
	// for each node in the group. The keys must be user-defined.
	Labels map[string]string `json:"labels"`

	// Taints represents a list of nodegroup taints.
	Taints []Taint `json:"taints"`

	// EnableAutoscale reflects if the nodegroup is allowed to be scaled automatically.
	// Disabled by default.
	EnableAutoscale *bool `json:"enable_autoscale,omitempty"`

	// AutoscaleMinNodes represents minimum possible number of worker nodes in the nodegroup.
	AutoscaleMinNodes *int `json:"autoscale_min_nodes,omitempty"`

	// AutoscaleMaxNodes represents maximum possible number of worker nodes in the nodegroup.
	AutoscaleMaxNodes *int `json:"autoscale_max_nodes,omitempty"`

	// UserData represents base64 data which is used to pass a script that worker nodes run on boot.
	UserData *string `json:"user_data,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 Taint added in v0.6.0

type Taint struct {
	// Key is the key of the taint.
	Key string `json:"key"`

	// Value is the value of the taint.
	Value string `json:"value"`

	// Effect is the effect of the taint.
	Effect TaintEffect `json:"effect"`
}

Taint represents k8s node's taint.

type TaintEffect added in v0.6.0

type TaintEffect string

TaintEffect represents an effect of the node's taint.

const (
	NoScheduleEffect       TaintEffect = "NoSchedule"
	NoExecuteEffect        TaintEffect = "NoExecute"
	PreferNoScheduleEffect TaintEffect = "PreferNoSchedule"
)

type UpdateOpts added in v0.3.0

type UpdateOpts struct {
	// Labels represents an object containing a set of Kubernetes labels that will be applied
	// for each node in the group. The keys must be user-defined.
	Labels map[string]string `json:"labels"`

	// Taints represents a list of nodegroup taints which will be applied
	// for each node in the group.
	Taints []Taint `json:"taints"`

	// EnableAutoscale reflects if the nodegroup is allowed to be scaled automatically.
	EnableAutoscale *bool `json:"enable_autoscale,omitempty"`

	// AutoscaleMinNodes represents minimum possible number of worker nodes in the nodegroup.
	AutoscaleMinNodes *int `json:"autoscale_min_nodes,omitempty"`

	// AutoscaleMaxNodes represents maximum possible number of worker nodes in the nodegroup.
	AutoscaleMaxNodes *int `json:"autoscale_max_nodes,omitempty"`
}

UpdateOpts represents options for the nodegroup Update 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"`

	// Labels represents an object containing a set of Kubernetes labels that will be applied
	// for each node in the group. The keys must be user-defined.
	Labels map[string]string `json:"labels"`

	// Taints represents a list of nodegroup taints.
	Taints []Taint `json:"taints"`

	// EnableAutoscale reflects if the nodegroup is allowed to be scaled automatically.
	EnableAutoscale bool `json:"enable_autoscale"`

	// AutoscaleMinNodes represents minimum possible number of worker nodes in the nodegroup.
	AutoscaleMinNodes int `json:"autoscale_min_nodes"`

	// AutoscaleMaxNodes represents maximum possible number of worker nodes in the nodegroup.
	AutoscaleMaxNodes int `json:"autoscale_max_nodes"`

	// NodegroupType represents nodegroup type.
	NodegroupType string `json:"nodegroup_type"`
}

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