cloud_provider

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceAnnotationLoadBalancerPrefix is the annotation prefix of LoadBalancer
	ServiceAnnotationLoadBalancerPrefix = "service.beta.kubernetes.io/cce-load-balancer-"
	// CceAutoAddLoadBalancerId is the annotation of CCE adding LoadBalancerId
	ServiceAnnotationCceAutoAddLoadBalancerId = ServiceAnnotationLoadBalancerPrefix + "cce-add-id"
	// CceAutoAddEip is the annotation of CCE adding Eip
	ServiceAnnotationCceAutoAddEip = ServiceAnnotationLoadBalancerPrefix + "cce-add-eip"

	ServiceAnnotationLoadBalancerExistId = ServiceAnnotationLoadBalancerPrefix + "exist-id"
	// ServiceAnnotationLoadBalancerInternalVpc is the annotation of LoadBalancerInternalVpc
	ServiceAnnotationLoadBalancerInternalVpc = ServiceAnnotationLoadBalancerPrefix + "internal-vpc"
	// ServiceAnnotationLoadBalancerAllocateVip is the annotation which indicates BLB with a VIP
	ServiceAnnotationLoadBalancerAllocateVip = ServiceAnnotationLoadBalancerPrefix + "allocate-vip"
	//ServiceAnnotationLoadBalancerSubnetId is the annotation which indicates the BCC type subnet the BLB will use
	ServiceAnnotationLoadBalancerSubnetId = ServiceAnnotationLoadBalancerPrefix + "subnet-id"
	// ServiceAnnotationLoadBalancerRsMaxNum is the annotation which set max num of rs of the BLB
	ServiceAnnotationLoadBalancerRsMaxNum = ServiceAnnotationLoadBalancerPrefix + "rs-max-num"

	// TODO:
	// ServiceAnnotationLoadBalancerScheduler is the annotation of load balancer which can be "RoundRobin"/"LeastConnection"/"Hash"
	ServiceAnnotationLoadBalancerScheduler = ServiceAnnotationLoadBalancerPrefix + "scheduler"
	// TODO:
	// ServiceAnnotationLoadBalancerHealthCheckTimeoutInSecond is the annotation of health check timeout, default 3s, [1, 60]
	ServiceAnnotationLoadBalancerHealthCheckTimeoutInSecond = ServiceAnnotationLoadBalancerPrefix + "health-check-timeout-in-second"
	// TODO:
	// ServiceAnnotationLoadBalancerHealthCheckInterval is the annotation of health check interval, default 3s, [1, 10]
	ServiceAnnotationLoadBalancerHealthCheckInterval = ServiceAnnotationLoadBalancerPrefix + "health-check-interval"
	// TODO:
	// ServiceAnnotationLoadBalancerUnhealthyThreshold is the annotation of unhealthy threshold, default 3, [2, 5]
	ServiceAnnotationLoadBalancerUnhealthyThreshold = ServiceAnnotationLoadBalancerPrefix + "unhealthy-threshold"
	// TODO:
	// ServiceAnnotationLoadBalancerHealthyThreshold is the annotation of healthy threshold, default 3, [2, 5]
	ServiceAnnotationLoadBalancerHealthyThreshold = ServiceAnnotationLoadBalancerPrefix + "healthy-threshold"
	// TODO:
	// ServiceAnnotationLoadBalancerHealthCheckString is the annotation of health check string
	ServiceAnnotationLoadBalancerHealthCheckString = ServiceAnnotationLoadBalancerPrefix + "health-check-string"

	// ServiceAnnotationElasticIPPrefix is the annotation prefix of ElasticIP
	ServiceAnnotationElasticIPPrefix = "service.beta.kubernetes.io/cce-elastic-ip-"
	// ServiceAnnotationElasticIPName is the annotation of ElasticIPName
	ServiceAnnotationElasticIPName = ServiceAnnotationElasticIPPrefix + "name"
	// ServiceAnnotationElasticIPPaymentTiming is the annotation of ElasticIPPaymentTiming
	ServiceAnnotationElasticIPPaymentTiming = ServiceAnnotationElasticIPPrefix + "payment-timing"
	// ServiceAnnotationElasticIPBillingMethod is the annotation of ElasticIPBillingMethod
	ServiceAnnotationElasticIPBillingMethod = ServiceAnnotationElasticIPPrefix + "billing-method"
	// ServiceAnnotationElasticIPBandwidthInMbps is the annotation of ElasticIPBandwidthInMbps
	ServiceAnnotationElasticIPBandwidthInMbps = ServiceAnnotationElasticIPPrefix + "bandwidth-in-mbps"
	// ServiceAnnotationElasticIPReservationLength is the annotation of ElasticIPReservationLength
	ServiceAnnotationElasticIPReservationLength = ServiceAnnotationElasticIPPrefix + "reservation-length"
)
View Source
const (
	// NodeAnnotationPrefix is the annotation prefix of Node
	NodeAnnotationPrefix = "node.alpha.kubernetes.io/"
	// NodeAnnotationVpcId is the annotation of VpcId on node
	NodeAnnotationVpcId = NodeAnnotationPrefix + "vpc-id"
	// NodeAnnotationVpcRouteTableId is the annotation of VpcRouteTableId on node
	NodeAnnotationVpcRouteTableId = NodeAnnotationPrefix + "vpc-route-table-id"
	// NodeAnnotationVpcRouteRuleId is the annotation of VpcRouteRuleId on node
	NodeAnnotationVpcRouteRuleId = NodeAnnotationPrefix + "vpc-route-rule-id"

	// NodeAnnotationCCMVersion is the version of CCM
	NodeAnnotationCCMVersion = NodeAnnotationPrefix + "ccm-version"

	// NodeAnnotationAdvertiseRoute indicates whether to advertise route to vpc route table
	NodeAnnotationAdvertiseRoute = NodeAnnotationPrefix + "advertise-route"
)
View Source
const BLBMaxRSNum int = 50
View Source
const CceUserAgent = "cce-k8s:"

CceUserAgent is prefix of http header UserAgent

View Source
const DefaultBLBRSWeight int = 100
View Source
const ProviderName = "cce"

ProviderName is the name of this cloud provider.

Variables

View Source
var CCMVersion string

CCMVersion is the version of CCM

Functions

func AddressCount added in v1.0.9

func AddressCount(network *net.IPNet) uint64

AddressCount returns the number of distinct host addresses within the given CIDR range.

Since the result is a uint64, this function returns meaningful information only for IPv4 ranges and IPv6 ranges with a prefix size of at least 65.

func AddressRange added in v1.0.9

func AddressRange(network *net.IPNet) (net.IP, net.IP)

AddressRange returns the first and last addresses in the given CIDR range.

func Dec added in v1.0.9

func Dec(IP net.IP) net.IP

Dec decreases the IP by one this returns a new []byte for the IP

func Host added in v1.0.9

func Host(base *net.IPNet, num int) (net.IP, error)

Host takes a parent CIDR range and turns it into a host IP address with the given host number.

For example, 10.3.0.0/16 with a host number of 2 gives 10.3.0.2.

func Inc added in v1.0.9

func Inc(IP net.IP) net.IP

Inc increases the IP by one this returns a new []byte for the IP

func NextSubnet added in v1.0.9

func NextSubnet(network *net.IPNet, prefixLen int) (*net.IPNet, bool)

NextSubnet returns the next available subnet of the desired mask size starting for the maximum IP of the offset subnet If the IP exceeds the maxium IP then the second return value is true

func PreviousSubnet added in v1.0.9

func PreviousSubnet(network *net.IPNet, prefixLen int) (*net.IPNet, bool)

PreviousSubnet returns the subnet of the desired mask in the IP space just lower than the start of IPNet provided. If the IP space rolls over then the second return value is true

func Subnet added in v1.0.9

func Subnet(base *net.IPNet, newBits int, num int) (*net.IPNet, error)

Subnet takes a parent CIDR range and creates a subnet within it with the given number of additional prefix bits and the given network number.

For example, 10.3.0.0/16, extended by 8 bits, with a network number of 5, becomes 10.3.5.0/24 .

func VerifyNoOverlap added in v1.0.9

func VerifyNoOverlap(subnets []*net.IPNet, CIDRBlock *net.IPNet) error

VerifyNoOverlap takes a list subnets and supernet (CIDRBlock) and verifies none of the subnets overlap and all subnets are in the supernet it returns an error if any of those conditions are not satisfied

Types

type Baiducloud added in v1.0.4

type Baiducloud struct {
	CloudConfig
	// contains filtered or unexported fields
}

Baiducloud defines the main struct

func (*Baiducloud) AddSSHKeyToAllInstances added in v1.0.4

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

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 (*Baiducloud) Clusters added in v1.0.4

func (bc *Baiducloud) Clusters() (cloudprovider.Clusters, bool)

Clusters returns a clusters interface. Also returns true if the interface is supported, false otherwise.

func (*Baiducloud) CreateRoute added in v1.0.4

func (bc *Baiducloud) CreateRoute(ctx context.Context, clusterName string, nameHint string, kubeRoute *cloudprovider.Route) error

CreateRoute creates the described managed route route.Name will be ignored, although the cloud-provider may use nameHint to create a more user-meaningful name.

func (*Baiducloud) CurrentNodeName added in v1.0.4

func (bc *Baiducloud) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error)

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 (*Baiducloud) DeleteEipFinally added in v1.0.12

func (bc *Baiducloud) DeleteEipFinally(service *v1.Service, result *ServiceAnnotation, lb *blb.LoadBalancer, serviceName, clusterName string) error

func (*Baiducloud) DeleteRoute added in v1.0.4

func (bc *Baiducloud) DeleteRoute(ctx context.Context, clusterName string, kubeRoute *cloudprovider.Route) error

DeleteRoute deletes the specified managed route Route should be as returned by ListRoutes

func (*Baiducloud) EnsureLoadBalancer added in v1.0.4

func (bc *Baiducloud) 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 (*Baiducloud) EnsureLoadBalancerDeleted added in v1.0.4

func (bc *Baiducloud) 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 (*Baiducloud) GetLoadBalancer added in v1.0.4

func (bc *Baiducloud) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (status *v1.LoadBalancerStatus, exists bool, err 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 (*Baiducloud) GetZone added in v1.0.4

func (bc *Baiducloud) GetZone(ctx context.Context) (cloudprovider.Zone, error)

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 (*Baiducloud) GetZoneByNodeName added in v1.0.4

func (bc *Baiducloud) 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 down outside the kubelets.

func (*Baiducloud) GetZoneByProviderID added in v1.0.4

func (bc *Baiducloud) 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 down outside the kubelets.

func (*Baiducloud) HasClusterID added in v1.0.4

func (bc *Baiducloud) HasClusterID() bool

HasClusterID returns true if a ClusterID is required and set

func (*Baiducloud) Initialize added in v1.0.4

func (bc *Baiducloud) Initialize(clientBuilder controller.ControllerClientBuilder)

Initialize provides the cloud with a kubernetes client builder and may spawn goroutines to perform housekeeping activities within the cloud provider.

func (*Baiducloud) InstanceExistsByProviderID added in v1.0.4

func (bc *Baiducloud) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error)

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

func (*Baiducloud) InstanceID added in v1.0.4

func (bc *Baiducloud) InstanceID(ctx context.Context, name types.NodeName) (string, error)

InstanceID returns the cloud provider ID of the node with the specified NodeName. Note that if the instance does not exist or is no longer running, we must return ("", cloudprovider.InstanceNotFound)

func (*Baiducloud) InstanceShutdownByProviderID added in v1.0.4

func (bc *Baiducloud) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)

InstanceShutdownByProviderID returns true if the instance is shutdown in cloudprovider

func (*Baiducloud) InstanceType added in v1.0.4

func (bc *Baiducloud) InstanceType(ctx context.Context, name types.NodeName) (string, error)

InstanceType returns the type of the specified instance.

func (*Baiducloud) InstanceTypeByProviderID added in v1.0.4

func (bc *Baiducloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error)

InstanceTypeByProviderID returns the type of the specified instance.

func (*Baiducloud) Instances added in v1.0.4

func (bc *Baiducloud) Instances() (cloudprovider.Instances, bool)

Instances returns an instances interface. Also returns true if the interface is supported, false otherwise.

func (*Baiducloud) ListClusters added in v1.0.4

func (bc *Baiducloud) ListClusters(ctx context.Context) ([]string, error)

ListClusters lists the names of the available clusters.

func (*Baiducloud) ListRoutes added in v1.0.4

func (bc *Baiducloud) ListRoutes(ctx context.Context, clusterName string) (routes []*cloudprovider.Route, err error)

ListRoutes lists all managed routes that belong to the specified clusterName

func (*Baiducloud) LoadBalancer added in v1.0.4

func (bc *Baiducloud) LoadBalancer() (cloudprovider.LoadBalancer, bool)

LoadBalancer returns a balancer interface. Also returns true if the interface is supported, false otherwise.

func (*Baiducloud) Master added in v1.0.4

func (bc *Baiducloud) Master(ctx context.Context, clusterName string) (string, error)

Master gets back the address (either DNS name or IP address) of the master node for the cluster.

func (*Baiducloud) NodeAddresses added in v1.0.4

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

NodeAddresses returns the addresses of the specified instance. TODO(roberthbailey): This currently is only used in such a way that it returns the address of the calling instance. We should do a rename to make this clearer.

func (*Baiducloud) NodeAddressesByProviderID added in v1.0.4

func (bc *Baiducloud) 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 (*Baiducloud) ProviderName added in v1.0.4

func (bc *Baiducloud) ProviderName() string

ProviderName returns the cloud provider ID.

func (*Baiducloud) Routes added in v1.0.4

func (bc *Baiducloud) Routes() (cloudprovider.Routes, bool)

Routes returns a routes interface along with whether the interface is supported.

func (*Baiducloud) SetInformers added in v1.0.4

func (bc *Baiducloud) SetInformers(informerFactory informers.SharedInformerFactory)

SetInformers sets the informer on the cloud object.

func (*Baiducloud) UpdateLoadBalancer added in v1.0.4

func (bc *Baiducloud) 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 (*Baiducloud) Zones added in v1.0.4

func (bc *Baiducloud) Zones() (cloudprovider.Zones, bool)

Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.

type CloudConfig

type CloudConfig struct {
	ClusterID       string `json:"ClusterId"`
	ClusterName     string `json:"ClusterName"`
	AccessKeyID     string `json:"AccessKeyID"`
	SecretAccessKey string `json:"SecretAccessKey"`
	Region          string `json:"Region"`
	VpcID           string `json:"VpcId"`
	SubnetID        string `json:"SubnetId"`
	MasterID        string `json:"MasterId"`
	Endpoint        string `json:"Endpoint"`
	NodeIP          string `json:"NodeIP"`
	Debug           bool   `json:"Debug"`
}

CloudConfig is the cloud config

type NodeAnnotation added in v1.0.4

type NodeAnnotation struct {
	VpcId           string
	VpcRouteTableId string
	VpcRouteRuleId  string
	CCMVersion      string
	AdvertiseRoute  bool
}

NodeAnnotation contains annotations from node

func ExtractNodeAnnotation added in v1.0.4

func ExtractNodeAnnotation(node *v1.Node) (*NodeAnnotation, error)

ExtractNodeAnnotation extract annotations from node

type PortListener

type PortListener struct {
	Port     int
	Protocol string
	NodePort int32
}

PortListener describe listener port

type ServiceAnnotation added in v1.0.4

type ServiceAnnotation struct {
	/* BLB */
	CceAutoAddLoadBalancerId string
	CceAutoAddEip            string
	LoadBalancerExistId      string
	LoadBalancerInternalVpc  string
	LoadBalancerAllocateVip  string
	LoadBalancerSubnetId     string
	LoadBalancerScheduler    string
	LoadBalancerRsMaxNum     int

	LoadBalancerHealthCheckTimeoutInSecond int
	LoadBalancerHealthCheckInterval        int
	LoadBalancerUnhealthyThreshold         int
	LoadBalancerHealthyThreshold           int
	LoadBalancerHealthCheckString          string

	/* EIP */
	ElasticIPName              string
	ElasticIPPaymentTiming     string
	ElasticIPBillingMethod     string
	ElasticIPBandwidthInMbps   int
	ElasticIPReservationLength int
}

ServiceAnnotation contains annotations from service

func ExtractServiceAnnotation added in v1.0.4

func ExtractServiceAnnotation(service *v1.Service) (*ServiceAnnotation, error)

ExtractServiceAnnotation extract annotations from service

Jump to

Keyboard shortcuts

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