powervs

package
v1.14.16-dcf8320c8c4e Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 38 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegion

func GetRegion(defaultRegion string) (string, error)

GetRegion prompts the user to select a region and returns that region.

func GetZone

func GetZone(region string, defaultZone string) (string, error)

GetZone prompts the user for a zone given a zone.

func IsKnownRegion

func IsKnownRegion(region string) bool

IsKnownRegion return true is a specified region is Known to the installer.

func IsKnownZone

func IsKnownZone(region string, zone string) bool

IsKnownZone return true is a specified zone is Known to the installer.

func Platform

func Platform() (*powervs.Platform, error)

Platform collects powervs-specific configuration.

func Validate

func Validate(config *types.InstallConfig) error

Validate executes platform specific validation/

func ValidateCustomVPCSetup

func ValidateCustomVPCSetup(client API, ic *types.InstallConfig) error

ValidateCustomVPCSetup ensures optional VPC settings, if specified, are all legit.

func ValidatePERAvailability added in v0.9.153

func ValidatePERAvailability(client API, ic *types.InstallConfig) error

ValidatePERAvailability ensures the target datacenter has PER enabled.

func ValidatePreExistingDNS

func ValidatePreExistingDNS(client API, ic *types.InstallConfig, metadata MetadataAPI) error

ValidatePreExistingDNS ensures no pre-existing DNS record exists in the CIS DNS zone or IBM DNS zone for cluster's Kubernetes API.

func ValidateResourceGroup

func ValidateResourceGroup(client API, ic *types.InstallConfig) error

ValidateResourceGroup validates the resource group in our install config.

func ValidateServiceInstance

func ValidateServiceInstance(client API, ic *types.InstallConfig) error

ValidateServiceInstance validates the optional service instance GUID in our install config.

func ValidateSystemTypeForRegion added in v0.9.153

func ValidateSystemTypeForRegion(client API, ic *types.InstallConfig) error

ValidateSystemTypeForRegion checks if the specified sysType is available in the target region.

Types

type API

type API interface {
	// DNS
	GetDNSRecordsByName(ctx context.Context, crnstr string, zoneID string, recordName string, publish types.PublishingStrategy) ([]DNSRecordResponse, error)
	GetDNSZoneIDByName(ctx context.Context, name string, publish types.PublishingStrategy) (string, error)
	GetDNSZones(ctx context.Context, publish types.PublishingStrategy) ([]DNSZoneResponse, error)
	GetDNSInstancePermittedNetworks(ctx context.Context, dnsID string, dnsZone string) ([]string, error)
	GetDNSCustomResolverIP(ctx context.Context, dnsID string, vpcID string) (string, error)
	CreateDNSCustomResolver(ctx context.Context, name string, dnsID string, vpcID string) (*dnssvcsv1.CustomResolver, error)
	EnableDNSCustomResolver(ctx context.Context, dnsID string, resolverID string) (*dnssvcsv1.CustomResolver, error)
	CreateDNSRecord(ctx context.Context, publish types.PublishingStrategy, crnstr string, baseDomain string, hostname string, cname string) error
	AddVPCToPermittedNetworks(ctx context.Context, vpcCRN string, dnsID string, dnsZone string) error

	// VPC
	GetVPCByName(ctx context.Context, vpcName string) (*vpcv1.VPC, error)
	GetPublicGatewayByVPC(ctx context.Context, vpcName string) (*vpcv1.PublicGateway, error)
	SetVPCServiceURLForRegion(ctx context.Context, region string) error
	GetVPCs(ctx context.Context, region string) ([]vpcv1.VPC, error)
	GetVPCSubnets(ctx context.Context, vpcID string) ([]vpcv1.Subnet, error)

	// TG
	GetTGConnectionVPC(ctx context.Context, gatewayID string, vpcSubnetID string) (string, error)
	GetAttachedTransitGateway(ctx context.Context, svcInsID string) (string, error)

	// Data Center
	GetDatacenterCapabilities(ctx context.Context, region string) (map[string]bool, error)

	// API
	GetAuthenticatorAPIKeyDetails(ctx context.Context) (*iamidentityv1.APIKey, error)
	GetAPIKey() string

	// Subnet
	GetSubnetByName(ctx context.Context, subnetName string, region string) (*vpcv1.Subnet, error)

	// Resource Groups
	ListResourceGroups(ctx context.Context) (*resourcemanagerv2.ResourceGroupList, error)

	// Service Instance
	ListServiceInstances(ctx context.Context) ([]string, error)
	ServiceInstanceGUIDToName(ctx context.Context, id string) (string, error)
	ServiceInstanceNameToGUID(ctx context.Context, name string) (string, error)

	// Security Group
	ListSecurityGroupRules(ctx context.Context, securityGroupID string) (*vpcv1.SecurityGroupRuleCollection, error)
	AddSecurityGroupRule(ctx context.Context, securityGroupID string, rule *vpcv1.SecurityGroupRulePrototype) error

	// SSH
	CreateSSHKey(ctx context.Context, serviceInstance string, zone string, sshKeyName string, sshKey string) error

	// Load Balancer
	AddIPToLoadBalancerPool(ctx context.Context, lbID string, poolName string, port int64, ip string) error
}

API represents the calls made to the API.

type BxClient

type BxClient struct {
	APIKey               string
	Region               string
	Zone                 string
	PISession            *ibmpisession.IBMPISession
	User                 *User
	PowerVSResourceGroup string
}

BxClient is struct which provides bluemix session details

func NewBxClient

func NewBxClient(survey bool) (*BxClient, error)

NewBxClient func returns bluemix client

func (*BxClient) FilterServiceEndpoints added in v0.90.17

func (c *BxClient) FilterServiceEndpoints(cfg *powervs.Metadata) []string

FilterServiceEndpoints drops service endpoint overrides that are not supported by PowerVS CAPI provider.

func (*BxClient) GetBxClientAPIKey

func (c *BxClient) GetBxClientAPIKey() string

GetBxClientAPIKey returns the API key used by the Blue Mix Client.

func (*BxClient) NewPISession

func (c *BxClient) NewPISession() error

NewPISession updates pisession details, return error on fail.

type Client

type Client struct {
	APIKey string
	BXCli  *BxClient
	// contains filtered or unexported fields
}

Client makes calls to the PowerVS API.

func NewClient

func NewClient() (*Client, error)

NewClient initializes a client with a session.

func (*Client) AddIPToLoadBalancerPool added in v0.90.0

func (c *Client) AddIPToLoadBalancerPool(ctx context.Context, lbID string, poolName string, port int64, ip string) error

AddIPToLoadBalancerPool adds a server to a load balancer pool for the specified port. @TODO Remove once https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/1679 is fixed.

func (*Client) AddSecurityGroupRule added in v0.90.0

func (c *Client) AddSecurityGroupRule(ctx context.Context, securityGroupID string, rule *vpcv1.SecurityGroupRulePrototype) error

AddSecurityGroupRule adds a security group rule to an existing security group.

func (*Client) AddVPCToPermittedNetworks added in v0.90.17

func (c *Client) AddVPCToPermittedNetworks(ctx context.Context, vpcCRN string, dnsID string, dnsZone string) error

AddVPCToPermittedNetworks adds the specified VPC to the specified DNS zone.

func (*Client) CreateDNSCustomResolver added in v0.90.17

func (c *Client) CreateDNSCustomResolver(ctx context.Context, name string, dnsID string, vpcID string) (*dnssvcsv1.CustomResolver, error)

CreateDNSCustomResolver creates a custom resolver associated with the specified VPC in the specified DNS zone.

func (*Client) CreateDNSRecord added in v0.90.0

func (c *Client) CreateDNSRecord(ctx context.Context, publish types.PublishingStrategy, crnstr string, baseDomain string, hostname string, cname string) error

CreateDNSRecord Creates a DNS CNAME record in the given base domain and CRN.

func (*Client) CreateSSHKey added in v0.90.0

func (c *Client) CreateSSHKey(ctx context.Context, serviceInstance string, zone string, sshKeyName string, sshKey string) error

CreateSSHKey creates a SSH key in the PowerVS Workspace for the workers to use.

func (*Client) EnableDNSCustomResolver added in v0.90.17

func (c *Client) EnableDNSCustomResolver(ctx context.Context, dnsID string, resolverID string) (*dnssvcsv1.CustomResolver, error)

EnableDNSCustomResolver enables a specified custom resolver.

func (*Client) GetAPIKey

func (c *Client) GetAPIKey() string

GetAPIKey returns the PowerVS API key

func (*Client) GetAttachedTransitGateway added in v0.9.153

func (c *Client) GetAttachedTransitGateway(ctx context.Context, svcInsID string) (string, error)

GetAttachedTransitGateway finds an existing Transit Gateway attached to the provided PowerVS cloud instance.

func (*Client) GetAuthenticatorAPIKeyDetails

func (c *Client) GetAuthenticatorAPIKeyDetails(ctx context.Context) (*iamidentityv1.APIKey, error)

GetAuthenticatorAPIKeyDetails gets detailed information on the API key used for authentication to the IBM Cloud APIs.

func (*Client) GetDNSCustomResolverIP added in v0.90.0

func (c *Client) GetDNSCustomResolverIP(ctx context.Context, dnsID string, vpcID string) (string, error)

GetDNSCustomResolverIP gets the DNS Server IP of a custom resolver associated with the specified VPC subnet in the specified DNS zone.

func (*Client) GetDNSInstancePermittedNetworks

func (c *Client) GetDNSInstancePermittedNetworks(ctx context.Context, dnsID string, dnsZone string) ([]string, error)

GetDNSInstancePermittedNetworks gets the permitted VPC networks for a DNS Services instance.

func (*Client) GetDNSRecordsByName

func (c *Client) GetDNSRecordsByName(ctx context.Context, crnstr string, zoneID string, recordName string, publish types.PublishingStrategy) ([]DNSRecordResponse, error)

GetDNSRecordsByName gets DNS records in specific Cloud Internet Services instance by its CRN, zone ID, and DNS record name.

func (*Client) GetDNSZoneIDByName

func (c *Client) GetDNSZoneIDByName(ctx context.Context, name string, publish types.PublishingStrategy) (string, error)

GetDNSZoneIDByName gets the CIS zone ID from its domain name.

func (*Client) GetDNSZones

func (c *Client) GetDNSZones(ctx context.Context, publish types.PublishingStrategy) ([]DNSZoneResponse, error)

GetDNSZones returns all of the active DNS zones managed by CIS.

func (*Client) GetDatacenterCapabilities added in v0.9.153

func (c *Client) GetDatacenterCapabilities(ctx context.Context, region string) (map[string]bool, error)

GetDatacenterCapabilities retrieves the capabilities of the specified datacenter.

func (*Client) GetInstanceCRNByName

func (c *Client) GetInstanceCRNByName(ctx context.Context, name string, publish types.PublishingStrategy) (string, error)

GetInstanceCRNByName finds the CRN of the instance with the specified name.

func (*Client) GetPublicGatewayByVPC

func (c *Client) GetPublicGatewayByVPC(ctx context.Context, vpcName string) (*vpcv1.PublicGateway, error)

GetPublicGatewayByVPC gets all PublicGateways in a region

func (*Client) GetSubnetByName

func (c *Client) GetSubnetByName(ctx context.Context, subnetName string, region string) (*vpcv1.Subnet, error)

GetSubnetByName gets a VPC Subnet by its name and region.

func (*Client) GetTGConnectionVPC added in v0.9.153

func (c *Client) GetTGConnectionVPC(ctx context.Context, gatewayID string, vpcSubnetID string) (string, error)

GetTGConnectionVPC checks if the VPC subnet is attached to the provided Transit Gateway.

func (*Client) GetVPCByName

func (c *Client) GetVPCByName(ctx context.Context, vpcName string) (*vpcv1.VPC, error)

GetVPCByName gets a VPC by its name.

func (*Client) GetVPCSubnets added in v0.90.0

func (c *Client) GetVPCSubnets(ctx context.Context, vpcID string) ([]vpcv1.Subnet, error)

GetVPCSubnets retrieves all subnets in the given VPC.

func (*Client) GetVPCs

func (c *Client) GetVPCs(ctx context.Context, region string) ([]vpcv1.VPC, error)

GetVPCs gets all VPCs in a region.

func (*Client) ListResourceGroups

func (c *Client) ListResourceGroups(ctx context.Context) (*resourcemanagerv2.ResourceGroupList, error)

ListResourceGroups returns a list of resource groups.

func (*Client) ListSecurityGroupRules added in v0.90.0

func (c *Client) ListSecurityGroupRules(ctx context.Context, securityGroupID string) (*vpcv1.SecurityGroupRuleCollection, error)

ListSecurityGroupRules returns a list of the security group rules.

func (*Client) ListServiceInstances

func (c *Client) ListServiceInstances(ctx context.Context) ([]string, error)

ListServiceInstances lists all service instances in the cloud.

func (*Client) ServiceInstanceGUIDToName added in v0.9.153

func (c *Client) ServiceInstanceGUIDToName(ctx context.Context, id string) (string, error)

ServiceInstanceGUIDToName returns the name of the matching service instance GUID which was passed in.

func (*Client) ServiceInstanceNameToGUID added in v0.90.0

func (c *Client) ServiceInstanceNameToGUID(ctx context.Context, name string) (string, error)

ServiceInstanceNameToGUID returns the name of the matching service instance GUID which was passed in.

func (*Client) SetVPCServiceURLForRegion

func (c *Client) SetVPCServiceURLForRegion(ctx context.Context, region string) error

SetVPCServiceURLForRegion will set the VPC Service URL to a specific IBM Cloud Region, in order to access Region scoped resources

type DNSRecordResponse

type DNSRecordResponse struct {
	Name string
	Type string
}

DNSRecordResponse represents a DNS record response.

type DNSZoneResponse

type DNSZoneResponse struct {
	// Name is the domain name of the zone.
	Name string

	// ID is the zone's ID.
	ID string

	// CISInstanceCRN is the IBM Cloud Resource Name for the CIS instance where
	// the DNS zone is managed.
	InstanceCRN string

	// CISInstanceName is the display name of the CIS instance where the DNS zone
	// is managed.
	InstanceName string

	// ResourceGroupID is the resource group ID of the CIS instance.
	ResourceGroupID string
}

DNSZoneResponse represents a DNS zone response.

type Metadata

type Metadata struct {
	BaseDomain      string
	PublishStrategy types.PublishingStrategy
	// contains filtered or unexported fields
}

Metadata holds additional metadata for InstallConfig resources that do not need to be user-supplied (e.g. because it can be retrieved from external APIs).

func NewMetadata

func NewMetadata(config *types.InstallConfig) *Metadata

NewMetadata initializes a new Metadata object.

func (*Metadata) APIKey

func (m *Metadata) APIKey(ctx context.Context) (string, error)

APIKey returns the IBM Cloud account API Key associated with the authentication credentials.

func (*Metadata) AccountID

func (m *Metadata) AccountID(ctx context.Context) (string, error)

AccountID returns the IBM Cloud account ID associated with the authentication credentials.

func (*Metadata) AddSecurityGroupRule added in v0.90.0

func (m *Metadata) AddSecurityGroupRule(ctx context.Context, rule *vpcv1.SecurityGroupRulePrototype, vpcID string) error

AddSecurityGroupRule adds a security group rule to the specified VPC.

func (*Metadata) CISInstanceCRN

func (m *Metadata) CISInstanceCRN(ctx context.Context) (string, error)

CISInstanceCRN returns the Cloud Internet Services instance CRN that is managing the DNS zone for the base domain.

func (*Metadata) CreateDNSRecord added in v0.90.0

func (m *Metadata) CreateDNSRecord(ctx context.Context, hostname string, destHostname string) error

CreateDNSRecord creates a CNAME record for the specified hostname and destination hostname.

func (*Metadata) DNSInstanceCRN

func (m *Metadata) DNSInstanceCRN(ctx context.Context) (string, error)

DNSInstanceCRN returns the IBM DNS Service instance CRN that is managing the DNS zone for the base domain.

func (*Metadata) EnsureVPCIsPermittedNetwork added in v0.90.17

func (m *Metadata) EnsureVPCIsPermittedNetwork(ctx context.Context, vpcName string) error

EnsureVPCIsPermittedNetwork checks if a VPC is permitted to the DNS zone and adds it if it is not.

func (*Metadata) GetDNSServerIP added in v0.90.0

func (m *Metadata) GetDNSServerIP(ctx context.Context, vpcName string) (string, error)

GetDNSServerIP gets the IP of a custom resolver for DNS use.

func (*Metadata) GetExistingVPCGateway

func (m *Metadata) GetExistingVPCGateway(ctx context.Context, vpcName string, vpcSubnet string) (string, bool, error)

GetExistingVPCGateway checks if the VPC is a Permitted Network for the DNS Zone

func (*Metadata) GetSubnetID added in v0.90.0

func (m *Metadata) GetSubnetID(ctx context.Context, subnetName string, vpcRegion string) (string, error)

GetSubnetID gets the ID of a VPC subnet by name and region.

func (*Metadata) GetVPCSubnets added in v0.90.0

func (m *Metadata) GetVPCSubnets(ctx context.Context, vpcName string) ([]vpcv1.Subnet, error)

GetVPCSubnets gets a list of subnets in a VPC.

func (*Metadata) IsVPCPermittedNetwork

func (m *Metadata) IsVPCPermittedNetwork(ctx context.Context, vpcName string, baseDomain string) (bool, error)

IsVPCPermittedNetwork checks if the VPC is a Permitted Network for the DNS Zone

func (*Metadata) ListSecurityGroupRules added in v0.90.0

func (m *Metadata) ListSecurityGroupRules(ctx context.Context, vpcID string) (*vpcv1.SecurityGroupRuleCollection, error)

ListSecurityGroupRules lists the rules created in the specified VPC.

func (*Metadata) SetCISInstanceCRN

func (m *Metadata) SetCISInstanceCRN(crn string)

SetCISInstanceCRN sets Cloud Internet Services instance CRN to a string value.

func (*Metadata) SetDNSInstanceCRN

func (m *Metadata) SetDNSInstanceCRN(crn string)

SetDNSInstanceCRN sets IBM DNS Service instance CRN to a string value.

func (*Metadata) SetVPCServiceURLForRegion added in v0.90.0

func (m *Metadata) SetVPCServiceURLForRegion(ctx context.Context, vpcRegion string) error

SetVPCServiceURLForRegion sets the URL for the VPC based on the specified region.

type MetadataAPI

type MetadataAPI interface {
	AccountID(ctx context.Context) (string, error)
	APIKey(ctx context.Context) (string, error)
	CISInstanceCRN(ctx context.Context) (string, error)
	DNSInstanceCRN(ctx context.Context) (string, error)
}

MetadataAPI represents functions that eventually call out to the API

type SessionStore

type SessionStore struct {
	ID                   string `json:"id,omitempty"`
	APIKey               string `json:"apikey,omitempty"`
	DefaultRegion        string `json:"region,omitempty"`
	DefaultZone          string `json:"zone,omitempty"`
	PowerVSResourceGroup string `json:"resourcegroup,omitempty"`
}

SessionStore is an object and store that holds credentials and variables required to create a SessionVars object.

type SessionVars

type SessionVars struct {
	ID                   string
	APIKey               string
	Region               string
	Zone                 string
	PowerVSResourceGroup string
}

SessionVars is an object that holds the variables required to create an ibmpisession object.

type User

type User struct {
	ID      string
	Email   string
	Account string
}

User is struct with user details

func FetchUserDetails added in v0.9.153

func FetchUserDetails(apikey string) (*User, error)

FetchUserDetails returns User details from the given API key.

type Zone

type Zone struct {
	Name            string
	InstanceCRN     string
	ResourceGroupID string
	Publish         types.PublishingStrategy
}

Zone represents a DNS Zone

func GetDNSZone

func GetDNSZone() (*Zone, error)

GetDNSZone returns a DNS Zone chosen by survey.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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