ibmcloud

package
v1.5.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 39 Imported by: 4

Documentation

Index

Constants

View Source
const (

	// BootstrapSGNameSuffix is the suffix value to append for the bootstrap VPC Security Group name.
	BootstrapSGNameSuffix = "security-group-bootstrap"

	// KubernetesAPIPort is the Kubernetes API port.
	KubernetesAPIPort = 6443

	// KubernetesAPIPrivateSuffix is the name suffix for Kubernetes API Private LB resources.
	KubernetesAPIPrivateSuffix = "kubernetes-api-private"

	// KubernetesAPIPublicSuffix is the name suffix for Kubernetes API Public LB resources.
	KubernetesAPIPublicSuffix = "kubernetes-api-public"

	// MachineConfigServerPort is the Machine Config Server port.
	MachineConfigServerPort = 22623

	// MachineConfigSuffix is the name suffix for Machine Config Server LB resources.
	MachineConfigSuffix = "machine-config"
)
View Source
const (
	// PrivateHostPrefix is the prefix for private API traffic used for DNS Records.
	PrivateHostPrefix = "api-int."
	// PublicHostPrefix is the prefix for public API traffic used for DNS Records.
	PublicHostPrefix = "api."
)

Variables

This section is empty.

Functions

func BootstrapSecurityGroupName

func BootstrapSecurityGroupName(infraID string) string

BootstrapSecurityGroupName creates a VPC Security Group name using the provided InfraID and bootstrap SG name suffix.

func COSInstanceName

func COSInstanceName(infraID string) string

COSInstanceName creates a COS Instance name based on provided InfraID.

func CreateSubnetName

func CreateSubnetName(clusterID string, role string, zone string) (string, error)

CreateSubnetName will build a subnet name based on the clusterID, subnet role, and subnet zone.

func NewIamAuthenticator

func NewIamAuthenticator(apiKey string, iamServiceEndpointOverride string) (*core.IamAuthenticator, error)

NewIamAuthenticator returns a new IamAuthenticator for using IBM Cloud services.

func Platform

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

Platform collects IBM Cloud-specific configuration.

func VPCName

func VPCName(infraID string) string

VPCName creates a VPC name based on provided InfraID.

func VSIImageCOSBucketName

func VSIImageCOSBucketName(infraID string) string

VSIImageCOSBucketName creates a COS Bucket name for the VSI Image, based on provided InfraID.

func VSIImageName

func VSIImageName(infraID string) string

VSIImageName creates a VPC VSI Image name, based on provided InfraID.

func Validate

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

Validate executes platform-specific validation.

func ValidatePreExistingPublicDNS

func ValidatePreExistingPublicDNS(client API, ic *types.InstallConfig, metadata *Metadata) error

ValidatePreExistingPublicDNS ensure no pre-existing DNS record exists in the CIS DNS zone for cluster's Kubernetes API.

func ValidateServiceEndpoints

func ValidateServiceEndpoints(ic *types.InstallConfig) error

ValidateServiceEndpoints will validate a series of service endpoint overrides.

Types

type API

type API interface {
	AttachFloatingIP(ctx context.Context, instanceName string, instanceID string, region string, resourceGroupName string) (*vpcv1.FloatingIP, error)
	CreateCOSBucket(ctx context.Context, cosInstanceID string, bucketName string, region string) error
	CreateCOSInstance(ctx context.Context, cosName string, resourceGroupID string) (*resourcecontrollerv2.ResourceInstance, error)
	CreateCOSObject(ctx context.Context, sourceData []byte, fileName string, cosInstanceID string, bucketName string, region string) error
	CreateCISDNSRecord(ctx context.Context, cisInstanceCRN string, zoneID string, recordName string, cname string) error
	CreateDNSServicesDNSRecord(ctx context.Context, dnsInstanceID string, zoneID string, recordName string, cname string) error
	CreateDNSServicesPermittedNetwork(ctx context.Context, dnsInstanceID string, dnsZoneID string, vpcCRN string) error
	CreateIAMAuthorizationPolicy(tx context.Context, sourceServiceName string, sourceServiceResourceType string, targetServiceName string, targetServiceInstanceID string, roles []string) error
	CreateResourceGroup(ctx context.Context, rgName string) error
	DeleteCOSBucket(ctx context.Context, cosInstanceID string, bucketName string, region string) error
	DeleteCOSInstance(ctx context.Context, cosInstanceID string) error
	DeleteCOSObject(ctx context.Context, cosInstanceID string, bucketName string, objectKey string, region string) error
	DeleteFloatingIP(ctx context.Context, floatingIPID string, region string) error
	DeleteSecurityGroup(ctx context.Context, securityGroupID string, region string) error
	DeleteSecurityGroupTargetBinding(ctx context.Context, securityGroupID string, targetID string, region string) error
	GetAPIKey() string
	GetAuthenticatorAPIKeyDetails(ctx context.Context) (*iamidentityv1.APIKey, error)
	GetCISInstance(ctx context.Context, crnstr string) (*resourcecontrollerv2.ResourceInstance, error)
	GetCOSBucketByName(ctx context.Context, cosInstanceID string, bucketName string, region string) (*ibms3.Bucket, error)
	GetCOSInstanceByName(ctx context.Context, cosName string) (*resourcecontrollerv2.ResourceInstance, error)
	GetDNSInstance(ctx context.Context, crnstr string) (*resourcecontrollerv2.ResourceInstance, error)
	GetDNSInstancePermittedNetworks(ctx context.Context, dnsID string, dnsZone string) ([]string, error)
	GetDedicatedHostByName(ctx context.Context, name string, region string) (*vpcv1.DedicatedHost, error)
	GetDedicatedHostProfiles(ctx context.Context, region string) ([]vpcv1.DedicatedHostProfile, error)
	GetDNSRecordsByName(ctx context.Context, crnstr string, zoneID string, recordName string) ([]dnsrecordsv1.DnsrecordDetails, error)
	GetDNSZoneIDByName(ctx context.Context, name string, publish types.PublishingStrategy) (string, error)
	GetDNSZones(ctx context.Context, publish types.PublishingStrategy) ([]responses.DNSZoneResponse, error)
	GetEncryptionKey(ctx context.Context, keyCRN string) (*responses.EncryptionKeyResponse, error)
	GetIBMCloudRegions(ctx context.Context) (map[string]string, error)
	GetFloatingIPByName(ctx context.Context, floatingIPName string, region string) (*vpcv1.FloatingIP, error)
	GetLoadBalancer(ctx context.Context, loadBalancerID string) (*vpcv1.LoadBalancer, error)
	GetResourceGroups(ctx context.Context) ([]resourcemanagerv2.ResourceGroup, error)
	GetResourceGroup(ctx context.Context, nameOrID string) (*resourcemanagerv2.ResourceGroup, error)
	GetSecurityGroupByName(ctx context.Context, sgName string, vpcID string, region string) (*vpcv1.SecurityGroup, error)
	GetSSHKeyByPublicKey(ctx context.Context, publicKey string) (*vpcv1.Key, error)
	GetSubnet(ctx context.Context, subnetID string) (*vpcv1.Subnet, error)
	GetSubnetByName(ctx context.Context, subnetName string, region string) (*vpcv1.Subnet, error)
	GetVSI(ctx context.Context, instanceID string, region string) (*vpcv1.Instance, error)
	GetVSIProfiles(ctx context.Context) ([]vpcv1.InstanceProfile, error)
	GetVPC(ctx context.Context, vpcID string) (*vpcv1.VPC, error)
	GetVPCs(ctx context.Context, region string) ([]vpcv1.VPC, error)
	GetVPCByName(ctx context.Context, vpcName string) (*vpcv1.VPC, error)
	GetVPCZonesForRegion(ctx context.Context, region string) ([]string, error)
	ListCOSBuckets(ctx context.Context, cosInstanceID string, region string) (*ibms3.ListBucketsOutput, error)
	ListCOSObjects(ctx context.Context, cosInstanceID string, bucketName string, region string) (*ibms3.ListObjectsOutput, error)
	SetVPCServiceURLForRegion(ctx context.Context, region string) error
}

API represents the calls made to the API.

type COSResourceNotFoundError

type COSResourceNotFoundError struct{}

COSResourceNotFoundError represents an error for a COS resource that is not found.

func (*COSResourceNotFoundError) Error

func (e *COSResourceNotFoundError) Error() string

Error returns the error message for the COSResourceNotFoundError error type.

type Client

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

Client makes calls to the IBM Cloud API.

func NewClient

func NewClient(endpoints []configv1.IBMCloudServiceEndpoint) (*Client, error)

NewClient initializes a client with any provided endpoint overrides.

func (*Client) AttachFloatingIP

func (c *Client) AttachFloatingIP(ctx context.Context, instanceName string, instanceID string, region string, resourceGroupName string) (*vpcv1.FloatingIP, error)

AttachFloatingIP will create a new VPC Floating IP resource, attaching it to the provided instance's primary network interface.

func (*Client) CreateCISDNSRecord

func (c *Client) CreateCISDNSRecord(ctx context.Context, cisInstanceCRN string, zoneID string, recordName string, cname string) error

CreateCISDNSRecord creates a DNS Record in the IBM Cloud Internet Services (CIS) zone based on the provided Load Balancer.

func (*Client) CreateCOSBucket

func (c *Client) CreateCOSBucket(ctx context.Context, cosInstanceID string, bucketName string, region string) error

CreateCOSBucket will create a new COS Bucket in the COS Instance, based on the Instance ID.

func (*Client) CreateCOSInstance

func (c *Client) CreateCOSInstance(ctx context.Context, cosName string, resourceGroupID string) (*resourcecontrollerv2.ResourceInstance, error)

CreateCOSInstance will create a new COS Instance and return the ResourceInstance details.

func (*Client) CreateCOSObject

func (c *Client) CreateCOSObject(ctx context.Context, sourceData []byte, fileName string, cosInstanceID string, bucketName string, region string) error

CreateCOSObject will (upload) create a new COS object in the designated COS instance and bucket.

func (*Client) CreateDNSServicesDNSRecord

func (c *Client) CreateDNSServicesDNSRecord(ctx context.Context, dnsInstanceID string, zoneID string, recordName string, cname string) error

CreateDNSServicesDNSRecord create a DNS Record in the DNS Serivces zone, based on provided the Load Balancer.

func (*Client) CreateDNSServicesPermittedNetwork

func (c *Client) CreateDNSServicesPermittedNetwork(ctx context.Context, dnsInstanceID string, dnsZoneID string, vpcCRN string) error

CreateDNSServicesPermittedNetwork will create a new VPC Permitted Network in the specified DNS Services Instance and Zone.

func (*Client) CreateIAMAuthorizationPolicy

func (c *Client) CreateIAMAuthorizationPolicy(ctx context.Context, sourceServiceName string, sourceServiceResourceType string, targetServiceName string, targetServiceInstanceID string, roles []string) error

CreateIAMAuthorizationPolicy creates a new IAM Authorization policy for read access to VPC to a COS Instance.

func (*Client) CreateResourceGroup

func (c *Client) CreateResourceGroup(ctx context.Context, rgName string) error

CreateResourceGroup creates a new IBM Cloud Resource Group.

func (*Client) DeleteCOSBucket

func (c *Client) DeleteCOSBucket(ctx context.Context, cosInstanceID string, bucketName string, region string) error

DeleteCOSBucket deletes the specified COS Bucket within a COS Instance.

func (*Client) DeleteCOSInstance

func (c *Client) DeleteCOSInstance(ctx context.Context, cosInstanceID string) error

DeleteCOSInstance deletes the specified COS Instance by ID.

func (*Client) DeleteCOSObject

func (c *Client) DeleteCOSObject(ctx context.Context, cosInstanceID string, bucketName string, objectKey string, region string) error

DeleteCOSObject deletes the specified COS Object in the specified bucket and instance.

func (*Client) DeleteFloatingIP

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

DeleteFloatingIP deletes the specified VPC Floating IP by ID and Region. Region is required to make sure the VPC API is using the correct Region, assuming that is required.

func (*Client) DeleteSecurityGroup

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

DeleteSecurityGroup deletes the specified security group by ID and Region. Region is required to make sure the VPC API is using the correct Region, assuming that is required.

func (*Client) DeleteSecurityGroupTargetBinding

func (c *Client) DeleteSecurityGroupTargetBinding(ctx context.Context, securityGroupID string, targetID string, region string) error

DeleteSecurityGroupTargetBinding removes the specificied target resource attached to the specified security group.

func (*Client) GetAPIKey

func (c *Client) GetAPIKey() string

GetAPIKey gets the API Key.

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) GetCISInstance

func (c *Client) GetCISInstance(ctx context.Context, crnstr string) (*resourcecontrollerv2.ResourceInstance, error)

GetCISInstance gets a specific Cloud Internet Services by its CRN.

func (*Client) GetCOSBucketByName

func (c *Client) GetCOSBucketByName(ctx context.Context, cosInstanceID string, bucketName string, region string) (*ibms3.Bucket, error)

GetCOSBucketByName will get the COS Bucket that matches the name provided.

func (*Client) GetCOSInstanceByName

func (c *Client) GetCOSInstanceByName(ctx context.Context, cosName string) (*resourcecontrollerv2.ResourceInstance, error)

GetCOSInstanceByName will get the COS Instance (ResourceInstance) that matches the name provided.

func (*Client) GetChildrenFromParents

func (c *Client) GetChildrenFromParents(ctx context.Context, parentList []globalcatalogv1.CatalogEntry, kind string) ([]globalcatalogv1.CatalogEntry, error)

GetChildrenFromParents fetches the children from the IBM Catalog using the given list of parents and the specified kind.

func (*Client) GetDNSInstance

func (c *Client) GetDNSInstance(ctx context.Context, crnstr string) (*resourcecontrollerv2.ResourceInstance, error)

GetDNSInstance gets a specific DNS Services instance by its CRN.

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) ([]dnsrecordsv1.DnsrecordDetails, 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 DNS (Internal) or CIS zone ID from its domain name.

func (*Client) GetDNSZones

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

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

func (*Client) GetDedicatedHostByName

func (c *Client) GetDedicatedHostByName(ctx context.Context, name string, region string) (*vpcv1.DedicatedHost, error)

GetDedicatedHostByName gets dedicated host by name.

func (*Client) GetDedicatedHostProfiles

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

GetDedicatedHostProfiles gets a list of profiles supported in a region.

func (*Client) GetEncryptionKey

func (c *Client) GetEncryptionKey(ctx context.Context, keyCRN string) (*responses.EncryptionKeyResponse, error)

GetEncryptionKey gets data for an encryption key

func (*Client) GetFloatingIPByName

func (c *Client) GetFloatingIPByName(ctx context.Context, floatingIPName string, region string) (*vpcv1.FloatingIP, error)

GetFloatingIPByName gets a VPC Floating IP by name.

func (*Client) GetIBMCloudRegions

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

GetIBMCloudRegions gets the Regions for IBM Cloud, mapped by shortname to descriptive name.

func (*Client) GetLoadBalancer

func (c *Client) GetLoadBalancer(ctx context.Context, loadBalancerID string) (*vpcv1.LoadBalancer, error)

GetLoadBalancer gets a VPC Load Balancer by ID.

func (*Client) GetResourceGroup

func (c *Client) GetResourceGroup(ctx context.Context, nameOrID string) (*resourcemanagerv2.ResourceGroup, error)

GetResourceGroup gets a resource group by its name or ID.

func (*Client) GetResourceGroups

func (c *Client) GetResourceGroups(ctx context.Context) ([]resourcemanagerv2.ResourceGroup, error)

GetResourceGroups gets the list of resource groups.

func (*Client) GetSSHKeyByPublicKey

func (c *Client) GetSSHKeyByPublicKey(ctx context.Context, publicKey string) (*vpcv1.Key, error)

GetSSHKeyByPublicKey gets an SSH Key by its public key.

func (*Client) GetSecurityGroupByName

func (c *Client) GetSecurityGroupByName(ctx context.Context, sgName string, vpcID string, region string) (*vpcv1.SecurityGroup, error)

GetSecurityGroupByName gets a Security Group by its Name, within the specified VPC (ID) and Region.

func (*Client) GetSubnet

func (c *Client) GetSubnet(ctx context.Context, subnetID string) (*vpcv1.Subnet, error)

GetSubnet gets a subnet by its ID.

func (*Client) GetSubnetByName

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

GetSubnetByName gets a subnet by its Name.

func (*Client) GetVPC

func (c *Client) GetVPC(ctx context.Context, vpcID string) (*vpcv1.VPC, error)

GetVPC gets a VPC by its ID.

func (*Client) GetVPCByName

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

GetVPCByName gets a VPC by its name.

func (*Client) GetVPCZonesForRegion

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

GetVPCZonesForRegion gets the supported zones for a VPC region.

func (*Client) GetVPCs

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

GetVPCs gets all VPCs in a region

func (*Client) GetVSI

func (c *Client) GetVSI(ctx context.Context, instanceID string, region string) (*vpcv1.Instance, error)

GetVSI gets a VPC Virtual Service Instance with provided ID.

func (*Client) GetVSIProfiles

func (c *Client) GetVSIProfiles(ctx context.Context) ([]vpcv1.InstanceProfile, error)

GetVSIProfiles gets a list of all VSI profiles.

func (*Client) ListCOSBuckets

func (c *Client) ListCOSBuckets(ctx context.Context, cosInstanceID string, region string) (*ibms3.ListBucketsOutput, error)

ListCOSBuckets lists Buckets in the specified COS Instance.

func (*Client) ListCOSObjects

func (c *Client) ListCOSObjects(ctx context.Context, cosInstanceID string, bucketName string, region string) (*ibms3.ListObjectsOutput, error)

ListCOSObjects lists Objects in the specified COS Bucket and Instance.

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 DNSInstance

type DNSInstance struct {
	ID   string
	CRN  string
	Zone string
}

DNSInstance holds information for a DNS Services instance

type InstanceType

type InstanceType string

InstanceType is the IBM Cloud network services type being used

const (
	// CISInstanceType is a Cloud Internet Services InstanceType
	CISInstanceType InstanceType = "CIS"
	// DNSInstanceType is a DNS Services InstanceType
	DNSInstanceType InstanceType = "DNS"
)

type Metadata

type Metadata struct {
	BaseDomain              string
	ComputeSubnetNames      []string
	ControlPlaneSubnetNames []string
	Region                  string
	// contains filtered or unexported fields
}

Metadata holds additional metadata for InstallConfig resources that does 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) AccountID

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

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

func (*Metadata) AddVPCToPermittedNetworks

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

AddVPCToPermittedNetworks adds a VPC to the DNS Services Zone of Permitted Networks.

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) Client

func (m *Metadata) Client() (API, error)

Client returns a client used for making API calls to IBM Cloud services.

func (*Metadata) ComputeSubnets

func (m *Metadata) ComputeSubnets(ctx context.Context) (map[string]Subnet, error)

ComputeSubnets gets the Subnet details for compute subnets

func (*Metadata) ControlPlaneSubnets

func (m *Metadata) ControlPlaneSubnets(ctx context.Context) (map[string]Subnet, error)

ControlPlaneSubnets gets the Subnet details for control plane subnets

func (*Metadata) CreateDNSRecord

func (m *Metadata) CreateDNSRecord(ctx context.Context, recordName string, loadBalancer *vpcv1.LoadBalancer) error

CreateDNSRecord creates a CNAME DNS Record in the IBM Cloud Internet Services zone or DNS Services zone for a Load Balancer hostname, based on the PublishStrategy.

func (*Metadata) DNSInstance

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

DNSInstance returns a DNSInstance holding information about the DNS Services instance managing the DNS zone for the base domain.

func (*Metadata) GetIAMToken

func (m *Metadata) GetIAMToken(apiKey string) (*string, error)

GetIAMToken will retrieve an IAM access token using an IAM Authenticator and API Key.

func (*Metadata) IsVPCPermittedNetwork

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

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

type Subnet

type Subnet struct {
	CIDR string
	CRN  string
	ID   string
	Name string
	VPC  string
	Zone string
}

Subnet represents an IBM Cloud VPC Subnet

type VPCResourceNotFoundError

type VPCResourceNotFoundError struct{}

VPCResourceNotFoundError represents an error for a VPC resoruce that is not found.

func (*VPCResourceNotFoundError) Error

func (e *VPCResourceNotFoundError) Error() string

Error returns the error message for the VPCResourceNotFoundError error type.

type Zone

type Zone struct {
	Name            string
	ID              string
	InstanceCRN     string
	ResourceGroupID string
}

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