yandex

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegion

func GetRegion(zoneName string) (string, error)

GetRegion returns region of the provided zone.

func MapNodeNameToInstanceName

func MapNodeNameToInstanceName(nodeName types.NodeName) string

MapNodeNameToInstanceName maps a k8s Node Name to a Yandex.Cloud Instance Name Currently - this is a simple string cast.

func ParseProviderID

func ParseProviderID(providerID string) (folderID string, zone string, instanceName string, err error)

ParseProviderID splits a providerID into Folder ID, Zone and Instance Name.

Types

type Cloud

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

Cloud is an implementation of cloudprovider.Interface for Yandex.Cloud

func NewCloud

func NewCloud(config *CloudConfig, api CloudAPI) *Cloud

NewCloud creates a new instance of Cloud object

func (*Cloud) AddSSHKeyToAllInstances

func (yc *Cloud) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error

AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances.

func (*Cloud) Clusters

func (yc *Cloud) Clusters() (cloudprovider.Clusters, bool)

Clusters returns a clusters interface if supported.

func (*Cloud) CurrentNodeName

func (yc *Cloud) CurrentNodeName(ctx context.Context, hostName string) (types.NodeName, error)

CurrentNodeName returns the name of the node we are currently running on

func (*Cloud) GetZone

func (yc *Cloud) GetZone(ctx context.Context) (cloudprovider.Zone, error)

GetZone returns the Zone containing the current zone and locality region for the node we are currently running on.

func (*Cloud) GetZoneByNodeName

func (yc *Cloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName) (cloudprovider.Zone, error)

GetZoneByNodeName returns the Zone containing the current zone and locality region of the node specified by node name.

func (*Cloud) GetZoneByProviderID

func (yc *Cloud) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error)

GetZoneByProviderID returns the Zone containing the current zone and locality region of the node specified by providerID

func (*Cloud) HasClusterID

func (yc *Cloud) HasClusterID() bool

HasClusterID returns true if the cluster has a clusterID

func (*Cloud) Initialize

func (yc *Cloud) Initialize(clientBuilder controller.ControllerClientBuilder)

Initialize passes a Kubernetes clientBuilder interface to the cloud provider

func (*Cloud) InstanceExistsByProviderID

func (yc *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error)

InstanceExistsByProviderID returns true if the instance with the given providerID still exists. If false is returned with no error, the instance will be immediately deleted by the cloud controller manager.

func (*Cloud) InstanceID

func (yc *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string, error)

InstanceID returns the cloud provider ID of the node with the specified nodeName.

func (*Cloud) InstanceShutdownByProviderID

func (yc *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)

InstanceShutdownByProviderID returns true if the instance is in safe state to detach volumes

func (*Cloud) InstanceType

func (yc *Cloud) InstanceType(ctx context.Context, nodeName types.NodeName) (string, error)

InstanceType returns the type of the node with the specified nodeName. Currently "" is always returned, since Yandex.Cloud API does not provide any information about instance type.

func (*Cloud) InstanceTypeByProviderID

func (yc *Cloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error)

InstanceTypeByProviderID returns the type of the node with the specified unique providerD. Currently "" is always returned, since Yandex.Cloud API does not provide any information about instance type.

func (*Cloud) Instances

func (yc *Cloud) Instances() (cloudprovider.Instances, bool)

Instances returns an instances interface if supported.

func (*Cloud) LoadBalancer

func (yc *Cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool)

LoadBalancer returns a balancer interface if supported.

func (*Cloud) NodeAddresses

func (yc *Cloud) NodeAddresses(ctx context.Context, nodeName types.NodeName) ([]v1.NodeAddress, error)

NodeAddresses returns the addresses of the node specified by node name.

func (*Cloud) NodeAddressesByProviderID

func (yc *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error)

NodeAddressesByProviderID returns the addresses of the node specified by providerID

func (*Cloud) ProviderName

func (yc *Cloud) ProviderName() string

ProviderName returns the cloud provider ID.

func (*Cloud) Routes

func (yc *Cloud) Routes() (cloudprovider.Routes, bool)

Routes returns a routes interface if supported

func (*Cloud) Zones

func (yc *Cloud) Zones() (cloudprovider.Zones, bool)

Zones returns a zones interface if supported.

type CloudAPI

type CloudAPI interface {
	// FindInstanceByFolderAndName searches for Instance with the specified folderID and instanceName.
	// If nothing found - no error must be returned.
	FindInstanceByFolderAndName(ctx context.Context, folderID string, instanceName string) (*compute.Instance, error)
}

CloudAPI is an abstraction over Yandex.Cloud SDK, to allow mocking/unit testing

func NewCloudAPI

func NewCloudAPI(config *CloudConfig) (CloudAPI, error)

NewCloudAPI creates new instance of CloudAPI object

type CloudAPIImpl

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

CloudAPIImpl is an implementation of CloudAPI

func (*CloudAPIImpl) FindInstanceByFolderAndName

func (api *CloudAPIImpl) FindInstanceByFolderAndName(ctx context.Context, folderID string, instanceName string) (*compute.Instance, error)

FindInstanceByFolderAndName searches for Instance with the specified folderID and instanceName.

type CloudConfig

type CloudConfig struct {
	FolderID   string
	LocalZone  string
	OAuthToken ycsdk.Credentials
}

CloudConfig includes all the necessary configuration for creating Cloud object

func NewCloudConfig

func NewCloudConfig() (*CloudConfig, error)

NewCloudConfig creates a new instance of CloudConfig object

type MetadataService

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

MetadataService knows how to query the Yandex.Cloud instance metadata server. See https://cloud.yandex.com/docs/compute/operations/vm-info/get-info#gce-metadata.

func NewMetadataService

func NewMetadataService() *MetadataService

NewMetadataService creates an instance of the MetadataService object using default metadata URL.

func NewMetadataServiceWithURL

func NewMetadataServiceWithURL(metadataURL string) *MetadataService

NewMetadataServiceWithURL creates an instance of the MetadataService object using specified metadata URL.

func (*MetadataService) Get

func (m *MetadataService) Get(suffix string) (string, error)

Get returns a value from the instance metadata service. The suffix is appended to "${metadataURL}/computeMetadata/v1/".

func (*MetadataService) GetFolderID

func (m *MetadataService) GetFolderID() (string, error)

GetFolderID returns the current VM's FolderID, such as "b1g4c2a3g6vkffp3qacq" Currently instance metadata service does not implement "project/project-id" element, so we using "instance/zone" to extract FolderID information

func (*MetadataService) GetZone

func (m *MetadataService) GetZone() (string, error)

GetZone returns the current VM's Zone, such as "ru-central1-a".

Jump to

Keyboard shortcuts

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