cluster

package
v0.0.0-...-ddf91f6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

This section is empty.

Functions

func CreateInstance

func CreateInstance(ctx context.Context, client *oxide.Client, projectID, instanceName string, spec config.NodeSpec, cloudConfig string) (*oxide.Instance, error)

func GenerateCloudConfig

func GenerateCloudConfig(nodeType string, initCluster bool, controlPlaneIP, joinToken string, pubkey []string, extraDisk, tailscaleAuthKey, tailscaleTag string) ([]byte, error)

GenerateCloudConfig for a particular node type

func GenerateCloudConfigB64

func GenerateCloudConfigB64(nodeType string, initCluster bool, controlPlaneIP, joinToken string, pubkey []string, extraDisk, tailscaleAuthKey, tailscaleTag string) (string, error)

GenerateCloudConfigB64 generates a base64 encoded cloud config for a particular node type

func GetControlPlaneIP

func GetControlPlaneIP(ctx context.Context, logger *log.Entry, client *oxide.Client, projectID, controlPlanePrefix string) (*oxide.FloatingIp, error)

func GetSecretConfig

func GetSecretConfig(ctx context.Context, apiConfig *rest.Config, logger *log.Entry, namespace, secret string) (*config.ControllerConfig, error)

func getSecretValue(ctx context.Context, apiConfig *rest.Config, logger *log.Entry, namespace, secret, key string) ([]byte, error) {

func NewSecretKeyNotFoundError

func NewSecretKeyNotFoundError(key string) error

Types

type CloudConfig

type CloudConfig struct {
	Hostname           string           `yaml:"hostname,omitempty"`
	ManageEtcHosts     bool             `yaml:"manage_etc_hosts,omitempty"`
	Packages           []string         `yaml:"packages,omitempty"`
	WriteFiles         []WriteFile      `yaml:"write_files,omitempty"`
	RunCmd             MultiLineStrings `yaml:"runcmd,omitempty"`
	Users              []User           `yaml:"users,omitempty"`
	SSHPWAuth          bool             `yaml:"ssh_pwauth"`            // disables password logins
	DisableRoot        bool             `yaml:"disable_root"`          // ensure root isn't disabled
	AllowPublicSSHKeys bool             `yaml:"allow_public_ssh_keys"` // allow public SSH keys
}

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

func New

func New(logger *log.Entry, ctrlrConfig *config.ControllerConfig, kubeconfigOverwrite bool, ociImage string, initWait time.Duration) *Cluster

New creates a new Cluster instance

func (*Cluster) CreateControlPlaneNodes

func (c *Cluster) CreateControlPlaneNodes(ctx context.Context, initCluster bool, count, start int, additionalPubKeys []string) ([]oxide.Instance, error)

createControlPlaneNodes creates new control plane nodes

func (*Cluster) EnsureWorkerNodes

func (c *Cluster) EnsureWorkerNodes(ctx context.Context) ([]oxide.Instance, error)

EnsureWorkerNodes ensures the count of worker nodes matches what it should be

func (*Cluster) Execute

func (c *Cluster) Execute(ctx context.Context) (newKubeconfig []byte, err error)

Execute execute the core functionality, which includes: 1. Verifying the project exists 2. Verifying the images exist 3. Verifying the cluster exists 4. Ensuring the worker nodes exist as desired 5. Returning the new kubeconfig, if any

func (*Cluster) GetJoinToken

func (c *Cluster) GetJoinToken(ctx context.Context) (string, error)

GetJoinToken retrieves a new k3s worker join token from the Kubernetes cluster

func (*Cluster) GetOxideToken

func (c *Cluster) GetOxideToken(ctx context.Context) ([]byte, error)

GetOxideToken retrieves the oxide token from the Kubernetes cluster

func (*Cluster) GetOxideURL

func (c *Cluster) GetOxideURL(ctx context.Context) ([]byte, error)

GetOxideURL retrieves the oxide URL from the Kubernetes cluster

func (*Cluster) GetUserSSHPublicKey

func (c *Cluster) GetUserSSHPublicKey(ctx context.Context) ([]byte, error)

GetUserSSHPublicKey retrieves the SSH public key from the Kubernetes cluster

func (*Cluster) GetWorkerCount

func (c *Cluster) GetWorkerCount(ctx context.Context) (int, error)

GetWorkerCount retrieves the targeted worker count from the Kubernetes cluster

func (*Cluster) GetWorkerNodeCount

func (c *Cluster) GetWorkerNodeCount() (int, error)

GetWorkerNodeCount gets the number of worker nodes in the cluster

func (*Cluster) LoadControllerToClusterNodes

func (c *Cluster) LoadControllerToClusterNodes(ctx context.Context, infile io.ReadCloser) error

LoadControllerToClusterNodes loads the controller binary to all control plane nodes in the cluster. It is not intended to persist, just used for development purposes. The namespace and pod used are per the cluster configuration.

func (*Cluster) LoadHelmCharts

func (c *Cluster) LoadHelmCharts(ctx context.Context) error

LoadHelmCharts loads the embedded Helm charts into the cluster.

func (*Cluster) SetWorkerCount

func (c *Cluster) SetWorkerCount(ctx context.Context, count int) error

SetWorkerCount sets the targeted worker count in the Kubernetes cluster

type Config

type Config struct {
	*rest.Config
	Source ConfigSource
}

func GetRestConfig

func GetRestConfig(kubeconfigRaw []byte) (*Config, error)

type ConfigSource

type ConfigSource int
const (
	ConfigSourceProvidedKubeconfig ConfigSource = iota
	ConfigSourceDefaultKubeconfig
	ConfigSourceInCluster
)

type MultiLineStrings

type MultiLineStrings [][]string

func (MultiLineStrings) MarshalYAML

func (m MultiLineStrings) MarshalYAML() (interface{}, error)

MarshalYAML formats each inner slice as a block scalar string

type SecretKeyNotFoundError

type SecretKeyNotFoundError struct {
	// contains filtered or unexported fields
}

func (*SecretKeyNotFoundError) Error

func (e *SecretKeyNotFoundError) Error() string

func (*SecretKeyNotFoundError) Is

func (e *SecretKeyNotFoundError) Is(target error) bool

type StaticRESTClientGetter

type StaticRESTClientGetter struct {
	RestConfig *rest.Config
	Namespace  string
}

func (*StaticRESTClientGetter) ToDiscoveryClient

func (*StaticRESTClientGetter) ToNamespace

func (s *StaticRESTClientGetter) ToNamespace() (string, error)

func (*StaticRESTClientGetter) ToRESTConfig

func (s *StaticRESTClientGetter) ToRESTConfig() (*rest.Config, error)

func (*StaticRESTClientGetter) ToRESTMapper

func (s *StaticRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)

func (*StaticRESTClientGetter) ToRawKubeConfigLoader

func (s *StaticRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig

type User

type User struct {
	Name              string   `yaml:"name"`
	Shell             string   `yaml:"shell,omitempty"`
	SSHAuthorizedKeys []string `yaml:"ssh-authorized-keys,omitempty"`
}

type WriteFile

type WriteFile struct {
	Path        string `yaml:"path"`
	Permissions string `yaml:"permissions,omitempty"`
	Content     string `yaml:"content"`
}

Jump to

Keyboard shortcuts

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