cloud_provider

package
v0.0.0-...-b13e5c6 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceAnnotationLoadBalancerPrefix is the annotation prefix of LoadBalancer
	ServiceAnnotationLoadBalancerPrefix = "service.beta.kubernetes.io/linkedcare-load-balancer-"

	ServiceAnnotationLoadBalancerId = ServiceAnnotationLoadBalancerPrefix + "id"
)
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 ProviderName = "alicloud"

ProviderName is the name of this cloud provider.

Variables

View Source
var (

	// DEFAULT_BANDWIDTH default bandwidth
	DEFAULT_BANDWIDTH = 100

	DEFAULT_NODE_MONITOR_PERIOD = 120 * time.Second

	DEFAULT_NODE_ADDR_SYNC_PERIOD = 240 * time.Second
)
View Source
var CCMVersion string

CCMVersion is the version of CCM

View Source
var CLUSTER_ID = "clusterid"

CLUSTER_ID default cluster id if it is not specified.

View Source
var KUBERNETES_ALICLOUD_IDENTITY = fmt.Sprintf("Kubernetes.Alicloud/%s", version.Get().String())

KUBERNETES_ALICLOUD_IDENTITY is for statistic purpose.

Functions

func AddressCount

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

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

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

func BuildVirturalGroupFromService

func BuildVirturalGroupFromService(s *LoadBalancerClient, service *v1.Service, nodes []*v1.Node, lbsId string) error

func Dec

func Dec(IP net.IP) net.IP

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

func Host

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

func Inc(IP net.IP) net.IP

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

func NextSubnet

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 NodeList

func NodeList(nodes []*v1.Node) []string

NodeList return nodes list in string

func PreviousSubnet

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

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

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 ClientMgr

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

func NewClientMgr

func NewClientMgr(region, key, secret string) (*ClientMgr, error)

NewClientMgr return a new client manager

func (*ClientMgr) Instances

func (mgr *ClientMgr) Instances() *InstanceClient

Instances return instance client

func (*ClientMgr) LoadBalancers

func (mgr *ClientMgr) LoadBalancers() *LoadBalancerClient

LoadBalancers return loadbalancer client

type Cloud

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

Cloud defines the main struct

func (*Cloud) AddSSHKeyToAllInstances

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

func (*Cloud) Clusters

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

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

func (*Cloud) CreateRoute

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

func (*Cloud) CurrentNodeName

func (c *Cloud) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error)

Doing

func (*Cloud) DeleteRoute

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

func (*Cloud) EnsureLoadBalancer

func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error)

func (*Cloud) EnsureLoadBalancerDeleted

func (c *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error

func (*Cloud) GetLoadBalancer

func (c *Cloud) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (status *v1.LoadBalancerStatus, exists bool, err error)

func (*Cloud) GetLoadBalancerName

func (c *Cloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string

func (*Cloud) GetZone

func (c *Cloud) GetZone(ctx context.Context) (cloudprovider.Zone, error)

func (*Cloud) GetZoneByNodeName

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

func (*Cloud) GetZoneByProviderID

func (c *Cloud) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error)

func (*Cloud) HasClusterID

func (bc *Cloud) HasClusterID() bool

HasClusterID returns true if a ClusterID is required and set

func (*Cloud) Initialize

func (c *Cloud) Initialize(builder controller.ControllerClientBuilder)

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

func (*Cloud) InstanceExistsByProviderID

func (c *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID string, ip string) (bool, error)

func (*Cloud) InstanceID

func (c *Cloud) InstanceID(ctx context.Context, nodeName types.NodeName) (string, error)

func (*Cloud) InstanceShutdownByProviderID

func (c *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID string) (bool, error)

TODO

func (*Cloud) InstanceType

func (c *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string, error)

func (*Cloud) InstanceTypeByProviderID

func (c *Cloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error)

func (*Cloud) Instances

func (c *Cloud) Instances() (cloudprovider.Instances, bool)

func (*Cloud) ListClusters

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

ListClusters lists the names of the available clusters.

func (*Cloud) ListRoutes

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

func (*Cloud) LoadBalancer

func (c *Cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool)

func (*Cloud) Master

func (bc *Cloud) 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 (*Cloud) NodeAddresses

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

func (*Cloud) NodeAddressesByProviderID

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

func (*Cloud) ProviderName

func (c *Cloud) ProviderName() string

func (*Cloud) Routes

func (c *Cloud) Routes() (cloudprovider.Routes, bool)

****************routes******************

func (*Cloud) UpdateLoadBalancer

func (c *Cloud) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error

func (*Cloud) Zones

func (c *Cloud) Zones() (cloudprovider.Zones, bool)

****************zones******************

type CloudConfig

type CloudConfig struct {
	UID             string `json:"uid"`
	ClusterID       string `json:"ClusterId"`
	ClusterName     string `json:"ClusterName"`
	AccessKeyID     string `json:"AccessKeyID"`
	AccessKeySecret string `json:"AccessKeySecret"`
	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 InstanceClient

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

type LoadBalancerClient

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

type NodeAnnotation

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

NodeAnnotation contains annotations from node

func ExtractNodeAnnotation

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

ExtractNodeAnnotation extract annotations from node

type ServiceAnnotation

type ServiceAnnotation struct {
	/* BLB */
	Loadbalancerid string
}

ServiceAnnotation contains annotations from service

func ExtractServiceAnnotation

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

ExtractServiceAnnotation extract annotations from service

type VsgBackendServer

type VsgBackendServer struct {
	ServerId    string `json: "ServerId"`
	Weight      string `json:"Weight"`
	Type        string `json:"Type"`
	Port        string `json:"Port"`
	Description string `json:"Description"`
}

Jump to

Keyboard shortcuts

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