openstack

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: Apache-2.0 Imports: 61 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"
	ServiceAnnotationLoadBalancerFloatingNetworkID    = "loadbalancer.openstack.org/floating-network-id"
	ServiceAnnotationLoadBalancerFloatingSubnet       = "loadbalancer.openstack.org/floating-subnet"
	ServiceAnnotationLoadBalancerFloatingSubnetID     = "loadbalancer.openstack.org/floating-subnet-id"
	ServiceAnnotationLoadBalancerClass                = "loadbalancer.openstack.org/class"
	ServiceAnnotationLoadBalancerKeepFloatingIP       = "loadbalancer.openstack.org/keep-floatingip"
	ServiceAnnotationLoadBalancerPortID               = "loadbalancer.openstack.org/port-id"
	ServiceAnnotationLoadBalancerProxyEnabled         = "loadbalancer.openstack.org/proxy-protocol"
	ServiceAnnotationLoadBalancerSubnetID             = "loadbalancer.openstack.org/subnet-id"
	ServiceAnnotationLoadBalancerNetworkID            = "loadbalancer.openstack.org/network-id"
	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"
	ServiceAnnotationLoadBalancerFlavorID             = "loadbalancer.openstack.org/flavor-id"
	ServiceAnnotationLoadBalancerAvailabilityZone     = "loadbalancer.openstack.org/availability-zone"
	// 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.

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 added in v1.16.0

func AddExtraFlags(fs *pflag.FlagSet)

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

func AddToNodeAddresses added in v1.18.1

func AddToNodeAddresses(addresses *[]v1.NodeAddress, addAddresses ...v1.NodeAddress)

AddToNodeAddresses appends the NodeAddresses to the passed-by-pointer slice, only if they do not already exist

func GetLoadBalancerSourceRanges added in v1.18.1

func GetLoadBalancerSourceRanges(service *corev1.Service) (netsets.IPNet, error)

GetLoadBalancerSourceRanges first try to parse and verify LoadBalancerSourceRanges field from a service. If the field is not specified, turn to parse and verify the AnnotationLoadBalancerSourceRangesKey annotation from a service, extracting the source ranges to allow, and if not present returns a default (allow-all) value.

func IsAllowAll added in v1.18.1

func IsAllowAll(ipnets netsets.IPNet) bool

IsAllowAll checks whether the netsets.IPNet allows traffic from 0.0.0.0/0

func LogCfg added in v1.16.0

func LogCfg(cfg Config)

func NewOpenStackClient added in v1.16.0

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 added in v1.14.0

func ReadClouds(cfg *Config) error

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

func RemoveFromNodeAddresses added in v1.18.1

func RemoveFromNodeAddresses(addresses *[]v1.NodeAddress, removeAddresses ...v1.NodeAddress)

RemoveFromNodeAddresses removes the NodeAddresses from the passed-by-pointer slice if they already exist.

Types

type AuthOpts added in v1.16.0

type AuthOpts struct {
	AuthURL          string `` /* 141-byte string literal not displayed */
	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"`
	TenantID         string `gcfg:"tenant-id" mapstructure:"project-id" name:"os-projectID" value:"optional" dependsOn:"os-password|os-clientCertPath"`
	TenantName       string `` /* 127-byte string literal not displayed */
	TrustID          string `gcfg:"trust-id" mapstructure:"trust-id" name:"os-trustID" value:"optional"`
	TrusteeID        string `gcfg:"trustee-id" mapstructure:"trustee-id" name:"os-trusteeID" value:"optional" dependsOn:"os-trustID"`
	TrusteePassword  string `gcfg:"trustee-password" mapstructure:"trustee-password" name:"os-trusteePassword" value:"optional" dependsOn:"os-trustID"`
	DomainID         string `gcfg:"domain-id" mapstructure:"domain-id" name:"os-domainID" value:"optional" dependsOn:"os-password|os-clientCertPath"`
	DomainName       string `gcfg:"domain-name" mapstructure:"domain-name" name:"os-domainName" value:"optional" dependsOn:"os-password|os-clientCertPath"`
	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"`
	TLSInsecure      string `gcfg:"tls-insecure" mapstructure:"tls-insecure" name:"os-TLSInsecure" value:"optional" matches:"^true|false$"`

	// TLS client auth
	CertFile string `gcfg:"cert-file" mapstructure:"cert-file" name:"os-clientCertPath" value:"optional" dependsOn:"os-clientKeyPath"`
	KeyFile  string `gcfg:"key-file" mapstructure:"key-file" name:"os-clientKeyPath" value:"optional" dependsOn:"os-clientCertPath"`

	// backward compatibility with the manila-csi-plugin
	CAFileContents string `name:"os-certAuthority" value:"optional"`

	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) ToAuth3Options added in v1.16.0

func (cfg AuthOpts) ToAuth3Options() tokens3.AuthOptions

func (AuthOpts) ToAuthOptions added in v1.16.0

func (cfg AuthOpts) ToAuthOptions() gophercloud.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 Config

type Config struct {
	Global            AuthOpts
	LoadBalancer      LoadBalancerOpts
	LoadBalancerClass map[string]*LBClass
	BlockStorage      BlockStorageOpts
	Route             RouterOpts
	Metadata          MetadataOpts
	Networking        NetworkingOpts
}

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

func ReadConfig added in v0.3.0

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) InstanceExists added in v1.19.0

func (i *Instances) InstanceExists(ctx context.Context, node *v1.Node) (bool, error)

InstanceExists returns true if the instance for the given node exists.

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 exists. 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) InstanceMetadata added in v1.19.0

func (i *Instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error)

InstanceMetadata returns metadata of the specified instance.

func (*Instances) InstanceShutdown added in v1.19.0

func (i *Instances) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, error)

InstanceShutdown returns true if the instances is in safe state to detach volumes. It is the only state, where volumes can be detached immediately.

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. It is the only state, where volumes can be detached immediately.

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 LBClass added in v1.15.0

type LBClass struct {
	FloatingNetworkID string `gcfg:"floating-network-id,omitempty"`
	FloatingSubnetID  string `gcfg:"floating-subnet-id,omitempty"`
	SubnetID          string `gcfg:"subnet-id,omitempty"`
	NetworkID         string `gcfg:"network-id,omitempty"`
}

LBClass defines the corresponding floating network, floating subnet or internal subnet ID

type LbaasV2

type LbaasV2 struct {
	LoadBalancer
}

LbaasV2 is a LoadBalancer implementation for Neutron LBaaS v2 API

func (*LbaasV2) EnsureLoadBalancer

func (lbaas *LbaasV2) 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 (*LbaasV2) EnsureLoadBalancerDeleted

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

EnsureLoadBalancerDeleted deletes the specified load balancer

func (*LbaasV2) EnsureSecurityGroupDeleted

func (lbaas *LbaasV2) EnsureSecurityGroupDeleted(clusterName string, service *corev1.Service) error

EnsureSecurityGroupDeleted deleting security group for specific loadbalancer service.

func (*LbaasV2) GetLoadBalancer

func (lbaas *LbaasV2) 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 (*LbaasV2) GetLoadBalancerLegacyName added in v1.14.0

func (lbaas *LbaasV2) GetLoadBalancerLegacyName(ctx context.Context, clusterName string, service *corev1.Service) string

GetLoadBalancerLegacyName returns the legacy load balancer name for backward compatibility.

func (*LbaasV2) GetLoadBalancerName added in v0.3.0

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

GetLoadBalancerName returns the constructed load balancer name.

func (*LbaasV2) UpdateLoadBalancer

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

UpdateLoadBalancer updates hosts under the specified load balancer.

type LoadBalancer

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

LoadBalancer is used for creating and maintaining load balancers

type LoadBalancerOpts

type LoadBalancerOpts struct {
	LBVersion            string              `gcfg:"lb-version"`          // overrides autodetection. Only support v2.
	UseOctavia           bool                `gcfg:"use-octavia"`         // uses Octavia V2 service catalog endpoint
	SubnetID             string              `gcfg:"subnet-id"`           // overrides autodetection.
	NetworkID            string              `gcfg:"network-id"`          // If specified, will create virtual ip from a subnet in network which has available IP addresses
	FloatingNetworkID    string              `gcfg:"floating-network-id"` // If specified, will create floating ip for loadbalancer, or do not create floating ip.
	FloatingSubnetID     string              `gcfg:"floating-subnet-id"`  // If specified, will create floating ip for loadbalancer in this particular floating pool subnetwork.
	LBClasses            map[string]*LBClass // Predefined named Floating networks and subnets
	LBMethod             string              `gcfg:"lb-method"` // default to ROUND_ROBIN.
	LBProvider           string              `gcfg:"lb-provider"`
	CreateMonitor        bool                `gcfg:"create-monitor"`
	MonitorDelay         MyDuration          `gcfg:"monitor-delay"`
	MonitorTimeout       MyDuration          `gcfg:"monitor-timeout"`
	MonitorMaxRetries    uint                `gcfg:"monitor-max-retries"`
	ManageSecurityGroups bool                `gcfg:"manage-security-groups"`
	NodeSecurityGroupIDs []string            // Do not specify, get it automatically when enable manage-security-groups. TODO(FengyunPan): move it into cache
	InternalLB           bool                `gcfg:"internal-lb"`    // default false
	CascadeDelete        bool                `gcfg:"cascade-delete"` // applicable only if use-octavia is set to True
	FlavorID             string              `gcfg:"flavor-id"`
	AvailabilityZone     string              `gcfg:"availability-zone"`
}

LoadBalancerOpts have the options to talk to Neutron LBaaSV2 or Octavia

type Logger added in v1.18.0

type Logger struct{}

func (Logger) Printf added in v1.18.0

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 added in v0.3.0

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

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

func (*OpenStack) Clusters

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

Clusters is a no-op

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) InstancesV2 added in v1.19.0

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

InstancesV2 returns an implementation of InstancesV2 for OpenStack. TODO: Support InstancesV2 in the future.

func (*OpenStack) LoadBalancer

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

LoadBalancer initializes a LbaasV2 object

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

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

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

func (*OpenStack) NewLoadBalancerV2

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

NewLoadBalancerV2 creates a ServiceClient that may be used with the Neutron LBaaS 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) 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) 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 ServerAttributesExt added in v1.14.0

type ServerAttributesExt struct {
	servers.Server
	availabilityzones.ServerAvailabilityZoneExt
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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