vsphere

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 50 Imported by: 0

README

vSphere Provider

The original vSphere provider template was generated with clusterctl and modified to support EKS-D. The template is stored in pkg/providers/vsphere/config/template.yaml The original file is stored in pkg/providers/vsphere/testdata/original_077.yaml so it can be used to compare against the files generated with future versions of CAPV.

You may use the generate.sh script to generate a new template using clusterctl.

Documentation

Index

Constants

View Source
const (
	CredentialsObjectName = "vsphere-credentials"

	MemoryAvailable = "Memory_Available"
)

Variables

This section is empty.

Functions

func AnyImmutableFieldChanged

func AnyImmutableFieldChanged(oldVdc, newVdc *v1alpha1.VSphereDatacenterConfig, oldVmc, newVmc *v1alpha1.VSphereMachineConfig) bool

func NeedsNewControlPlaneTemplate

func NeedsNewControlPlaneTemplate(oldSpec, newSpec *cluster.Spec, oldVdc, newVdc *v1alpha1.VSphereDatacenterConfig, oldVmc, newVmc *v1alpha1.VSphereMachineConfig) bool

func NeedsNewEtcdTemplate

func NeedsNewEtcdTemplate(oldSpec, newSpec *cluster.Spec, oldVdc, newVdc *v1alpha1.VSphereDatacenterConfig, oldVmc, newVmc *v1alpha1.VSphereMachineConfig) bool

func NeedsNewKubeadmConfigTemplate added in v0.7.1

func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeVmc *v1alpha1.VSphereMachineConfig, newWorkerNodeVmc *v1alpha1.VSphereMachineConfig) bool

func NeedsNewWorkloadTemplate

func NeedsNewWorkloadTemplate(oldSpec, newSpec *cluster.Spec, oldVdc, newVdc *v1alpha1.VSphereDatacenterConfig, oldVmc, newVmc *v1alpha1.VSphereMachineConfig, oldWorker, newWorker v1alpha1.WorkerNodeGroupConfiguration) bool

NeedsNewWorkloadTemplate determines if a new workload template is needed.

func NewProvider

func NewProvider(
	datacenterConfig *v1alpha1.VSphereDatacenterConfig,
	clusterConfig *v1alpha1.Cluster,
	providerGovcClient ProviderGovcClient,
	providerKubectlClient ProviderKubectlClient,
	writer filewriter.FileWriter,
	ipValidator IPValidator,
	now types.NowFunc,
	skipIPCheck bool,
	skippedValidations map[string]bool,
) *vsphereProvider

NewProvider initializes and returns a new vsphereProvider.

func NewProviderCustomNet

func NewProviderCustomNet(
	datacenterConfig *v1alpha1.VSphereDatacenterConfig,
	clusterConfig *v1alpha1.Cluster,
	providerGovcClient ProviderGovcClient,
	providerKubectlClient ProviderKubectlClient,
	writer filewriter.FileWriter,
	ipValidator IPValidator,
	now types.NowFunc,
	skipIPCheck bool,
	v *Validator,
	skippedValidations map[string]bool,
) *vsphereProvider

NewProviderCustomNet initializes and returns a new vsphereProvider.

func SetupEnvVars added in v0.7.0

func SetupEnvVars(datacenterConfig *anywherev1.VSphereDatacenterConfig) error

Types

type BaseControlPlane added in v0.13.0

BaseControlPlane represents a CAPI VSphere control plane.

type ControlPlane added in v0.13.0

type ControlPlane struct {
	BaseControlPlane
	Secrets             []*corev1.Secret
	ConfigMaps          []*corev1.ConfigMap
	ClusterResourceSets []*addonsv1.ClusterResourceSet
}

ControlPlane holds the VSphere specific objects for a CAPI VSphere control plane.

func ControlPlaneSpec added in v0.13.0

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

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

func (ControlPlane) Objects added in v0.13.0

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

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

type ControlPlaneBuilder added in v0.13.0

type ControlPlaneBuilder struct {
	BaseBuilder  *yamlcapi.ControlPlaneBuilder[*vspherev1.VSphereCluster, *vspherev1.VSphereMachineTemplate]
	ControlPlane *ControlPlane
}

ControlPlaneBuilder defines the builder for all objects in the CAPI VSphere control plane.

func (*ControlPlaneBuilder) BuildFromParsed added in v0.13.0

func (b *ControlPlaneBuilder) BuildFromParsed(lookup yamlutil.ObjectLookup) error

BuildFromParsed implements the base yamlcapi.BuildFromParsed and processes any additional objects for the VSphere control plane.

type Defaulter added in v0.7.0

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

func NewDefaulter added in v0.7.0

func NewDefaulter(govc ProviderGovcClient) *Defaulter

func (*Defaulter) SetDefaultsForDatacenterConfig added in v0.7.0

func (d *Defaulter) SetDefaultsForDatacenterConfig(ctx context.Context, datacenterConfig *anywherev1.VSphereDatacenterConfig) error

type IPValidator added in v0.13.0

type IPValidator interface {
	ValidateControlPlaneIPUniqueness(cluster *v1alpha1.Cluster) error
}

IPValidator is an interface that defines methods to validate the control plane IP.

type MachineConfigCount added in v0.18.0

type MachineConfigCount struct {
	*anywherev1.VSphereMachineConfig
	Count int
}

MachineConfigCount represents a machineConfig with it's associated count.

type PrivAssociation added in v0.11.2

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

type ProviderGovcClient

type ProviderGovcClient interface {
	SearchTemplate(ctx context.Context, datacenter, template string) (string, error)
	LibraryElementExists(ctx context.Context, library string) (bool, error)
	GetLibraryElementContentVersion(ctx context.Context, element string) (string, error)
	DeleteLibraryElement(ctx context.Context, element string) error
	TemplateHasSnapshot(ctx context.Context, template string) (bool, error)
	GetWorkloadAvailableSpace(ctx context.Context, datastore string) (float64, error)
	ValidateVCenterSetupMachineConfig(ctx context.Context, datacenterConfig *v1alpha1.VSphereDatacenterConfig, machineConfig *v1alpha1.VSphereMachineConfig, selfSigned *bool) error
	ValidateVCenterConnection(ctx context.Context, server string) error
	ValidateVCenterAuthentication(ctx context.Context) error
	IsCertSelfSigned(ctx context.Context) bool
	GetCertThumbprint(ctx context.Context) (string, error)
	ConfigureCertThumbprint(ctx context.Context, server, thumbprint string) error
	DatacenterExists(ctx context.Context, datacenter string) (bool, error)
	NetworkExists(ctx context.Context, network string) (bool, error)
	CreateLibrary(ctx context.Context, datastore, library string) error
	DeployTemplateFromLibrary(ctx context.Context, templateDir, templateName, library, datacenter, datastore, network, resourcePool string, resizeDisk2 bool) error
	ImportTemplate(ctx context.Context, library, ovaURL, name string) error
	GetVMDiskSizeInGB(ctx context.Context, vm, datacenter string) (int, error)
	GetTags(ctx context.Context, path string) (tags []string, err error)
	ListTags(ctx context.Context) ([]executables.Tag, error)
	CreateTag(ctx context.Context, tag, category string) error
	AddTag(ctx context.Context, path, tag string) error
	ListCategories(ctx context.Context) ([]string, error)
	CreateCategoryForVM(ctx context.Context, name string) error
	CreateUser(ctx context.Context, username string, password string) error
	UserExists(ctx context.Context, username string) (bool, error)
	CreateGroup(ctx context.Context, name string) error
	GroupExists(ctx context.Context, name string) (bool, error)
	AddUserToGroup(ctx context.Context, name string, username string) error
	RoleExists(ctx context.Context, name string) (bool, error)
	CreateRole(ctx context.Context, name string, privileges []string) error
	SetGroupRoleOnObject(ctx context.Context, principal string, role string, object string, domain string) error
	GetHardDiskSize(ctx context.Context, vm, datacenter string) (map[string]float64, error)
	GetResourcePoolInfo(ctx context.Context, datacenter, resourcepool string, args ...string) (map[string]int, error)
}

type ProviderKubectlClient

type ProviderKubectlClient interface {
	ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error
	CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig string, namespace string) error
	LoadSecret(ctx context.Context, secretObject string, secretObjType string, secretObjectName string, kubeConfFile string) error
	GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error)
	GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereDatacenterConfig, error)
	GetEksaVSphereMachineConfig(ctx context.Context, vsphereMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereMachineConfig, error)
	GetMachineDeployment(ctx context.Context, machineDeploymentName string, opts ...executables.KubectlOpt) (*clusterv1.MachineDeployment, error)
	GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*controlplanev1.KubeadmControlPlane, error)
	GetEtcdadmCluster(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*etcdv1.EtcdadmCluster, error)
	GetSecretFromNamespace(ctx context.Context, kubeconfigFile, name, namespace string) (*corev1.Secret, error)
	UpdateAnnotation(ctx context.Context, resourceType, objectName string, annotations map[string]string, opts ...executables.KubectlOpt) error
	RemoveAnnotationInNamespace(ctx context.Context, resourceType, objectName, key string, cluster *types.Cluster, namespace string) error
	SearchVsphereMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereMachineConfig, error)
	SearchVsphereDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error)
	SetDaemonSetImage(ctx context.Context, kubeconfigFile, name, namespace, container, image string) error
	DeleteEksaDatacenterConfig(ctx context.Context, vsphereDatacenterResourceType string, vsphereDatacenterConfigName string, kubeconfigFile string, namespace string) error
	DeleteEksaMachineConfig(ctx context.Context, vsphereMachineResourceType string, vsphereMachineConfigName string, kubeconfigFile string, namespace string) error
	ApplyTolerationsFromTaintsToDaemonSet(ctx context.Context, oldTaints []corev1.Taint, newTaints []corev1.Taint, dsName string, kubeconfigFile string) error
}

type Spec added in v0.7.0

type Spec struct {
	*cluster.Spec
}

func NewSpec added in v0.7.0

func NewSpec(clusterSpec *cluster.Spec) *Spec

NewSpec constructs a new vSphere cluster Spec.

type VSphereClientBuilder added in v0.11.2

type VSphereClientBuilder interface {
	Build(ctx context.Context, host string, username string, password string, insecure bool, datacenter string) (govmomi.VSphereClient, error)
}

type Validator added in v0.7.0

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

func NewValidator added in v0.7.0

func NewValidator(govc ProviderGovcClient, vscb VSphereClientBuilder) *Validator

NewValidator initializes the client for VSphere provider validations.

func (*Validator) ValidateClusterMachineConfigs added in v0.7.0

func (v *Validator) ValidateClusterMachineConfigs(ctx context.Context, vsphereClusterSpec *Spec) error

ValidateClusterMachineConfigs validates all the attributes of etcd, control plane, and worker node VSphereMachineConfigs.

func (*Validator) ValidateVCenterConfig added in v0.7.0

func (v *Validator) ValidateVCenterConfig(ctx context.Context, datacenterConfig *anywherev1.VSphereDatacenterConfig) error

type VsphereTemplateBuilder

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

func NewVsphereTemplateBuilder

func NewVsphereTemplateBuilder(
	now types.NowFunc,
) *VsphereTemplateBuilder

func (*VsphereTemplateBuilder) CAPIWorkersSpecWithInitialNames added in v0.13.0

func (vs *VsphereTemplateBuilder) CAPIWorkersSpecWithInitialNames(spec *cluster.Spec) (content []byte, err error)

CAPIWorkersSpecWithInitialNames generates a yaml spec with the CAPI objects representing the worker nodes for a particular eks-a cluster. It uses default initial names (ended in '-1') for the vsphere machine templates and kubeadm config templates.

func (*VsphereTemplateBuilder) GenerateCAPISpecControlPlane added in v0.6.0

func (vs *VsphereTemplateBuilder) GenerateCAPISpecControlPlane(
	clusterSpec *cluster.Spec,
	buildOptions ...providers.BuildMapOption,
) (content []byte, err error)

func (*VsphereTemplateBuilder) GenerateCAPISpecWorkers added in v0.6.0

func (vs *VsphereTemplateBuilder) GenerateCAPISpecWorkers(
	clusterSpec *cluster.Spec,
	workloadTemplateNames,
	kubeadmconfigTemplateNames map[string]string,
) (content []byte, err error)

type Workers added in v0.13.0

Workers represents the vSphere specific CAPI spec for worker nodes.

func WorkersSpec added in v0.13.0

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

WorkersSpec generates a vSphere 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.

Directories

Path Synopsis
internal
tags/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
templates/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
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.
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