v1

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Example
a, err := api.NewAPI(api.WithClientOptions(client.AuthFromEnv(false)))
if err != nil {
	log.Fatalf("failed to initialize API client: %s", err)
}

cluster := Cluster{Name: "example", NeedsServiceVMs: pointer.Bool(true)}

if err := a.Create(context.TODO(), &cluster); err != nil {
	log.Fatalf("failed to create cluster: %s", err)
}

if err := gs.AwaitCompletion(context.TODO(), a, &cluster); err != nil {
	log.Fatalf("failed to await cluster creation: %s", err)
}

// define node pool with a single replica, 2 GiB of system memory and 20 GiB of disk space
nodePool := NodePool{Name: "example-np-00", Cluster: cluster, Replicas: pointer.Int(1), Memory: 2 * 1073741824, DiskSize: 20 * 1073741824}

if err := a.Create(context.TODO(), &nodePool); err != nil {
	log.Fatalf("failed to create nodepool: %s", err)
}

if err := gs.AwaitCompletion(context.TODO(), a, &nodePool); err != nil {
	log.Fatalf("failed to await nodepool creation: %s", err)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrManagedPrefixSet = errors.New("managed prefixes cannot be set on create")

ErrManagedPrefixSet is returned if a prefix is both set to managed and also set to an existing prefix on create

Functions

func GetKubeConfig

func GetKubeConfig(ctx context.Context, a api.API, clusterID string) (string, error)

GetKubeConfig retrieves the kubeconfig

func RemoveKubeConfig

func RemoveKubeConfig(ctx context.Context, a api.API, clusterID string) error

RemoveKubeConfig triggers the "Remove kubeconfig" automation rule

func RequestKubeConfig

func RequestKubeConfig(ctx context.Context, a api.API, clusterID string) error

RequestKubeConfig triggers the "Request kubeconfig" automation rule

Types

type Cluster

type Cluster struct {
	gs.GenericService
	gs.HasState

	// Identifier of the cluster
	Identifier string `json:"identifier,omitempty" anxcloud:"identifier"`
	// Name of the cluster. Must be an RFC 1123 hostname in lowercase
	Name string `json:"name,omitempty"`
	// Kubernetes version to be used for the cluster. We recommend to use the default value.
	Version string `json:"version,omitempty"`
	// Location where the cluster will be deployed
	Location corev1.Location `json:"location,omitempty"`
	// If set to true, Service VMs providing load balancers and outbound masquerade are created for this cluster.
	// Default: true. Optional value can be set via pkg/utils/pointer.Bool
	NeedsServiceVMs *bool `json:"needs_service_vms,omitempty"`
	// If enabled, Service VMs are configured as NAT gateways connecting the internal cluster network to the internet.
	// Requires Service VMs.
	EnableNATGateways *bool `json:"enable_nat_gateways,omitempty"`
	// If enabled, Service VMs are set up as LBaaS hosts enabling K8s services of type LoadBalancer.
	// Requires Service VMs.
	EnableLBaaS *bool `json:"enable_lbaas,omitempty"`

	// Identifier of an internal v4 prefix (to be) assigned to the cluster. If ManageInternalIPv4Prefix
	// is set to false, the Prefix given in this field is used when creating the cluster, otherwise a new
	// prefix will be created automatically. The API will always return the Prefix for the Cluster,
	// when ManageInternalIPv4Prefix is true, this will be the Prefix that was created automatically.
	InternalIPv4Prefix *common.PartialResource `json:"internal_ipv4_prefix,omitempty"`
	// Identifier of an external v4 prefix (to be) assigned to the cluster. If ManageExternalIPv4Prefix
	// is set to false, the Prefix given in this field is used when creating the cluster, otherwise a new
	// prefix will be created automatically. The API will always return the Prefix for the Cluster,
	// when ManageExternalIPv4Prefix is true, this will be the Prefix that was created automatically.
	ExternalIPv4Prefix *common.PartialResource `json:"external_ipv4_prefix,omitempty"`
	// Identifier of an external v6 prefix (to be) assigned to the cluster. If ManageExternalIPv6Prefix
	// is set to false, the Prefix given in this field is used when creating the cluster, otherwise a new
	// prefix will be created automatically. The API will always return the Prefix for the Cluster,
	// when ManageExternalIPv6Prefix is true, this will be the Prefix that was created automatically.
	ExternalIPv6Prefix *common.PartialResource `json:"external_ipv6_prefix,omitempty"`

	// If set to true an internal v4 prefix is automatically created for the cluster. Defaults to true if not set.
	ManageInternalIPv4Prefix *bool `json:"manage_internal_ipv4_prefix,omitempty"`
	// If set to true an external v4 prefix is automatically created for the cluster. Defaults to true if not set.
	ManageExternalIPv4Prefix *bool `json:"manage_external_ipv4_prefix,omitempty"`
	// If set to true an external v6 prefix is automatically created for the cluster. Defaults to true if not set.
	ManageExternalIPv6Prefix *bool `json:"manage_external_ipv6_prefix,omitempty"`

	// Contains a kubeconfig if available
	KubeConfig *string `json:"kubeconfig,omitempty"`

	// Enable autoscaling for this cluster. You will need to explicitly configure
	// your node pools for autoscaling, please refer to the provided [Autoscaling documentation]
	// for details. Defaults to false if unset.
	//
	// [Autoscaling documentation]: https://engine.anexia-it.com/docs/en/module/kubernetes/user-guide/autoscaling
	EnableAutoscaling *bool `json:"autoscaling,omitempty"`
}

Cluster represents a Kubernetes cluster This resource does not support updates

func (*Cluster) EndpointURL

func (c *Cluster) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the common URL for operations on Cluster resource

func (*Cluster) FilterAPIRequestBody

func (c *Cluster) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody adds the CommonRequestBody

func (*Cluster) GetIdentifier

func (o *Cluster) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a Cluster object

type NodePool

type NodePool struct {
	gs.GenericService
	gs.HasState

	// Identifier of the node pool
	Identifier string `json:"identifier,omitempty" anxcloud:"identifier"`
	// Name of the node pool. Must be an RFC 1123 hostname in lowercase
	Name string `json:"name,omitempty"`
	// Cluster in which the node pool is deployed
	Cluster Cluster `json:"cluster,omitempty" anxcloud:"filterable"`

	// Number of replicas. Can be changed via machine controller.
	// Default: 3 (see FAQ for more details) Optional value can be set via pkg/utils/pointer.Int
	Replicas *int `json:"replicas,omitempty"`
	// Number of computation cores for each node. The provided cores will be "performance" type CPUs. Must be at least 1 and no more than 16
	CPUs int `json:"cpus,omitempty"`
	// RAM size for each node in bytes. Must be a multiple of 1 GiB, at least 2 GiB and no more than 64 GiB
	Memory int `json:"memory,omitempty"`
	// Size of the disk for each node in bytes. Its performance type will be the default Anexia Engine provides for the given location.
	// Must be a multiple of 1 GiB, at least 20 GiB and no more than 1600 GiB
	DiskSize int `json:"disk_size,omitempty"`

	// Operating system for deployment on the nodes. Default: Flatcar Linux
	OperatingSystem OperatingSystem `json:"operating_system,omitempty"`
}

NodePool represents a Kubernetes node pool This resource does not support updates

func (*NodePool) EndpointURL

func (np *NodePool) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the common URL for operations on NodePool resource

func (*NodePool) FilterAPIRequestBody

func (np *NodePool) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody adds the CommonRequestBody and unwraps the identifiers of related Objects

func (*NodePool) GetIdentifier

func (o *NodePool) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a NodePool object

type OperatingSystem

type OperatingSystem string

OperatingSystem is a typed string for available OS templates

const (
	// FlatcarLinux is currently the only available OS template available for Kubernetes Node Pools
	FlatcarLinux OperatingSystem = "Flatcar Linux"
)

Jump to

Keyboard shortcuts

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