Documentation ¶
Overview ¶
Package ibm implements the ibm cloud provider.
Index ¶
- Constants
- Variables
- func AddVersionFlag(fs *flag.FlagSet)
- func GetCloudProviderLoadBalancerName(service *v1.Service) string
- func MonitorLoadBalancers(c *Cloud, data map[string]string)
- func NewCloud(config io.Reader) (cloudprovider.Interface, error)
- func PrintVersionAndExitIfRequested()
- type Cloud
- func (c *Cloud) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error
- func (c *Cloud) Clusters() (cloudprovider.Clusters, bool)
- func (c *Cloud) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error)
- func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error)
- func (c *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error
- func (c *Cloud) GetCloudVpc() *vpcctl.CloudVpc
- func (c *Cloud) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error)
- func (c *Cloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string
- func (c *Cloud) GetZone(ctx context.Context) (cloudprovider.Zone, error)
- func (c *Cloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName) (cloudprovider.Zone, error)
- func (c *Cloud) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error)
- func (c *Cloud) HasClusterID() bool
- func (c *Cloud) InitCloudVpc(enablePrivateEndpoint bool) (*vpcctl.CloudVpc, error)
- func (c *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{})
- func (c *Cloud) InstanceExists(ctx context.Context, node *v1.Node) (bool, error)
- func (c *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error)
- func (c *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string, error)
- func (c *Cloud) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error)
- func (c *Cloud) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, error)
- func (c *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)
- func (c *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string, error)
- func (c *Cloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error)
- func (c *Cloud) Instances() (cloudprovider.Instances, bool)
- func (c *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool)
- func (c *Cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool)
- func (c *Cloud) NewConfigVpc(enablePrivateEndpoint bool) (*vpcctl.ConfigVpc, error)
- func (c *Cloud) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.NodeAddress, error)
- func (c *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error)
- func (c *Cloud) ProviderName() string
- func (c *Cloud) Routes() (cloudprovider.Routes, bool)
- func (c *Cloud) SetInformers(informerFactory informers.SharedInformerFactory)
- func (c *Cloud) StartTask(taskFunc CloudTaskFunc, interval time.Duration)
- func (c *Cloud) StopTask(taskFunc CloudTaskFunc)
- func (c *Cloud) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error
- func (c *Cloud) VpcEnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error)
- func (c *Cloud) VpcEnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error
- func (c *Cloud) VpcGetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error)
- func (c *Cloud) VpcMonitorLoadBalancers(services *v1.ServiceList, status map[string]string)
- func (c *Cloud) VpcUpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error
- func (c *Cloud) WatchCloudCredential() error
- func (c *Cloud) Zones() (cloudprovider.Zones, bool)
- type CloudConfig
- type CloudEventReason
- type CloudEventRecorder
- type CloudTask
- type CloudTaskFunc
- type LoadBalancerDeployment
- type MetadataService
- type NodeMetadata
- type Provider
Constants ¶
const (
ProviderName = "ibm"
)
Variables ¶
var CreateUpdateChan = make(chan string) // Channel used to wake up sleeping CreateLB thread(s) when nodes are available
var CreateUpdateMutex = sync.Mutex{} // Serialize access to sync channel. Only allow 1 thread to do close()
var Version = "v1.31.1"
Version is overwritten during builds.
Functions ¶
func AddVersionFlag ¶
AddFlags registers this package's flags on arbitrary FlagSets, such that they point to the same value as the global flags.
func GetCloudProviderLoadBalancerName ¶
GetCloudProviderLoadBalancerName is a copy of the original Kubernetes function for generating a load balancer name. The original function is now deprecated so we are providing our own implementation here to continue generating load balancer names as we always have.
func MonitorLoadBalancers ¶
MonitorLoadBalancers monitors load balancer services to ensure that they are working properly. This is a cloud task run via ticker.
func NewCloud ¶
func NewCloud(config io.Reader) (cloudprovider.Interface, error)
NewCloud creates a new instance of Cloud.
func PrintVersionAndExitIfRequested ¶
func PrintVersionAndExitIfRequested()
Types ¶
type Cloud ¶
type Cloud struct { Name string KubeClient clientset.Interface Config *CloudConfig Recorder *CloudEventRecorder CloudTasks map[string]*CloudTask Metadata *MetadataService // will be nil in kubelet ClassicCloud *classic.Cloud // Classic load balancer support }
Cloud is the ibm cloud provider implementation.
func (*Cloud) AddSSHKeyToAllInstances ¶
AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances expected format for the key is standard ssh-keygen format: <protocol> <blob>
func (*Cloud) Clusters ¶
func (c *Cloud) Clusters() (cloudprovider.Clusters, bool)
Clusters cloud provider interface isn't impletemented.
func (*Cloud) CurrentNodeName ¶
CurrentNodeName returns the name of the node we are currently running on On most clouds (e.g. GCE) this is the hostname, so we provide the hostname
func (*Cloud) EnsureLoadBalancer ¶
func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error)
EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer Implementations must treat the *v1.Service and *v1.Node parameters as read-only and not modify them. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
func (*Cloud) EnsureLoadBalancerDeleted ¶
func (c *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error
EnsureLoadBalancerDeleted deletes the specified load balancer if it exists, returning nil if the load balancer specified either didn't exist or was successfully deleted. This construction is useful because many cloud providers' load balancers have multiple underlying components, meaning a Get could say that the LB doesn't exist even if some part of it is still laying around. Implementations must treat the *v1.Service parameter as read-only and not modify it. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
func (*Cloud) GetCloudVpc ¶
GetCloudVpc - Retrieve the VPC cloud object. Return nil if not initialized.
func (*Cloud) GetLoadBalancer ¶
func (c *Cloud) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error)
GetLoadBalancer returns whether the specified load balancer exists, and if so, what its status is. Implementations must treat the *v1.Service parameter as read-only and not modify it. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
func (*Cloud) GetLoadBalancerName ¶
func (c *Cloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string
GetLoadBalancerName returns the name of the load balancer. Implementations must treat the *v1.Service parameter as read-only and not modify it.
func (*Cloud) GetZone ¶
GetZone returns the Zone containing the current failure zone and locality region that the program is running in In most cases, this method is called from the kubelet querying a local metadata service to acquire its zone. For the case of external cloud providers, use GetZoneByProviderID or GetZoneByNodeName since GetZone can no longer be called from the kubelets.
func (*Cloud) GetZoneByNodeName ¶
func (c *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 This method is particularly used in the context of external cloud providers where node initialization must be done outside the kubelets.
func (*Cloud) GetZoneByProviderID ¶
func (c *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 This method is particularly used in the context of external cloud providers where node initialization must be done outside the kubelets.
func (*Cloud) HasClusterID ¶
HasClusterID returns true if a ClusterID is required and set
func (*Cloud) InitCloudVpc ¶
InitCloudVpc - Initialize the VPC cloud logic
func (*Cloud) Initialize ¶
func (c *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{})
Initialize provides the cloud with a kubernetes client builder and may spawn goroutines to perform housekeeping or run custom controllers specific to the cloud provider. Any tasks started here should be cleaned up when the stop channel closes.
func (*Cloud) InstanceExists ¶
InstanceExists returns true if the instance for the given node exists according to the cloud provider. Use the node.name or node.spec.providerID field to find the node in the cloud provider.
func (*Cloud) InstanceExistsByProviderID ¶
InstanceExistsByProviderID returns true if the instance for the given provider exists. If false is returned with no error, the instance will be immediately deleted by the cloud controller manager. This method should still return true for instances that exist but are stopped/sleeping.
func (*Cloud) InstanceID ¶
InstanceID returns the cloud provider ID of the node with the specified NodeName. Note that if the instance does not exist, we must return ("", cloudprovider.InstanceNotFound) cloudprovider.InstanceNotFound should NOT be returned for instances that exist but are stopped/sleeping
func (*Cloud) InstanceMetadata ¶
func (c *Cloud) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error)
InstanceMetadata returns the instance's metadata. The values returned in InstanceMetadata are translated into specific fields and labels in the Node object on registration. Implementations should always check node.spec.providerID first when trying to discover the instance for a given node. In cases where node.spec.providerID is empty, implementations can use other properties of the node like its name, labels and annotations.
func (*Cloud) InstanceShutdown ¶
InstanceShutdown returns true if the instance is shutdown according to the cloud provider. Use the node.name or node.spec.providerID field to find the node in the cloud provider.
func (*Cloud) InstanceShutdownByProviderID ¶
InstanceShutdownByProviderID returns true if the instance is shutdown in cloudprovider.
func (*Cloud) InstanceType ¶
InstanceType returns the type of the specified instance.
func (*Cloud) InstanceTypeByProviderID ¶
InstanceTypeByProviderID returns the type of the specified instance.
func (*Cloud) Instances ¶
func (c *Cloud) Instances() (cloudprovider.Instances, bool)
Instances cloud provider interface must be implemented.
func (*Cloud) InstancesV2 ¶
func (c *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool)
func (*Cloud) LoadBalancer ¶
func (c *Cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool)
LoadBalancer returns a balancer interface. Also returns true if the interface is supported, false otherwise.
func (*Cloud) NewConfigVpc ¶
NewConfigVpc - Create the ConfigVpc from the current Cloud object
func (*Cloud) NodeAddresses ¶
NodeAddresses returns the addresses of the specified instance.
func (*Cloud) NodeAddressesByProviderID ¶
func (c *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error)
NodeAddressesByProviderID returns the addresses of the specified instance. The instance is specified using the providerID of the node. The ProviderID is a unique identifier of the node. This will not be called from the node whose nodeaddresses are being queried. i.e. local metadata services cannot be used in this method to obtain nodeaddresses
func (*Cloud) ProviderName ¶
ProviderName returns the cloud provider ID.
func (*Cloud) Routes ¶
func (c *Cloud) Routes() (cloudprovider.Routes, bool)
Routes cloud provider interface isn't impletemented because Calico provides the required routing support.
func (*Cloud) SetInformers ¶
func (c *Cloud) SetInformers(informerFactory informers.SharedInformerFactory)
SetInformers initializes any informers when the cloud provider starts
func (*Cloud) StartTask ¶
func (c *Cloud) StartTask(taskFunc CloudTaskFunc, interval time.Duration)
StartTask creates and runs a new cloud task as a go routine at the specified interval.
func (*Cloud) StopTask ¶
func (c *Cloud) StopTask(taskFunc CloudTaskFunc)
StopTask stops an existing cloud task
func (*Cloud) UpdateLoadBalancer ¶
func (c *Cloud) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error
UpdateLoadBalancer updates hosts under the specified load balancer. Implementations must treat the *v1.Service and *v1.Node parameters as read-only and not modify them. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
func (*Cloud) VpcEnsureLoadBalancer ¶
func (c *Cloud) VpcEnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error)
VpcEnsureLoadBalancer - Creates a new VPC load balancer or updates the existing one. Returns the status of the balancer
func (*Cloud) VpcEnsureLoadBalancerDeleted ¶
func (c *Cloud) VpcEnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error
VpcEnsureLoadBalancerDeleted - Deletes the specified load balancer if it exists, returning nil if the load balancer specified either didn't exist or was successfully deleted.
func (*Cloud) VpcGetLoadBalancer ¶
func (c *Cloud) VpcGetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error)
VpcGetLoadBalancer - Returns whether the specified load balancer exists, and if so, what its status is.
func (*Cloud) VpcMonitorLoadBalancers ¶
func (c *Cloud) VpcMonitorLoadBalancers(services *v1.ServiceList, status map[string]string)
VpcMonitorLoadBalancers accepts a list of services (of all types), verifies that each Kubernetes load balancer service has a corresponding VPC load balancer object, and creates Kubernetes events based on the load balancer's status. `status` is a map from a load balancer's unique Service ID to its status. This persists load balancer status between consecutive monitor calls.
func (*Cloud) VpcUpdateLoadBalancer ¶
func (c *Cloud) VpcUpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error
VpcUpdateLoadBalancer updates hosts under the specified load balancer
func (*Cloud) WatchCloudCredential ¶
WatchCloudCredential watches for changes to the cloud credentials and resets the VPC settings
type CloudConfig ¶
type CloudConfig struct { // [global] section Global struct { // Required: Version of the cloud config. Currently only versions // 1.0.0 and 1.1.0 are supported. Version string `gcfg:"version"` } // [kubernetes] section Kubernetes struct { // The Kubernetes config file paths. The first file found will be used. // If not specified, then the in cluster config will be used. Using // an in cluster config is not support for classic infrastructure // since Calico does not support such configurations. ConfigFilePaths []string `gcfg:"config-file"` // The Calico datastore type: "ETCD" or "KDD". Required when running on // classic infrastructure, otherwise this may be omitted and will be // ignored for VPC infrastructure. CalicoDatastore string `gcfg:"calico-datastore"` // If set to true, all new nodes will get the condition NetworkUnavailable // during node registration SetNetworkUnavailable bool `gcfg:"set-network-unavailable,false"` // The CNI being used by the cluster: "Calico" or "OVNKubernetes". CniProvider string `gcfg:"cniProvider"` } // [load-balancer-deployment] section LBDeployment LoadBalancerDeployment `gcfg:"load-balancer-deployment"` // [provider] section Prov Provider `gcfg:"provider"` }
CloudConfig is the ibm cloud provider config data.
type CloudEventReason ¶
type CloudEventReason string
CloudEventReason describes the reason for the cloud event
const ( // CreatingCloudLoadBalancerFailed cloud event reason CreatingCloudLoadBalancerFailed CloudEventReason = "CreatingCloudLoadBalancerFailed" // UpdatingCloudLoadBalancerFailed cloud event reason UpdatingCloudLoadBalancerFailed CloudEventReason = "UpdatingCloudLoadBalancerFailed" // DeletingCloudLoadBalancerFailed cloud event reason DeletingCloudLoadBalancerFailed CloudEventReason = "DeletingCloudLoadBalancerFailed" // GettingCloudLoadBalancerFailed cloud event reason GettingCloudLoadBalancerFailed CloudEventReason = "GettingCloudLoadBalancerFailed" // VerifyingCloudLoadBalancerFailed cloud event reason VerifyingCloudLoadBalancerFailed CloudEventReason = "VerifyingCloudLoadBalancerFailed" )
type CloudEventRecorder ¶
type CloudEventRecorder struct { Name string Recorder record.EventRecorder }
CloudEventRecorder is the cloud event recorder data
func NewCloudEventRecorder ¶
func NewCloudEventRecorder(providerName string, kubeClient clientset.Interface) *CloudEventRecorder
NewCloudEventRecorder returns a cloud event recorder.
func NewCloudEventRecorderV1 ¶
func NewCloudEventRecorderV1(providerName string, eventInterface v1core.EventInterface) *CloudEventRecorder
NewCloudEventRecorderV1 returns a cloud event recorder for v1 client
func (*CloudEventRecorder) LoadBalancerServiceWarningEvent ¶
func (c *CloudEventRecorder) LoadBalancerServiceWarningEvent(lbService *v1.Service, reason CloudEventReason, errorMessage string) error
LoadBalancerServiceWarningEvent logs a load balancer service warning event and returns an error representing the event.
func (*CloudEventRecorder) VpcLoadBalancerServiceWarningEvent ¶
func (c *CloudEventRecorder) VpcLoadBalancerServiceWarningEvent(lbService *v1.Service, reason CloudEventReason, lbName string, errorMessage string) error
VpcLoadBalancerServiceWarningEvent logs a VPC load balancer service warning event and returns an error representing the event.
type CloudTask ¶
type CloudTask struct { // Name of the cloud task built from the task function Name string // Interval between each run of the cloud task Interval time.Duration // Ticker to run the cloud task on the specified interval Ticker *time.Ticker // Stopper to stop the cloud task Stopper chan time.Time // Function to run for the cloud task TaskFunc CloudTaskFunc // Persistent data for the cloud task function FuncData map[string]string }
CloudTask is the cloud task data.
type CloudTaskFunc ¶
CloudTaskFunc is the cloud task function signature.
type LoadBalancerDeployment ¶
type LoadBalancerDeployment struct { // Name of the image to use for the load balancer deployment. Image string `gcfg:"image"` // Name of the application to use as a label for the load balancer deployment. Application string `gcfg:"application"` // Name of the VLAN IP config map in the kube-system or ibm-system namespace // that is used to determine the available cloud provider IPs for the // load balancer deployment. VlanIPConfigMap string `gcfg:"vlan-ip-config-map"` }
LoadBalancerDeployment is the load balancer deployment data for classic load balancers. All fields are required when running on classic infrastructure, otherwise this section may be omitted and will be ignored for VPC infrastructure.
type MetadataService ¶
type MetadataService struct {
// contains filtered or unexported fields
}
MetadataService provides access to provider metadata stored in node labels.
func NewMetadataService ¶
func NewMetadataService(provider *Provider, kubeClient kubernetes.Interface) *MetadataService
NewMetadataService creates a service using the specified client to connect to the cluster. kubernetes.Interface could be a kubernetes/fake ClientSet
func (*MetadataService) GetNodeMetadata ¶
func (ms *MetadataService) GetNodeMetadata(name string, applyNetworkUnavailable bool, cni string) (NodeMetadata, error)
GetNodeMetadata returns the metadata for the named node. If the node does not exist, or not all data is available, an error is returned.
type NodeMetadata ¶
type NodeMetadata struct { InternalIP string ExternalIP string WorkerID string InstanceType string FailureDomain string Region string ProviderID string }
NodeMetadata holds the provider metatdata from a node. Field names reflects Kubernetes CCM terminology.
type Provider ¶
type Provider struct { // Unsupported: Cloud provider ID for the node. Only used when running the // legacy in tree cloud provider implementation, ignored otherwise. ProviderID string `gcfg:"providerID"` // Unsupported: Internal IP of the node. Only used when running the // legacy in tree cloud provider implementation, ignored otherwise. InternalIP string `gcfg:"internalIP"` // Unsupported: External IP of the node. Only used when running the // legacy in tree cloud provider implementation, ignored otherwise. ExternalIP string `gcfg:"externalIP"` // NOTE(rtheis): This field has multiple usages. // Region of the cluster. Required when configured to get node // data from VPC. // Unsupported: Region of the node. Only used when running the // legacy in tree cloud provider implementation. Region string `gcfg:"region"` // Unsupported: Zone of the node. Only used when running the // legacy in tree cloud provider implementation, ignored otherwise. Zone string `gcfg:"zone"` // Unsupported: Instance Type of the node. Only used when running the // legacy in tree cloud provider implementation, ignored otherwise. InstanceType string `gcfg:"instanceType"` // Required: Cluster ID of the cluster. ClusterID string `gcfg:"clusterID"` // Required: Account ID that owns the cluster. AccountID string `gcfg:"accountID"` // Required: Provider type of the cloud provider. Set to "g2" when running // on VPC infrastructure. All other values (including being unset) // yield the default, classic infrastructure. // TODO(rtheis): Remove support for "gc" provider type. ProviderType string `gcfg:"cluster-default-provider"` // Required for VPC: Service account ID used to allocate VPC infrastructure. G2WorkerServiceAccountID string `gcfg:"g2workerServiceAccountID"` // VPC name. Required when configured to get node data from VPC. G2VpcName string `gcfg:"g2VpcName"` // File containing VPC credentials. Required when configured to get node // data from VPC. G2Credentials string `gcfg:"g2Credentials"` // Resource group name. Required when configured to get node // data from VPC. G2ResourceGroupName string `gcfg:"g2ResourceGroupName"` // List of VPC subnet names. Required when configured to get node // data from VPC. G2VpcSubnetNames string `gcfg:"g2VpcSubnetNames"` // Optional: VPC RIaaS endpoint override URL G2EndpointOverride string `gcfg:"g2EndpointOverride"` // Optional: IAM endpoint override URL IamEndpointOverride string `gcfg:"iamEndpointOverride"` // Optional: Resource Manager endpoint override URL RmEndpointOverride string `gcfg:"rmEndpointOverride"` // Optional: IBM Cloud Kubernetes Service API Private Endpoint Hostname IKSPrivateEndpointHostname string `gcfg:"iksPrivateEndpointHostname"` // File containing cloud credentials both for Classic and VPC CloudCredentials string `gcfg:"cloudCredentials"` }
Provider holds information from the cloud provider. TODO(rtheis): Remove legacy in tree cloud provider implementation.