Documentation ¶
Index ¶
- Constants
- func ExtractProject(credentialsData map[string][]byte) (string, error)
- func WaitUntilOperationCompleted(computeService *compute.Service, project, zone, operationName string) error
- type MachinePlugin
- func (ms *MachinePlugin) CreateMachine(ctx context.Context, req *driver.CreateMachineRequest) (*driver.CreateMachineResponse, error)
- func (ms *MachinePlugin) CreateMachineUtil(ctx context.Context, machineName string, providerSpec *api.GCPProviderSpec, ...) (string, error)
- func (ms *MachinePlugin) DeleteMachine(ctx context.Context, req *driver.DeleteMachineRequest) (*driver.DeleteMachineResponse, error)
- func (ms *MachinePlugin) DeleteMachineUtil(ctx context.Context, machineName string, _ string, ...) (string, error)
- func (ms *MachinePlugin) GetMachineStatus(ctx context.Context, req *driver.GetMachineStatusRequest) (*driver.GetMachineStatusResponse, error)
- func (ms *MachinePlugin) GetMachineStatusUtil(ctx context.Context, machineName string, _ string, ...) (string, error)
- func (ms *MachinePlugin) GetVolumeIDs(ctx context.Context, req *driver.GetVolumeIDsRequest) (*driver.GetVolumeIDsResponse, error)
- func (ms *MachinePlugin) ListMachines(ctx context.Context, req *driver.ListMachinesRequest) (*driver.ListMachinesResponse, error)
- func (ms *MachinePlugin) ListMachinesUtil(ctx context.Context, providerSpec *api.GCPProviderSpec, secret *corev1.Secret) (map[string]string, error)
- type PluginSPI
- type PluginSPIImpl
Constants ¶
const ( // GCPProviderPrefix is the prefix used by the GCP provider GCPProviderPrefix = "gce://" // GCPMachineClassKind for GCPMachineClass GCPMachineClassKind = "GCPMachineClass" // MachineClassKind for MachineClass MachineClassKind = "MachineClass" )
const (
// ProviderGCP string const to identify GCP provider
ProviderGCP = "GCP"
)
Variables ¶
This section is empty.
Functions ¶
func ExtractProject ¶ added in v0.8.0
ExtractProject returns the name of the project which is extracted from the secret
func WaitUntilOperationCompleted ¶ added in v0.8.0
func WaitUntilOperationCompleted(computeService *compute.Service, project, zone, operationName string) error
WaitUntilOperationCompleted waits for the specified operation to be completed and returns true if it does else returns false
Types ¶
type MachinePlugin ¶
type MachinePlugin struct {
SPI PluginSPI
}
MachinePlugin implements the driver.Driver It also implements the PluginSPI interface
func NewGCPPlugin ¶
func NewGCPPlugin(pluginSPI PluginSPI) *MachinePlugin
NewGCPPlugin returns a new Gcp plugin
func (*MachinePlugin) CreateMachine ¶
func (ms *MachinePlugin) CreateMachine(ctx context.Context, req *driver.CreateMachineRequest) (*driver.CreateMachineResponse, error)
CreateMachine handles a machine creation request REQUIRED METHOD
REQUEST PARAMETERS (driver.CreateMachineRequest) MachineName string Contains the name of the machine object for whom an VM is to be created at the provider ProviderSpec bytes(blob) Template/Configuration of the machine to be created is given by at the provider Secrets map<string,bytes> (Optional) Contains a map from string to string contains any cloud specific secrets that can be used by the provider LastKnownState bytes(blob) (Optional) Last known state of VM during last operation. Could be helpful to continue operation from previous state
RESPONSE PARAMETERS (driver.CreateMachineResponse) ProviderID string Unique identification of the VM at the cloud provider. This could be the same/different from req.MachineName.
ProviderID typically matches with the node.Spec.ProviderID on the node object. Eg: gce://project-name/region/vm-ProviderID
NodeName string Returns the name of the node-object that the VM register's with Kubernetes.
This could be different from req.MachineName as well
LastKnownState bytes(blob) (Optional) Last known state of VM during the current operation.
Could be helpful to continue operations in future requests.
OPTIONAL IMPLEMENTATION LOGIC It is optionally expected by the safety controller to use an identification mechanisms to map the VM Created by a providerSpec. These could be done using tag(s)/resource-groups etc. This logic is used by safety controller to delete orphan VMs which are not backed by any machine CRD
func (*MachinePlugin) CreateMachineUtil ¶
func (ms *MachinePlugin) CreateMachineUtil(ctx context.Context, machineName string, providerSpec *api.GCPProviderSpec, secret *corev1.Secret) (string, error)
CreateMachineUtil method is used to create a GCP machine
func (*MachinePlugin) DeleteMachine ¶
func (ms *MachinePlugin) DeleteMachine(ctx context.Context, req *driver.DeleteMachineRequest) (*driver.DeleteMachineResponse, error)
DeleteMachine handles a machine deletion request
REQUEST PARAMETERS (driver.DeleteMachineRequest) MachineName string Contains the name of the machine object for the backing VM(s) have to be deleted ProviderID string Contains the unique identification of the VM at the cloud provider ProviderSpec bytes(blob) Template/Configuration of the machine to be deleted is given by at the provider Secrets map<string,bytes> (Optional) Contains a map from string to string contains any cloud specific secrets that can be used by the provider LastKnownState bytes(blob) (Optional) Last known state of VM during last operation. Could be helpful to continue operation from previous state
RESPONSE PARAMETERS (driver.DeleteMachineResponse) LastKnownState bytes(blob) (Optional) Last known state of VM during the current operation.
Could be helpful to continue operations in future requests.
func (*MachinePlugin) DeleteMachineUtil ¶
func (ms *MachinePlugin) DeleteMachineUtil(ctx context.Context, machineName string, _ string, providerSpec *api.GCPProviderSpec, secret *corev1.Secret) (string, error)
DeleteMachineUtil deletes a VM by name
func (*MachinePlugin) GetMachineStatus ¶
func (ms *MachinePlugin) GetMachineStatus(ctx context.Context, req *driver.GetMachineStatusRequest) (*driver.GetMachineStatusResponse, error)
GetMachineStatus handles a machine get status request OPTIONAL METHOD
REQUEST PARAMETERS (driver.GetMachineStatusRequest) MachineName string Contains the name of the machine object for whose status is to be retrived ProviderID string Contains the unique identification of the VM at the cloud provider ProviderSpec bytes(blob) Template/Configuration of the machine whose status is to be retrived Secrets map<string,bytes> (Optional) Contains a map from string to string contains any cloud specific secrets that can be used by the provider
RESPONSE PARAMETERS (driver.GetMachineStatueResponse) ProviderID string Unique identification of the VM at the cloud provider. This could be the same/different from req.MachineName.
ProviderID typically matches with the node.Spec.ProviderID on the node object. Eg: gce://project-name/region/vm-ProviderID
NodeName string Returns the name of the node-object that the VM register's with Kubernetes.
This could be different from req.MachineName as well
func (*MachinePlugin) GetMachineStatusUtil ¶
func (ms *MachinePlugin) GetMachineStatusUtil(ctx context.Context, machineName string, _ string, providerSpec *api.GCPProviderSpec, secret *corev1.Secret) (string, error)
GetMachineStatusUtil checks for existence of VM by name
func (*MachinePlugin) GetVolumeIDs ¶
func (ms *MachinePlugin) GetVolumeIDs(ctx context.Context, req *driver.GetVolumeIDsRequest) (*driver.GetVolumeIDsResponse, error)
GetVolumeIDs returns a list of Volume IDs for all PV Specs for whom an provider volume was found
REQUEST PARAMETERS (driver.GetVolumeIDsRequest) PVSpecList bytes(blob) PVSpecsList is a list PV specs for whom volume-IDs are required. Plugin should parse this raw data into pre-defined list of PVSpecs.
RESPONSE PARAMETERS (driver.GetVolumeIDsResponse) VolumeIDs repeated string VolumeIDs is a repeated list of VolumeIDs.
func (*MachinePlugin) ListMachines ¶
func (ms *MachinePlugin) ListMachines(ctx context.Context, req *driver.ListMachinesRequest) (*driver.ListMachinesResponse, error)
ListMachines lists all the machines possibilly created by a providerSpec Identifying machines created by a given providerSpec depends on the OPTIONAL IMPLEMENTATION LOGIC you have used to identify machines created by a providerSpec. It could be tags/resource-groups etc OPTIONAL METHOD
REQUEST PARAMETERS (driver.ListMachinesRequest) ProviderSpec bytes(blob) Template/Configuration of the machine that wouldn've been created by this ProviderSpec (Machine Class) Secrets map<string,bytes> (Optional) Contains a map from string to string contains any cloud specific secrets that can be used by the provider
RESPONSE PARAMETERS (driver.ListMachinesResponse) MachineList map<string,string> A map containing the keys as the MachineID and value as the MachineName
for all machine's who where possibilly created by this ProviderSpec
func (*MachinePlugin) ListMachinesUtil ¶
func (ms *MachinePlugin) ListMachinesUtil(ctx context.Context, providerSpec *api.GCPProviderSpec, secret *corev1.Secret) (map[string]string, error)
ListMachinesUtil lists all VMs in the DC or folder
type PluginSPI ¶
type PluginSPI interface {
NewComputeService(secrets *corev1.Secret) (context.Context, *compute.Service, error)
}
PluginSPI provides an interface to deal with cloud provider session You can optionally enhance this interface to add interface methods here You can use it to mock cloud provider calls
type PluginSPIImpl ¶
type PluginSPIImpl struct{}
PluginSPIImpl is the real implementation of PluginSPI interface that makes the calls to the provider SDK
func (*PluginSPIImpl) NewComputeService ¶
func (spi *PluginSPIImpl) NewComputeService(secret *corev1.Secret) (context.Context, *compute.Service, error)
NewComputeService returns an instance of the compute service