openstack

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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"
	ServiceAnnotationLoadBalancerFloatingSubnetTags   = "loadbalancer.openstack.org/floating-subnet-tags"
	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"
	ServiceAnnotationLoadBalancerMemberSubnetID       = "loadbalancer.openstack.org/member-subnet-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 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"
	ServiceAnnotationLoadBalancerHealthMonitorDelay          = "loadbalancer.openstack.org/health-monitor-delay"
	ServiceAnnotationLoadBalancerHealthMonitorTimeout        = "loadbalancer.openstack.org/health-monitor-timeout"
	ServiceAnnotationLoadBalancerHealthMonitorMaxRetries     = "loadbalancer.openstack.org/health-monitor-max-retries"
	ServiceAnnotationLoadBalancerHealthMonitorMaxRetriesDown = "loadbalancer.openstack.org/health-monitor-max-retries-down"
	ServiceAnnotationLoadBalancerLoadbalancerHostname        = "loadbalancer.openstack.org/hostname"
	ServiceAnnotationLoadBalancerAddress                     = "loadbalancer.openstack.org/load-balancer-address"
	// revive:disable:var-naming
	ServiceAnnotationTlsContainerRef = "loadbalancer.openstack.org/default-tls-container-ref"

	ServiceAnnotationLoadBalancerID = "loadbalancer.openstack.org/load-balancer-id"
)

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 (
	// ProviderName is the name of the openstack provider
	ProviderName = "openstack"

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

Variables

This section is empty.

Functions

func AddExtraFlags

func AddExtraFlags(fs *pflag.FlagSet)

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

func AddToNodeAddresses

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

func GetLoadBalancerSourceRanges(service *corev1.Service, preferredIPFamily corev1.IPFamily) (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 NewRoutes

func NewRoutes(os *OpenStack, network *gophercloud.ServiceClient, atomicRoutes bool, allowedAddressPairs bool) (cloudprovider.Routes, error)

NewRoutes creates a new instance of Routes

func PreserveGopherError

func PreserveGopherError(rawError error) error

PreserveGopherError preserves the error details delivered with the response that are explicitly discarded by dedicated error types. The gopher library, because of an unknown reason, explicitly hides the detailed error information from the response body and replaces it with a generic phrase that does not help to identify the problem anymore. This method resurrects the error message from the response body for such cases. For example for an 404 Error the provided message just tells `Resource not found`, which is not helpful, because it hides the real error information, which might be something completely different. error types from provider_client.go

func RemoveFromNodeAddresses

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

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

Types

type Config

type Config struct {
	Global            client.AuthOpts
	LoadBalancer      LoadBalancerOpts
	LoadBalancerClass map[string]*LBClass
	Route             RouterOpts
	Metadata          metadata.Opts
	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) InstanceExists

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

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

InstanceMetadata returns metadata of the specified instance.

func (*Instances) InstanceShutdown

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

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

InstancesV2 encapsulates an implementation of InstancesV2 for OpenStack.

func (*InstancesV2) InstanceExists added in v1.27.0

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

InstanceExists indicates whether a given node exists according to the cloud provider

func (*InstancesV2) InstanceMetadata added in v1.27.0

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

InstanceMetadata returns the instance's metadata.

func (*InstancesV2) InstanceShutdown added in v1.27.0

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

InstanceShutdown returns true if the instance is shutdown according to the cloud provider.

type LBClass

type LBClass struct {
	FloatingNetworkID  string `gcfg:"floating-network-id,omitempty"`
	FloatingSubnetID   string `gcfg:"floating-subnet-id,omitempty"`
	FloatingSubnet     string `gcfg:"floating-subnet,omitempty"`
	FloatingSubnetTags string `gcfg:"floating-subnet-tags,omitempty"`
	NetworkID          string `gcfg:"network-id,omitempty"`
	SubnetID           string `gcfg:"subnet-id,omitempty"`
	MemberSubnetID     string `gcfg:"member-subnet-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 based on Octavia

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

func (lbaas *LbaasV2) GetLoadBalancerName(_ 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 {
	Enabled                        bool                `gcfg:"enabled"`              // if false, disables the controller
	LBVersion                      string              `gcfg:"lb-version"`           // overrides autodetection. Only support v2.
	SubnetID                       string              `gcfg:"subnet-id"`            // overrides autodetection.
	MemberSubnetID                 string              `gcfg:"member-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.
	FloatingSubnet                 string              `gcfg:"floating-subnet"`      // If specified, will create floating ip for loadbalancer in one of the matching floating pool subnetworks.
	FloatingSubnetTags             string              `gcfg:"floating-subnet-tags"` // If specified, will create floating ip for loadbalancer in one of the matching floating pool subnetworks.
	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                   util.MyDuration     `gcfg:"monitor-delay"`
	MonitorTimeout                 util.MyDuration     `gcfg:"monitor-timeout"`
	MonitorMaxRetries              uint                `gcfg:"monitor-max-retries"`
	MonitorMaxRetriesDown          uint                `gcfg:"monitor-max-retries-down"`
	ManageSecurityGroups           bool                `gcfg:"manage-security-groups"`
	InternalLB                     bool                `gcfg:"internal-lb"` // default false
	CascadeDelete                  bool                `gcfg:"cascade-delete"`
	FlavorID                       string              `gcfg:"flavor-id"`
	AvailabilityZone               string              `gcfg:"availability-zone"`
	EnableIngressHostname          bool                `gcfg:"enable-ingress-hostname"`            // Used with proxy protocol by adding a dns suffix to the load balancer IP address. Default false.
	IngressHostnameSuffix          string              `gcfg:"ingress-hostname-suffix"`            // Used with proxy protocol by adding a dns suffix to the load balancer IP address. Default nip.io.
	MaxSharedLB                    int                 `gcfg:"max-shared-lb"`                      //  Number of Services in maximum can share a single load balancer. Default 2
	ContainerStore                 string              `gcfg:"container-store"`                    // Used to specify the store of the tls-container-ref
	ProviderRequiresSerialAPICalls bool                `gcfg:"provider-requires-serial-api-calls"` // default false, the provider supports the "bulk update" API call
	// revive:disable:var-naming
	TlsContainerRef string `gcfg:"default-tls-container-ref"` //  reference to a tls container

}

LoadBalancerOpts have the options to talk to Neutron LBaaSV2 or Octavia

type NetworkingOpts

type NetworkingOpts struct {
	IPv6SupportDisabled bool     `gcfg:"ipv6-support-disabled"`
	PublicNetworkName   []string `gcfg:"public-network-name"`
	InternalNetworkName []string `gcfg:"internal-network-name"`
	AddressSortOrder    string   `gcfg:"address-sort-order"`
}

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

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

Clusters is a no-op

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. TODO: v1 instance apis can be deleted after the v2 is verified enough

func (*OpenStack) InstancesV2

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

InstancesV2 returns an implementation of InstancesV2 for OpenStack.

func (*OpenStack) LoadBalancer

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

LoadBalancer initializes a LbaasV2 object

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) SetInformers added in v1.25.5

func (os *OpenStack) SetInformers(informerFactory informers.SharedInformerFactory)

SetInformers implements InformerUser interface by setting up informer-fed caches to leverage Kubernetes API for caching

func (*OpenStack) Zones

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

Zones indicates that we support zones

type PortWithPortSecurity added in v1.28.2

type PortWithPortSecurity struct {
	neutronports.Port
	portsecurity.PortSecurityExt
}

type PortWithTrunkDetails added in v1.28.0

type PortWithTrunkDetails struct {
	neutronports.Port
	trunk_details.TrunkDetailsExt
}

type RouterOpts

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

RouterOpts is used for Neutron routes

type Routes

type Routes struct {

	// Neutron with no "extraroute-atomic" extension can modify only one route at
	// once
	sync.Mutex
	// 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 TweakSubNetListOpsFunction

type TweakSubNetListOpsFunction func(*subnets.ListOpts)

TweakSubNetListOpsFunction is used to modify List Options for subnets

Jump to

Keyboard shortcuts

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