snow

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SnowClusterKind is the kubernetes object kind for CAPAS Cluster.
	SnowClusterKind = "AWSSnowCluster"
	// SnowMachineTemplateKind is the kubernetes object kind for CAPAS machine template.
	SnowMachineTemplateKind = "AWSSnowMachineTemplate"
	// SnowIPPoolKind is the kubernetes object kind for CAPAS IP pool.
	SnowIPPoolKind = "AWSSnowIPPool"
)

Variables

This section is empty.

Functions

func CAPASCredentialsSecret added in v0.12.0

func CAPASCredentialsSecret(clusterSpec *cluster.Spec, credsB64, certsB64 []byte) *v1.Secret

func CAPICluster

func CAPICluster(clusterSpec *cluster.Spec, snowCluster *snowv1.AWSSnowCluster, kubeadmControlPlane *controlplanev1.KubeadmControlPlane, etcdCluster *etcdv1.EtcdadmCluster) *clusterv1.Cluster

CAPICluster generates the CAPICluster object for snow provider.

func CAPIObjects added in v0.9.0

func CAPIObjects(ctx context.Context, log logr.Logger, clusterSpec *cluster.Spec, kubeClient kubernetes.Client) (controlPlaneSpec, workersSpec []byte, err error)

CAPIObjects generates the control plane and worker nodes objects for snow provider from clusterSpec.

func ControlPlaneObjects

func ControlPlaneObjects(ctx context.Context, log logr.Logger, clusterSpec *cluster.Spec, kubeClient kubernetes.Client) ([]kubernetes.Object, error)

ControlPlaneObjects generates the control plane objects for snow provider from clusterSpec.

func CredentialsSecret added in v0.12.0

func CredentialsSecret(name, namespace string, credsB64, certsB64 []byte) *v1.Secret

func CredentialsSecretName added in v0.12.0

func CredentialsSecretName(clusterSpec *cluster.Spec) string

func EksaCredentialsSecret added in v0.12.0

func EksaCredentialsSecret(datacenter *v1alpha1.SnowDatacenterConfig, credsB64, certsB64 []byte) *v1.Secret

func EtcdadmCluster added in v0.14.0

func EtcdadmCluster(log logr.Logger, clusterSpec *cluster.Spec, snowMachineTemplate *snowv1.AWSSnowMachineTemplate) *etcdv1.EtcdadmCluster

EtcdadmCluster builds an etcdadmCluster based on an eks-a cluster spec and snowMachineTemplate.

func KubeadmConfigTemplate added in v0.11.0

func KubeadmConfigTemplate(log logr.Logger, clusterSpec *cluster.Spec, workerNodeGroupConfig v1alpha1.WorkerNodeGroupConfiguration) (*bootstrapv1.KubeadmConfigTemplate, error)

KubeadmConfigTemplate generates the kubeadmConfigTemplate object for snow provider from clusterSpec and workerNodeGroupConfig.

func KubeadmControlPlane

func KubeadmControlPlane(log logr.Logger, clusterSpec *cluster.Spec, snowMachineTemplate *snowv1.AWSSnowMachineTemplate) (*controlplanev1.KubeadmControlPlane, error)

KubeadmControlPlane generates the kubeadmControlPlane object for snow provider from clusterSpec and snowMachineTemplate.

func MachineTemplate added in v0.14.0

func MachineTemplate(name string, machineConfig *v1alpha1.SnowMachineConfig, capasPools CAPASIPPools) *snowv1.AWSSnowMachineTemplate

MachineTemplate builds a snowMachineTemplate based on an eks-a snowMachineConfig and a capasIPPool.

func MachineTemplateDeepDerivative added in v0.12.0

func MachineTemplateDeepDerivative(new, old *snowv1.AWSSnowMachineTemplate) bool

MachineTemplateDeepDerivative compares two awssnowmachinetemplates to determine if their spec fields are equal. DeepDerivative is used so that unset fields in new object are not compared. Although DeepDerivative treats new subset slice equal to the original slice. i.e. DeepDerivative([]int{1}, []int{1, 2}) returns true. Custom logic is added to justify this usecase since removing a device from the devices list shall trigger machine rollout and recreate or the snow cluster goes into a state where the machines on the removed device can’t be deleted.

func SetupEksaCredentialsSecret added in v0.12.0

func SetupEksaCredentialsSecret(c *cluster.Config) error

func SnowCluster

func SnowCluster(clusterSpec *cluster.Spec, credentialsSecret *v1.Secret) *snowv1.AWSSnowCluster

func WorkersObjects

func WorkersObjects(ctx context.Context, log logr.Logger, clusterSpec *cluster.Spec, kubeClient kubernetes.Client) ([]kubernetes.Object, error)

WorkersObjects generates all the objects that compose a Snow specific CAPI spec for the worker nodes of an eks-a cluster.

Types

type AwsClient added in v0.9.0

type AwsClient interface {
	EC2ImageExists(ctx context.Context, imageID string) (bool, error)
	EC2KeyNameExists(ctx context.Context, keyName string) (bool, error)
	EC2ImportKeyPair(ctx context.Context, keyName string, keyMaterial []byte) error
	EC2InstanceTypes(ctx context.Context) ([]aws.EC2InstanceType, error)
	IsSnowballDeviceUnlocked(ctx context.Context) (bool, error)
	SnowballDeviceSoftwareVersion(ctx context.Context) (string, error)
}

type AwsClientMap added in v0.9.0

type AwsClientMap map[string]AwsClient

func NewAwsClientMap added in v0.9.0

func NewAwsClientMap(awsClients aws.Clients) AwsClientMap

type AwsClientRegistry added in v0.11.0

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

func NewAwsClientRegistry added in v0.11.0

func NewAwsClientRegistry() *AwsClientRegistry

func (*AwsClientRegistry) Build added in v0.11.0

func (b *AwsClientRegistry) Build(ctx context.Context) error

Build creates the device client map based on the filepaths specified. This method must be called before any Get operations.

func (*AwsClientRegistry) Get added in v0.11.0

type BaseControlPlane added in v0.14.0

BaseControlPlane represents a CAPI Snow control plane.

type BaseWorkers added in v0.14.0

BaseWorkers represents the Snow specific CAPI spec for worker nodes.

type CAPASIPPools added in v0.14.0

type CAPASIPPools map[string]*snowv1.AWSSnowIPPool

CAPASIPPools defines a set of CAPAS AWSSnowPool objects.

type ClientRegistry added in v0.11.0

type ClientRegistry interface {
	Get(ctx context.Context) (AwsClientMap, error)
}

type ConfigManager added in v0.9.0

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

func NewConfigManager added in v0.9.0

func NewConfigManager(defaulters *Defaulters, validators *Validator) *ConfigManager

NewConfigManager returns a new snow config manager.

func (*ConfigManager) SetDefaultsAndValidate added in v0.9.0

func (cm *ConfigManager) SetDefaultsAndValidate(ctx context.Context, config *cluster.Config) error

type ControlPlane added in v0.14.0

type ControlPlane struct {
	BaseControlPlane
	Secret       *corev1.Secret
	CAPASIPPools CAPASIPPools
}

ControlPlane holds the Snow specific objects for a CAPI snow control plane.

func ControlPlaneSpec added in v0.14.0

func ControlPlaneSpec(ctx context.Context, logger logr.Logger, client kubernetes.Client, clusterSpec *cluster.Spec) (*ControlPlane, error)

ControlPlaneSpec builds a snow ControlPlane definition based on an eks-a cluster spec.

func (ControlPlane) Objects added in v0.14.0

func (c ControlPlane) Objects() []kubernetes.Object

Objects returns the control plane objects associated with the snow cluster.

type Defaulters added in v0.9.0

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

func NewDefaulters added in v0.9.0

func NewDefaulters(clientRegistry ClientRegistry, writer filewriter.FileWriter, opts ...DefaultersOpt) *Defaulters

func (*Defaulters) GenerateDefaultSSHKeys added in v0.14.0

func (d *Defaulters) GenerateDefaultSSHKeys(ctx context.Context, machineConfigs map[string]*v1alpha1.SnowMachineConfig, clusterName string) error

GenerateDefaultSSHKeys generates ssh key if it doesn't exist already.

type DefaultersOpt added in v0.11.0

type DefaultersOpt func(defaulters *Defaulters)

func WithKeyGenerator added in v0.11.0

func WithKeyGenerator(generator SshKeyGenerator) DefaultersOpt

func WithUUID added in v0.14.0

func WithUUID(uuid uuid.UUID) DefaultersOpt

WithUUID will set uuid generated outside of constructor.

type KubeUnAuthClient added in v0.9.0

type KubeUnAuthClient interface {
	KubeconfigClient(kubeconfig string) kubernetes.Client
	Apply(ctx context.Context, kubeconfig string, obj runtime.Object) error
}

type LocalIMDSClient added in v0.14.2

type LocalIMDSClient interface {
	EC2InstanceIP(ctx context.Context) (string, error)
}

LocalIMDSClient contains methods that fetch metadata from the local imds.

type MachineConfigDefaulters added in v0.9.0

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

func NewMachineConfigDefaulters added in v0.9.0

func NewMachineConfigDefaulters(d *Defaulters) *MachineConfigDefaulters

func (*MachineConfigDefaulters) SetupDefaultSSHKey added in v0.14.0

func (md *MachineConfigDefaulters) SetupDefaultSSHKey(ctx context.Context, m *v1alpha1.SnowMachineConfig, clusterName string) error

SetupDefaultSSHKey creates and imports a default ssh key to snow devices listed in the snow machine config. If not exist, a ssh auth key is generated locally first. Then we loop through the devices in the machine config, and import the key to any device that does not have the key. In the end the default ssh key name is assigned to the snow machine config.

type SnowProvider added in v0.9.0

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

func NewProvider

func NewProvider(kubeUnAuthClient KubeUnAuthClient, configManager *ConfigManager, skipIpCheck bool) *SnowProvider

func (*SnowProvider) BootstrapClusterOpts added in v0.9.0

func (p *SnowProvider) BootstrapClusterOpts(_ *cluster.Spec) ([]bootstrapper.BootstrapClusterOption, error)

func (*SnowProvider) ChangeDiff added in v0.9.0

func (p *SnowProvider) ChangeDiff(currentComponents, newComponents *cluster.ManagementComponents) *types.ComponentChangeDiff

ChangeDiff returns the change diff from the management components.

func (*SnowProvider) DatacenterConfig added in v0.9.0

func (p *SnowProvider) DatacenterConfig(clusterSpec *cluster.Spec) providers.DatacenterConfig

func (*SnowProvider) DatacenterResourceType added in v0.9.0

func (p *SnowProvider) DatacenterResourceType() string

func (*SnowProvider) DeleteResources added in v0.9.0

func (p *SnowProvider) DeleteResources(ctx context.Context, clusterSpec *cluster.Spec) error

func (*SnowProvider) EnvMap added in v0.9.0

func (p *SnowProvider) EnvMap(managementComponents *cluster.ManagementComponents, clusterSpec *cluster.Spec) (map[string]string, error)

EnvMap returns the environment variables for the snow provider.

func (*SnowProvider) GenerateCAPISpecForCreate added in v0.9.0

func (p *SnowProvider) GenerateCAPISpecForCreate(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error)

func (*SnowProvider) GenerateCAPISpecForUpgrade added in v0.9.0

func (p *SnowProvider) GenerateCAPISpecForUpgrade(ctx context.Context, bootstrapCluster, _ *types.Cluster, _ *cluster.Spec, clusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error)

func (*SnowProvider) GetDeployments added in v0.9.0

func (p *SnowProvider) GetDeployments() map[string][]string

func (*SnowProvider) GetInfrastructureBundle added in v0.9.0

func (p *SnowProvider) GetInfrastructureBundle(components *cluster.ManagementComponents) *types.InfrastructureBundle

GetInfrastructureBundle returns the infrastructure bundle from the management components.

func (*SnowProvider) InstallCustomProviderComponents added in v0.9.0

func (p *SnowProvider) InstallCustomProviderComponents(ctx context.Context, kubeconfigFile string) error

func (*SnowProvider) MachineConfigs added in v0.9.0

func (p *SnowProvider) MachineConfigs(clusterSpec *cluster.Spec) []providers.MachineConfig

func (*SnowProvider) MachineResourceType added in v0.9.0

func (p *SnowProvider) MachineResourceType() string

func (*SnowProvider) Name added in v0.9.0

func (p *SnowProvider) Name() string

func (*SnowProvider) PostBootstrapDeleteForUpgrade added in v0.11.0

func (p *SnowProvider) PostBootstrapDeleteForUpgrade(ctx context.Context, cluster *types.Cluster) error

PostBootstrapDeleteForUpgrade runs any provider-specific operations after bootstrap cluster has been deleted.

func (*SnowProvider) PostBootstrapSetup added in v0.9.0

func (p *SnowProvider) PostBootstrapSetup(ctx context.Context, clusterConfig *v1alpha1.Cluster, cluster *types.Cluster) error

func (*SnowProvider) PostBootstrapSetupUpgrade added in v0.9.2

func (p *SnowProvider) PostBootstrapSetupUpgrade(ctx context.Context, clusterConfig *v1alpha1.Cluster, cluster *types.Cluster) error

func (*SnowProvider) PostClusterDeleteValidate added in v0.9.0

func (p *SnowProvider) PostClusterDeleteValidate(_ context.Context, _ *types.Cluster) error

func (*SnowProvider) PostMoveManagementToBootstrap added in v0.12.0

func (p *SnowProvider) PostMoveManagementToBootstrap(_ context.Context, _ *types.Cluster) error

func (*SnowProvider) PostWorkloadInit added in v0.9.2

func (p *SnowProvider) PostWorkloadInit(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error

func (*SnowProvider) PreCAPIInstallOnBootstrap added in v0.9.0

func (p *SnowProvider) PreCAPIInstallOnBootstrap(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error

PreCAPIInstallOnBootstrap runs the steps that are provider specific before CAPI is installed on the bootstrap cluster.

func (*SnowProvider) PreCoreComponentsUpgrade added in v0.15.0

func (p *SnowProvider) PreCoreComponentsUpgrade(
	ctx context.Context,
	cluster *types.Cluster,
	managementComponents *cluster.ManagementComponents,
	clusterSpec *cluster.Spec,
) error

PreCoreComponentsUpgrade staisfies the Provider interface.

func (*SnowProvider) RunPostControlPlaneUpgrade added in v0.9.0

func (p *SnowProvider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec *cluster.Spec, clusterSpec *cluster.Spec, workloadCluster *types.Cluster, managementCluster *types.Cluster) error

func (*SnowProvider) SetupAndValidateCreateCluster added in v0.9.0

func (p *SnowProvider) SetupAndValidateCreateCluster(ctx context.Context, clusterSpec *cluster.Spec) error

func (*SnowProvider) SetupAndValidateDeleteCluster added in v0.9.0

func (p *SnowProvider) SetupAndValidateDeleteCluster(ctx context.Context, _ *types.Cluster, clusterSpec *cluster.Spec) error

func (*SnowProvider) SetupAndValidateUpgradeCluster added in v0.9.0

func (p *SnowProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error

func (*SnowProvider) SetupAndValidateUpgradeManagementComponents added in v0.19.0

func (p *SnowProvider) SetupAndValidateUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error

SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation.

func (*SnowProvider) UpdateKubeConfig added in v0.9.0

func (p *SnowProvider) UpdateKubeConfig(content *[]byte, clusterName string) error

func (*SnowProvider) UpdateSecrets added in v0.9.0

func (p *SnowProvider) UpdateSecrets(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error

func (*SnowProvider) UpgradeNeeded added in v0.9.0

func (p *SnowProvider) UpgradeNeeded(ctx context.Context, newSpec, oldSpec *cluster.Spec, c *types.Cluster) (bool, error)

UpgradeNeeded compares the new snow version bundle and objects with the existing ones in the cluster and decides whether to trigger a cluster upgrade or not. TODO: revert the change once cluster.BuildSpec is used in cluster_manager to replace the deprecated cluster.BuildSpecForCluster

func (*SnowProvider) ValidateNewSpec added in v0.9.0

func (p *SnowProvider) ValidateNewSpec(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error

func (*SnowProvider) Version added in v0.9.0

func (p *SnowProvider) Version(components *cluster.ManagementComponents) string

Version returns the snow version from the management components.

type SshKeyGenerator added in v0.9.0

type SshKeyGenerator interface {
	GenerateSSHAuthKey(filewriter.FileWriter) (string, error)
}

type Validator added in v0.9.0

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

Validator includes a client registry that maintains a snow device aws client map, and a local imds service that is used to fetch metadata of the host instance.

func NewValidator added in v0.9.0

func NewValidator(clientRegistry ClientRegistry, opts ...ValidatorOpt) *Validator

NewValidator creates a snow validator.

func (*Validator) ValidateControlPlaneIP added in v0.14.2

func (v *Validator) ValidateControlPlaneIP(ctx context.Context, controlPlaneIP string) error

ValidateControlPlaneIP checks whether the control plane ip is valid for creating a snow cluster.

func (*Validator) ValidateDeviceIsUnlocked added in v0.14.2

func (v *Validator) ValidateDeviceIsUnlocked(ctx context.Context, m *v1alpha1.SnowMachineConfig) error

ValidateDeviceIsUnlocked verifies if all snow devices in the device list are unlocked.

func (*Validator) ValidateDeviceSoftware added in v0.14.2

func (v *Validator) ValidateDeviceSoftware(ctx context.Context, m *v1alpha1.SnowMachineConfig) error

ValidateDeviceSoftware validates whether the snow software is compatible to run eks-a in each device.

func (*Validator) ValidateEC2ImageExistsOnDevice added in v0.9.0

func (v *Validator) ValidateEC2ImageExistsOnDevice(ctx context.Context, m *v1alpha1.SnowMachineConfig) error

ValidateEC2ImageExistsOnDevice validates the ami id (if specified) existence in each device in the device list.

func (*Validator) ValidateEC2SshKeyNameExists added in v0.9.0

func (v *Validator) ValidateEC2SshKeyNameExists(ctx context.Context, m *v1alpha1.SnowMachineConfig) error

ValidateEC2SshKeyNameExists validates the ssh key existence in each device in the device list.

func (*Validator) ValidateInstanceType added in v0.14.2

func (v *Validator) ValidateInstanceType(ctx context.Context, m *v1alpha1.SnowMachineConfig) error

ValidateInstanceType validates whether the instance type is compatible to run in each device.

type ValidatorOpt added in v0.14.2

type ValidatorOpt func(*Validator)

ValidatorOpt updates an Validator.

func WithIMDS added in v0.14.2

func WithIMDS(imds LocalIMDSClient) ValidatorOpt

WithIMDS returns a ValidatorOpt that sets the imds client.

type Workers added in v0.13.0

type Workers struct {
	BaseWorkers
	CAPASIPPools CAPASIPPools
}

Workers holds the Snow specific objects for CAPI snow worker groups.

func WorkersSpec added in v0.13.0

func WorkersSpec(ctx context.Context, log logr.Logger, spec *cluster.Spec, client kubernetes.Client) (*Workers, error)

WorkersSpec generates a Snow specific CAPI spec for an eks-a cluster worker nodes. It talks to the cluster with a client to detect changes in immutable objects and generates new names for them.

func (Workers) Objects added in v0.14.0

func (w Workers) Objects() []kubernetes.Object

Objects returns the worker nodes objects associated with the snow cluster.

Directories

Path Synopsis
api
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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