nutanix

package
v0.19.7 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyImmutableFieldChanged

func AnyImmutableFieldChanged(oldNmc, newNmc *v1alpha1.NutanixMachineConfig) bool

func CAPXSecretName added in v0.15.0

func CAPXSecretName(spec *cluster.Spec) string

CAPXSecretName returns the name of the secret containing the credentials for the nutanix prism central and is used by the CAPX controller.

func EKSASecretName added in v0.15.0

func EKSASecretName(spec *cluster.Spec) string

EKSASecretName returns the name of the secret containing the credentials for the nutanix prism central and is used by the EKS-Anywhere controller.

func GetCredsFromEnv added in v0.13.0

func GetCredsFromEnv() credentials.BasicAuthCredential

GetCredsFromEnv returns nutanix credentials based on the environment.

func NeedsNewControlPlaneTemplate

func NeedsNewControlPlaneTemplate(oldSpec, newSpec *cluster.Spec, oldNmc, newNmc *v1alpha1.NutanixMachineConfig) bool

func NeedsNewWorkloadTemplate

func NeedsNewWorkloadTemplate(oldSpec, newSpec *cluster.Spec, oldNmc, newNmc *v1alpha1.NutanixMachineConfig, oldWorker, newWorker v1alpha1.WorkerNodeGroupConfiguration) bool

NeedsNewWorkloadTemplate determines if a new workload template is needed.

Types

type BaseControlPlane added in v0.15.0

BaseControlPlane represents a CAPI Nutanix control plane.

type Client

type Client interface {
	GetSubnet(ctx context.Context, uuid string) (*v3.SubnetIntentResponse, error)
	ListSubnet(ctx context.Context, getEntitiesRequest *v3.DSMetadata) (*v3.SubnetListIntentResponse, error)
	GetImage(ctx context.Context, uuid string) (*v3.ImageIntentResponse, error)
	ListImage(ctx context.Context, getEntitiesRequest *v3.DSMetadata) (*v3.ImageListIntentResponse, error)
	GetCluster(ctx context.Context, uuid string) (*v3.ClusterIntentResponse, error)
	ListCluster(ctx context.Context, getEntitiesRequest *v3.DSMetadata) (*v3.ClusterListIntentResponse, error)
	GetProject(ctx context.Context, uuid string) (*v3.Project, error)
	ListProject(ctx context.Context, getEntitiesRequest *v3.DSMetadata) (*v3.ProjectListResponse, error)
	GetCurrentLoggedInUser(ctx context.Context) (*v3.UserIntentResponse, error)
	ListCategories(ctx context.Context, getEntitiesRequest *v3.CategoryListMetadata) (*v3.CategoryKeyListResponse, error)
	GetCategoryKey(ctx context.Context, name string) (*v3.CategoryKeyStatus, error)
	ListCategoryValues(ctx context.Context, name string, getEntitiesRequest *v3.CategoryListMetadata) (*v3.CategoryValueListResponse, error)
	GetCategoryValue(ctx context.Context, name string, value string) (*v3.CategoryValueStatus, error)
	GetCategoryQuery(ctx context.Context, query *v3.CategoryQueryInput) (*v3.CategoryQueryResponse, error)
}

type ClientCache added in v0.15.0

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

ClientCache is a map of NutanixDatacenterConfig name to Nutanix client.

func NewClientCache added in v0.15.0

func NewClientCache() *ClientCache

NewClientCache returns a new ClientCache.

func (*ClientCache) GetNutanixClient added in v0.15.0

func (cb *ClientCache) GetNutanixClient(datacenterConfig *anywherev1.NutanixDatacenterConfig, creds credentials.BasicAuthCredential) (Client, error)

GetNutanixClient returns a Nutanix client for the given NutanixDatacenterConfig.

type ControlPlane added in v0.15.0

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

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

func ControlPlaneSpec added in v0.15.0

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

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

func (ControlPlane) Objects added in v0.15.0

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

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

type ControlPlaneBuilder added in v0.15.0

type ControlPlaneBuilder struct {
	BaseBuilder  *yamlcapi.ControlPlaneBuilder[*nutanixv1.NutanixCluster, *nutanixv1.NutanixMachineTemplate]
	ControlPlane *ControlPlane
}

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

func (*ControlPlaneBuilder) BuildFromParsed added in v0.15.0

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

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

type Defaulter added in v0.15.0

type Defaulter struct{}

Defaulter implements the defaulting logic for NutanixDatacenterConfig and NutanixMachineConfig.

func NewDefaulter added in v0.15.0

func NewDefaulter() *Defaulter

NewDefaulter returns a new Defaulter.

func (*Defaulter) SetDefaultsForDatacenterConfig added in v0.15.0

func (d *Defaulter) SetDefaultsForDatacenterConfig(dcConf anywherev1.NutanixDatacenterConfig)

SetDefaultsForDatacenterConfig sets defaults for a NutanixDatacenterConfig.

func (*Defaulter) SetDefaultsForMachineConfig added in v0.15.0

func (d *Defaulter) SetDefaultsForMachineConfig(machineConf anywherev1.NutanixMachineConfig)

SetDefaultsForMachineConfig sets defaults for a NutanixMachineConfig.

type IPValidator added in v0.16.0

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

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

type Provider

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

Provider implements the Nutanix Provider.

func NewProvider

func NewProvider(
	datacenterConfig *v1alpha1.NutanixDatacenterConfig,
	machineConfigs map[string]*v1alpha1.NutanixMachineConfig,
	clusterConfig *v1alpha1.Cluster,
	providerKubectlClient ProviderKubectlClient,
	writer filewriter.FileWriter,
	clientCache *ClientCache,
	ipValidator IPValidator,
	certValidator crypto.TlsValidator,
	httpClient *http.Client,
	now types.NowFunc,
	skipIPCheck bool,
) *Provider

NewProvider returns a new nutanix provider.

func (*Provider) BootstrapClusterOpts

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

func (*Provider) BootstrapSetup

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

func (*Provider) ChangeDiff

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

ChangeDiff returns the component change diff for the provider.

func (*Provider) DatacenterConfig

func (p *Provider) DatacenterConfig(_ *cluster.Spec) providers.DatacenterConfig

func (*Provider) DatacenterResourceType

func (p *Provider) DatacenterResourceType() string

func (*Provider) DeleteResources

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

func (*Provider) EnvMap

EnvMap returns the environment variables for the provider.

func (*Provider) GenerateCAPISpecForCreate

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

func (*Provider) GenerateCAPISpecForUpgrade

func (p *Provider) GenerateCAPISpecForUpgrade(ctx context.Context, bootstrapCluster, workloadCluster *types.Cluster, currentSpec, newClusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error)

func (*Provider) GenerateMHC

func (p *Provider) GenerateMHC(_ *cluster.Spec) ([]byte, error)

GenerateMHC returns MachineHealthCheck for the cluster in yaml format.

func (*Provider) GenerateStorageClass

func (p *Provider) GenerateStorageClass() []byte

func (*Provider) GetDeployments

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

func (*Provider) GetInfrastructureBundle

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

GetInfrastructureBundle returns the infrastructure bundle for the provider.

func (*Provider) InstallCustomProviderComponents

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

func (*Provider) MachineConfigs

func (p *Provider) MachineConfigs(_ *cluster.Spec) []providers.MachineConfig

MachineConfigs returns a MachineConfig slice.

func (*Provider) MachineDeploymentsToDelete

func (p *Provider) MachineDeploymentsToDelete(workloadCluster *types.Cluster, currentSpec, newSpec *cluster.Spec) []string

func (*Provider) MachineResourceType

func (p *Provider) MachineResourceType() string

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) PostBootstrapDeleteForUpgrade

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

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

func (*Provider) PostBootstrapSetup

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

func (*Provider) PostBootstrapSetupUpgrade

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

func (*Provider) PostClusterDeleteValidate

func (p *Provider) PostClusterDeleteValidate(ctx context.Context, managementCluster *types.Cluster) error

func (*Provider) PostMoveManagementToBootstrap

func (p *Provider) PostMoveManagementToBootstrap(ctx context.Context, bootstrapCluster *types.Cluster) error

func (*Provider) PostWorkloadInit

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

func (*Provider) PreCAPIInstallOnBootstrap

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

func (*Provider) PreCoreComponentsUpgrade added in v0.15.0

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

PreCoreComponentsUpgrade staisfies the Provider interface.

func (*Provider) RunPostControlPlaneCreation

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

func (*Provider) RunPostControlPlaneUpgrade

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

func (*Provider) SetupAndValidateCreateCluster

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

func (*Provider) SetupAndValidateDeleteCluster

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

func (*Provider) SetupAndValidateUpgradeCluster

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

SetupAndValidateUpgradeCluster - Performs necessary setup and validations for upgrade cluster operation.

func (*Provider) SetupAndValidateUpgradeManagementComponents added in v0.19.0

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

SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation.

func (*Provider) UpdateKubeConfig

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

func (*Provider) UpdateSecrets

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

func (*Provider) UpgradeNeeded

func (p *Provider) UpgradeNeeded(ctx context.Context, newSpec, currentSpec *cluster.Spec, cluster *types.Cluster) (bool, error)

func (*Provider) ValidateNewSpec

func (p *Provider) ValidateNewSpec(_ context.Context, _ *types.Cluster, _ *cluster.Spec) error

func (*Provider) Version

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

Version returns the version of the provider.

type ProviderKubectlClient

type ProviderKubectlClient interface {
	ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error
	SetEksaControllerEnvVar(ctx context.Context, envVar, envVarVal, kubeconfig string) error
	GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error)
	GetEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.NutanixDatacenterConfig, error)
	GetEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.NutanixMachineConfig, error)
	GetEtcdadmCluster(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*etcdv1beta1.EtcdadmCluster, error)
	GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*kubeadmv1beta1.KubeadmControlPlane, error)
	GetMachineDeployment(ctx context.Context, workerNodeGroupName string, opts ...executables.KubectlOpt) (*clusterv1.MachineDeployment, error)
	SearchNutanixMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.NutanixMachineConfig, error)
	SearchNutanixDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.NutanixDatacenterConfig, error)
	DeleteEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName string, kubeconfigFile string, namespace string) error
	DeleteEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName string, kubeconfigFile string, namespace string) error
	UpdateAnnotation(ctx context.Context, resourceType, objectName string, annotations map[string]string, opts ...executables.KubectlOpt) error
}

type TemplateBuilder

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

TemplateBuilder builds templates for nutanix.

func NewNutanixTemplateBuilder

func NewNutanixTemplateBuilder(
	datacenterSpec *v1alpha1.NutanixDatacenterConfigSpec,
	controlPlaneMachineSpec,
	etcdMachineSpec *v1alpha1.NutanixMachineConfigSpec,
	workerNodeGroupMachineSpecs map[string]v1alpha1.NutanixMachineConfigSpec,
	creds credentials.BasicAuthCredential,
	now types.NowFunc,
) *TemplateBuilder

func (*TemplateBuilder) GenerateCAPISpecControlPlane

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

func (*TemplateBuilder) GenerateCAPISpecSecret

func (ntb *TemplateBuilder) GenerateCAPISpecSecret(clusterSpec *cluster.Spec, buildOptions ...providers.BuildMapOption) (content []byte, err error)

GenerateCAPISpecSecret generates the secret containing the credentials for the nutanix prism central and is used by the CAPX controller. The secret is named after the cluster name.

func (*TemplateBuilder) GenerateCAPISpecWorkers

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

func (*TemplateBuilder) GenerateEKSASpecSecret added in v0.15.0

func (ntb *TemplateBuilder) GenerateEKSASpecSecret(clusterSpec *cluster.Spec, buildOptions ...providers.BuildMapOption) (content []byte, err error)

GenerateEKSASpecSecret generates the secret containing the credentials for the nutanix prism central and is used by the EKS-A controller. The secret is named nutanix-credentials.

type Validator

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

Validator is a client to validate nutanix resources.

func NewValidator

func NewValidator(clientCache *ClientCache, certValidator crypto.TlsValidator, httpClient *http.Client) *Validator

NewValidator returns a new validator client.

func (*Validator) ValidateClusterSpec added in v0.15.0

func (v *Validator) ValidateClusterSpec(ctx context.Context, spec *cluster.Spec, creds credentials.BasicAuthCredential) error

ValidateClusterSpec validates the cluster spec.

func (*Validator) ValidateDatacenterConfig added in v0.13.0

func (v *Validator) ValidateDatacenterConfig(ctx context.Context, client Client, config *anywherev1.NutanixDatacenterConfig) error

ValidateDatacenterConfig validates the datacenter config.

func (*Validator) ValidateMachineConfig

func (v *Validator) ValidateMachineConfig(ctx context.Context, client Client, config *anywherev1.NutanixMachineConfig) error

ValidateMachineConfig validates the Prism Element cluster, subnet, and image for the machine.

type Workers added in v0.15.0

Workers represents the nutanix specific CAPI spec for worker nodes.

func WorkersSpec added in v0.15.0

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

WorkersSpec generates a nutanix 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
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