openstack

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderName is the name of the openstack provider
	ProviderName = "openstack"

	// TypeHostName is the name type of openstack instance
	TypeHostName = "hostname"
)
View Source
const (

	// ServiceAnnotationLoadBalancerInternal defines whether or not to create an internal loadbalancer. Default: false.
	ServiceAnnotationLoadBalancerInternal             = "service.beta.kubernetes.io/openstack-internal-load-balancer"
	ServiceAnnotationLoadBalancerConnLimit            = "loadbalancer.openstack.org/connection-limit"
	ServiceAnnotationLoadBalancerProxyEnabled         = "loadbalancer.openstack.org/proxy-protocol"
	ServiceAnnotationLoadBalancerTimeoutClientData    = "loadbalancer.openstack.org/timeout-client-data"
	ServiceAnnotationLoadBalancerTimeoutMemberConnect = "loadbalancer.openstack.org/timeout-member-connect"
	ServiceAnnotationLoadBalancerTimeoutMemberData    = "loadbalancer.openstack.org/timeout-member-data"
	ServiceAnnotationLoadBalancerTimeoutTCPInspect    = "loadbalancer.openstack.org/timeout-tcp-inspect"
	ServiceAnnotationLoadBalancerXForwardedFor        = "loadbalancer.openstack.org/x-forwarded-for"
	// ServiceAnnotationLoadBalancerEnableHealthMonitor defines whether or not to create health monitor for the load balancer
	// pool, if not specified, use 'create-monitor' config. The health monitor can be created or deleted dynamically.
	ServiceAnnotationLoadBalancerEnableHealthMonitor = "loadbalancer.openstack.org/enable-health-monitor"
)

Note: when creating a new Loadbalancer (VM), it can take some time before it is ready for use, this timeout is used for waiting until the Loadbalancer provisioning status goes to ACTIVE state.

View Source
const (
	LabelZoneFailureDomain = "failure-domain.beta.kubernetes.io/zone"
	LabelZoneRegion        = "failure-domain.beta.kubernetes.io/region"
)

Variables

View Source
var ErrIPv6SupportDisabled = errors.New("IPv6 support is disabled")

ErrIPv6SupportDisabled is used when one tries to use IPv6 Addresses when IPv6 support is disabled by config

View Source
var ErrMultipleResults = errors.New("multiple results where only one expected")

ErrMultipleResults is used when we unexpectedly get back multiple results

View Source
var ErrNoAddressFound = errors.New("no address found for host")

ErrNoAddressFound is used when we cannot find an ip address for the host

View Source
var ErrNotFound = errors.New("failed to find object")

ErrNotFound is used to inform that the object is missing

Functions

func AddExtraFlags

func AddExtraFlags(fs *pflag.FlagSet)

AddExtraFlags is called by the main package to add component specific command line flags

func LogCfg

func LogCfg(cfg Config)

func NewOpenStackClient

func NewOpenStackClient(cfg *AuthOpts, userAgent string, extraUserAgent ...string) (*gophercloud.ProviderClient, error)

NewOpenStackClient creates a new instance of the openstack client

func NewRoutes

func NewRoutes(compute *gophercloud.ServiceClient, network *gophercloud.ServiceClient, opts RouterOpts, networkingOpts NetworkingOpts) (cloudprovider.Routes, error)

NewRoutes creates a new instance of Routes

func ReadClouds

func ReadClouds(cfg *Config) error

ReadClouds reads Reads clouds.yaml to generate a Config Allows the cloud-config to have priority

func RegisterMetrics

func RegisterMetrics()

Types

type AuthOpts

type AuthOpts struct {
	AuthURL          string `gcfg:"auth-url" mapstructure:"auth-url" name:"os-authURL" dependsOn:"os-password|os-trustID"`
	UserID           string `gcfg:"user-id" mapstructure:"user-id" name:"os-userID" value:"optional" dependsOn:"os-password"`
	Username         string `name:"os-userName" value:"optional" dependsOn:"os-password"`
	Password         string `name:"os-password" value:"optional" dependsOn:"os-domainID|os-domainName,os-projectID|os-projectName,os-userID|os-userName"`
	ApiKey           string `gcfg:"rax-api-key" mapstructure:"rax-api-key" name:"rax-api-key" value:"optional" dependsOn:"os-username"`
	TenantID         string `gcfg:"tenant-id" mapstructure:"project-id" name:"os-projectID" value:"optional" dependsOn:"os-password"`
	TenantName       string `gcfg:"tenant-name" mapstructure:"project-name" name:"os-projectName" value:"optional" dependsOn:"os-password"`
	TrustID          string `gcfg:"trust-id" mapstructure:"trust-id" name:"os-trustID" value:"optional"`
	DomainID         string `gcfg:"domain-id" mapstructure:"domain-id" name:"os-domainID" value:"optional" dependsOn:"os-password"`
	DomainName       string `gcfg:"domain-name" mapstructure:"domain-name" name:"os-domainName" value:"optional" dependsOn:"os-password"`
	TenantDomainID   string `gcfg:"tenant-domain-id" mapstructure:"project-domain-id" name:"os-projectDomainID" value:"optional"`
	TenantDomainName string `gcfg:"tenant-domain-name" mapstructure:"project-domain-name" name:"os-projectDomainName" value:"optional"`
	UserDomainID     string `gcfg:"user-domain-id" mapstructure:"user-domain-id" name:"os-userDomainID" value:"optional"`
	UserDomainName   string `gcfg:"user-domain-name" mapstructure:"user-domain-name" name:"os-userDomainName" value:"optional"`
	Region           string `name:"os-region"`
	CAFile           string `gcfg:"ca-file" mapstructure:"ca-file" name:"os-certAuthorityPath" value:"optional"`

	// Manila only options
	TLSInsecure string `name:"os-TLSInsecure" value:"optional" matches:"^true|false$"`
	// backward compatibility with the manila-csi-plugin
	CAFileContents  string `name:"os-certAuthority" value:"optional"`
	TrusteeID       string `name:"os-trusteeID" value:"optional" dependsOn:"os-trustID"`
	TrusteePassword string `name:"os-trusteePassword" value:"optional" dependsOn:"os-trustID"`

	UseClouds  bool   `gcfg:"use-clouds" mapstructure:"use-clouds" name:"os-useClouds" value:"optional"`
	CloudsFile string `gcfg:"clouds-file,omitempty" mapstructure:"clouds-file,omitempty" name:"os-cloudsFile" value:"optional"`
	Cloud      string `gcfg:"cloud,omitempty" mapstructure:"cloud,omitempty" name:"os-cloud" value:"optional"`

	ApplicationCredentialID     string `gcfg:"application-credential-id" mapstructure:"application-credential-id" name:"os-applicationCredentialID" value:"optional"`
	ApplicationCredentialName   string `` /* 130-byte string literal not displayed */
	ApplicationCredentialSecret string `` /* 136-byte string literal not displayed */
}

func (AuthOpts) ToAuthOptions

func (cfg AuthOpts) ToAuthOptions() raxauth.AuthOptions

type BlockStorageOpts

type BlockStorageOpts struct {
	BSVersion       string `gcfg:"bs-version"`        // overrides autodetection. v1 or v2. Defaults to auto
	TrustDevicePath bool   `gcfg:"trust-device-path"` // See Issue #33128
	IgnoreVolumeAZ  bool   `gcfg:"ignore-volume-az"`
}

BlockStorageOpts is used to talk to Cinder service

type CloudLb

type CloudLb struct {
	LoadBalancer
}

CloudLb is a LoadBalancer implementation for Rackspace Cloud LoadBalancer API

func (*CloudLb) EnsureLoadBalancer

func (lbaas *CloudLb) EnsureLoadBalancer(ctx context.Context, clusterName string, apiService *corev1.Service, nodes []*corev1.Node) (*corev1.LoadBalancerStatus, error)

EnsureLoadBalancer creates a new load balancer or updates the existing one.

func (*CloudLb) EnsureLoadBalancerDeleted

func (lbaas *CloudLb) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *corev1.Service) error

EnsureLoadBalancerDeleted deletes the specified load balancer

func (*CloudLb) GetLoadBalancer

func (lbaas *CloudLb) GetLoadBalancer(ctx context.Context, clusterName string, service *corev1.Service) (*corev1.LoadBalancerStatus, bool, error)

GetLoadBalancer returns whether the specified load balancer exists and its status

func (*CloudLb) GetLoadBalancerName

func (lbaas *CloudLb) GetLoadBalancerName(ctx context.Context, clusterName string, service *corev1.Service) string

GetLoadBalancerName returns the constructed load balancer name.

func (*CloudLb) UpdateLoadBalancer

func (lbaas *CloudLb) UpdateLoadBalancer(ctx context.Context, clusterName string, service *corev1.Service, nodes []*corev1.Node) error

UpdateLoadBalancer updates hosts under the specified load balancer.

type Config

type Config struct {
	Global       AuthOpts
	LoadBalancer LoadBalancerOpts
	BlockStorage BlockStorageOpts
	Route        RouterOpts
	Metadata     MetadataOpts
	Networking   NetworkingOpts
}

Config is used to read and store information from the cloud configuration file

func ReadConfig

func ReadConfig(config io.Reader) (Config, error)

ReadConfig reads values from the cloud.conf

type Instances

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

Instances encapsulates an implementation of Instances for OpenStack.

func (*Instances) AddSSHKeyToAllInstances

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

AddSSHKeyToAllInstances is not implemented for OpenStack

func (*Instances) CurrentNodeName

func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error)

CurrentNodeName implements Instances.CurrentNodeName Note this is *not* necessarily the same as hostname.

func (*Instances) InstanceExistsByProviderID

func (i *Instances) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error)

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

func (*Instances) InstanceID

func (i *Instances) InstanceID(ctx context.Context, name types.NodeName) (string, error)

InstanceID returns the cloud provider ID of the specified instance.

func (*Instances) InstanceShutdownByProviderID

func (i *Instances) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)

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

func (*Instances) InstanceType

func (i *Instances) InstanceType(ctx context.Context, name types.NodeName) (string, error)

InstanceType returns the type of the specified instance.

func (*Instances) InstanceTypeByProviderID

func (i *Instances) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error)

InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID This method will not be called from the node that is requesting this ID. i.e. metadata service and other local methods cannot be used here

func (*Instances) NodeAddresses

func (i *Instances) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.NodeAddress, error)

NodeAddresses implements Instances.NodeAddresses

func (*Instances) NodeAddressesByProviderID

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

NodeAddressesByProviderID returns the node addresses of an instances with the specified unique providerID This method will not be called from the node that is requesting this ID. i.e. metadata service and other local methods cannot be used here

type LoadBalancer

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

LoadBalancer is used for creating and maintaining load balancers

type LoadBalancerOpts

type LoadBalancerOpts struct {
	LBMethod          string     `gcfg:"lb-method"` // default to ROUND_ROBIN.
	CreateMonitor     bool       `gcfg:"create-monitor"`
	MonitorDelay      MyDuration `gcfg:"monitor-delay"`
	MonitorTimeout    MyDuration `gcfg:"monitor-timeout"`
	MonitorMaxRetries uint       `gcfg:"monitor-max-retries"`
	InternalLB        bool       `gcfg:"internal-lb"` // default false
}

LoadBalancerOpts have the options to talk to Rackspace Cloud LoadBalancers

type Logger

type Logger struct{}

func (Logger) Printf

func (l Logger) Printf(format string, args ...interface{})

type MetadataOpts

type MetadataOpts struct {
	SearchOrder    string     `gcfg:"search-order"`
	RequestTimeout MyDuration `gcfg:"request-timeout"`
}

MetadataOpts is used for configuring how to talk to metadata service or config drive

type MyDuration

type MyDuration struct {
	time.Duration
}

MyDuration is the encoding.TextUnmarshaler interface for time.Duration

func (*MyDuration) UnmarshalText

func (d *MyDuration) UnmarshalText(text []byte) error

UnmarshalText is used to convert from text to Duration

type NetworkingOpts

type NetworkingOpts struct {
	IPv6SupportDisabled bool   `gcfg:"ipv6-support-disabled"`
	PublicNetworkName   string `gcfg:"public-network-name"`
	InternalNetworkName string `gcfg:"internal-network-name"`
}

NetworkingOpts is used for networking settings

type OpenStack

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

OpenStack is an implementation of cloud provider Interface for OpenStack.

func NewOpenStack

func NewOpenStack(cfg Config) (*OpenStack, error)

NewOpenStack creates a new new instance of the openstack struct from a config struct

func (*OpenStack) AttachDisk

func (os *OpenStack) AttachDisk(instanceID, volumeID string) (string, error)

AttachDisk attaches given cinder volume to the compute running kubelet

func (*OpenStack) Clusters

func (os *OpenStack) Clusters() (cloudprovider.Clusters, bool)

Clusters is a no-op

func (*OpenStack) CreateVolume

func (os *OpenStack) CreateVolume(name string, size int, vtype, availability string, tags *map[string]string) (string, string, string, bool, error)

CreateVolume creates a volume of given size (in GiB)

func (*OpenStack) DeleteVolume

func (os *OpenStack) DeleteVolume(volumeID string) error

DeleteVolume deletes a volume given volume name.

func (*OpenStack) DetachDisk

func (os *OpenStack) DetachDisk(instanceID, volumeID string) error

DetachDisk detaches given cinder volume from the compute running kubelet

func (*OpenStack) DiskIsAttached

func (os *OpenStack) DiskIsAttached(instanceID, volumeID string) (bool, error)

DiskIsAttached queries if a volume is attached to a compute instance

func (*OpenStack) DiskIsAttachedByName

func (os *OpenStack) DiskIsAttachedByName(nodeName types.NodeName, volumeID string) (bool, string, error)

DiskIsAttachedByName queries if a volume is attached to a compute instance by name

func (*OpenStack) DisksAreAttached

func (os *OpenStack) DisksAreAttached(instanceID string, volumeIDs []string) (map[string]bool, error)

DisksAreAttached queries if a list of volumes are attached to a compute instance

func (*OpenStack) DisksAreAttachedByName

func (os *OpenStack) DisksAreAttachedByName(nodeName types.NodeName, volumeIDs []string) (map[string]bool, error)

DisksAreAttachedByName queries if a list of volumes are attached to a compute instance by name

func (*OpenStack) ExpandVolume

func (os *OpenStack) ExpandVolume(volumeID string, oldSize resource.Quantity, newSize resource.Quantity) (resource.Quantity, error)

ExpandVolume expands the size of specific cinder volume (in GiB)

func (*OpenStack) GetAttachmentDiskPath

func (os *OpenStack) GetAttachmentDiskPath(instanceID, volumeID string) (string, error)

GetAttachmentDiskPath gets device path of attached volume to the compute running kubelet, as known by cinder

func (*OpenStack) GetDevicePath

func (os *OpenStack) GetDevicePath(volumeID string) (string, error)

GetDevicePath returns the path of an attached block storage volume, specified by its id.

func (*OpenStack) GetDevicePathBySerialID

func (os *OpenStack) GetDevicePathBySerialID(volumeID string) string

GetDevicePathBySerialID returns the path of an attached block storage volume, specified by its id.

func (*OpenStack) GetLabelsForVolume

func (os *OpenStack) GetLabelsForVolume(ctx context.Context, pv *v1.PersistentVolume) (map[string]string, error)

GetLabelsForVolume implements PVLabeler.GetLabelsForVolume

func (*OpenStack) GetNodeNameByID

func (os *OpenStack) GetNodeNameByID(instanceID string) (types.NodeName, error)

GetNodeNameByID maps instanceid to types.NodeName

func (*OpenStack) GetZone

func (os *OpenStack) GetZone(ctx context.Context) (cloudprovider.Zone, error)

GetZone returns the current zone

func (*OpenStack) GetZoneByNodeName

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

GetZoneByNodeName implements Zones.GetZoneByNodeName This is particularly useful in external cloud providers where the kubelet does not initialize node data.

func (*OpenStack) GetZoneByProviderID

func (os *OpenStack) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error)

GetZoneByProviderID implements Zones.GetZoneByProviderID This is particularly useful in external cloud providers where the kubelet does not initialize node data.

func (*OpenStack) HasClusterID

func (os *OpenStack) HasClusterID() bool

HasClusterID returns true if the cluster has a clusterID

func (*OpenStack) Initialize

func (os *OpenStack) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{})

Initialize passes a Kubernetes clientBuilder interface to the cloud provider

func (*OpenStack) InstanceID

func (os *OpenStack) InstanceID() (string, error)

InstanceID returns the kubelet's cloud provider ID.

func (*OpenStack) Instances

func (os *OpenStack) Instances() (cloudprovider.Instances, bool)

Instances returns an implementation of Instances for OpenStack.

func (*OpenStack) LoadBalancer

func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool)

LoadBalancer initializes a CloudLb object

func (*OpenStack) NewBlockStorageV1

func (os *OpenStack) NewBlockStorageV1() (*gophercloud.ServiceClient, error)

NewBlockStorageV1 creates a ServiceClient that may be used with the Cinder v1 API

func (*OpenStack) NewBlockStorageV2

func (os *OpenStack) NewBlockStorageV2() (*gophercloud.ServiceClient, error)

NewBlockStorageV2 creates a ServiceClient that may be used with the Cinder v2 API

func (*OpenStack) NewBlockStorageV3

func (os *OpenStack) NewBlockStorageV3() (*gophercloud.ServiceClient, error)

NewBlockStorageV3 creates a ServiceClient that may be used with the Cinder v3 API

func (*OpenStack) NewCloudLoadBalancer

func (os *OpenStack) NewCloudLoadBalancer() (*gophercloud.ServiceClient, error)

NewCloudLoadBalancer creates a ServiceClient that may be used with the Rackspace Cloud Load Balancer v1.0 API

func (*OpenStack) NewComputeV2

func (os *OpenStack) NewComputeV2() (*gophercloud.ServiceClient, error)

NewComputeV2 creates a ServiceClient that may be used with the nova v2 API

func (*OpenStack) NewNetworkV2

func (os *OpenStack) NewNetworkV2() (*gophercloud.ServiceClient, error)

NewNetworkV2 creates a ServiceClient that may be used with the neutron v2 API

func (*OpenStack) OperationPending

func (os *OpenStack) OperationPending(diskName string) (bool, string, error)

OperationPending checks if there is an operation pending on a volume

func (*OpenStack) ProviderName

func (os *OpenStack) ProviderName() string

ProviderName returns the cloud provider ID.

func (*OpenStack) Routes

func (os *OpenStack) Routes() (cloudprovider.Routes, bool)

Routes initializes routes support

func (*OpenStack) ScrubDNS

func (os *OpenStack) ScrubDNS(nameServers, searches []string) ([]string, []string)

ScrubDNS filters DNS settings for pods.

func (*OpenStack) ShouldTrustDevicePath

func (os *OpenStack) ShouldTrustDevicePath() bool

ShouldTrustDevicePath queries if we should trust the cinder provide deviceName, See issue #33128

func (*OpenStack) Zones

func (os *OpenStack) Zones() (cloudprovider.Zones, bool)

Zones indicates that we support zones

type RouterOpts

type RouterOpts struct {
	RouterID string `gcfg:"router-id"` // required
}

RouterOpts is used for Neutron routes

type Routes

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

Routes implements the cloudprovider.Routes for OpenStack clouds

func (*Routes) CreateRoute

func (r *Routes) CreateRoute(ctx context.Context, clusterName string, nameHint string, route *cloudprovider.Route) error

CreateRoute creates the described managed route

func (*Routes) DeleteRoute

func (r *Routes) DeleteRoute(ctx context.Context, clusterName string, route *cloudprovider.Route) error

DeleteRoute deletes the specified managed route

func (*Routes) ListRoutes

func (r *Routes) ListRoutes(ctx context.Context, clusterName string) ([]*cloudprovider.Route, error)

ListRoutes lists all managed routes that belong to the specified clusterName

type Volume

type Volume struct {
	// ID of the instance, to which this volume is attached. "" if not attached
	AttachedServerID string
	// Device file path
	AttachedDevice string
	// AvailabilityZone is which availability zone the volume is in
	AvailabilityZone string
	// Unique identifier for the volume.
	ID string
	// Human-readable display name for the volume.
	Name string
	// Current status of the volume.
	Status string
	// Volume size in GB
	Size int
}

Volume stores information about a single volume

type VolumesV2

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

VolumesV2 is a Volumes implementation for cinder v2

type VolumesV3

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

VolumesV3 is a Volumes implementation for cinder v3

Jump to

Keyboard shortcuts

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