cloud

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: Apache-2.0 Imports: 11 Imported by: 10

Documentation

Index

Constants

View Source
const ControllerTagKey = "KipControllerID"
View Source
const MilpaAPISGName = "CellSecurityGroup"
View Source
const NameTagKey = "Name"
View Source
const NamespaceTagKey = "KipNamespace"
View Source
const NametagTagKey = "KipNametag"
View Source
const PodNameTagKey = "KipPodName"
View Source
const ProviderAWS = "aws"
View Source
const ProviderAzure = "azure"
View Source
const ProviderGCE = "gce"
View Source
const PublicCIDR = "0.0.0.0/0"
View Source
const RestAPIPort = 6421

Variables

This section is empty.

Functions

func MergeSecurityGroups

func MergeSecurityGroups(cloudSG SecurityGroup, specPorts []InstancePort, specSourceRanges []string) ([]IngressRule, []IngressRule)

func SortImagesByCreationTime

func SortImagesByCreationTime(images []Image)

func ToSaneVolumeSize

func ToSaneVolumeSize(volSizeSpec string) int32

Types

type AZSubnetStatus

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

func NewAZSubnetStatus

func NewAZSubnetStatus(client CloudClient) (*AZSubnetStatus, error)

func (*AZSubnetStatus) AddUnavailableInstance

func (s *AZSubnetStatus) AddUnavailableInstance(instanceType string, spot bool)

func (*AZSubnetStatus) AddUnavailableSubnet

func (s *AZSubnetStatus) AddUnavailableSubnet(instanceType string, spot bool, subnetID string)

func (*AZSubnetStatus) AddUnavailableZone

func (s *AZSubnetStatus) AddUnavailableZone(instanceType string, spot bool, zone string)

func (*AZSubnetStatus) Dump

func (s *AZSubnetStatus) Dump() []byte

func (*AZSubnetStatus) GetAllAvailabilityZones

func (s *AZSubnetStatus) GetAllAvailabilityZones() []string

func (*AZSubnetStatus) GetAllSubnets

func (s *AZSubnetStatus) GetAllSubnets() []SubnetAttributes

func (*AZSubnetStatus) GetAvailableSubnets

func (s *AZSubnetStatus) GetAvailableSubnets(instanceType string, spot, privateIP bool) []SubnetAttributes

func (*AZSubnetStatus) GetAvailableZones

func (s *AZSubnetStatus) GetAvailableZones(instanceType string, spot bool, privateIP bool) []string

func (*AZSubnetStatus) IsUnavailableSubnet

func (s *AZSubnetStatus) IsUnavailableSubnet(instanceType string, spot bool, subnetID string) bool

func (*AZSubnetStatus) IsUnavailableZone

func (s *AZSubnetStatus) IsUnavailableZone(instanceType string, spot, privateIP bool, az string) bool

In

func (*AZSubnetStatus) Start

func (s *AZSubnetStatus) Start()

func (*AZSubnetStatus) Stop

func (s *AZSubnetStatus) Stop()

func (*AZSubnetStatus) SupportsAvailabilityZones

func (s *AZSubnetStatus) SupportsAvailabilityZones() bool

type BootImageSpec

type BootImageSpec map[string]string

func (*BootImageSpec) String

func (bis *BootImageSpec) String() string

type CloudAttributes

type CloudAttributes struct {
	DiskProductName api.StorageType
	FixedSizeVolume bool
	Provider        string
	Region          string
	Zone            string
}

type CloudClient

type CloudClient interface {
	SetBootSecurityGroupIDs([]string)
	GetBootSecurityGroupIDs() []string
	StartNode(*api.Node, Image, string) (*StartNodeResult, error)
	StartSpotNode(*api.Node, Image, string) (*StartNodeResult, error)
	// This should always be called from a goroutine as it can take a while
	StopInstance(instanceID string) error
	WaitForRunning(node *api.Node) ([]api.NetworkAddress, error)
	EnsureMilpaSecurityGroups([]string, []string) error
	AttachSecurityGroups(node *api.Node, groups []string) error
	AddIAMPermissions(node *api.Node, permissions string) error
	ListInstancesFilterID([]string) ([]CloudInstance, error)
	ListInstances() ([]CloudInstance, error)
	ResizeVolume(node *api.Node, size int64) (error, bool)
	GetRegistryAuth() (string, string, error)
	GetImage(spec BootImageSpec) (Image, error)
	SetSustainedCPU(*api.Node, bool) error
	AddInstanceTags(string, map[string]string) error
	ConnectWithPublicIPs() bool
	ModifySourceDestinationCheck(string, bool) error
	RemoveRoute(string, string) error
	AddRoute(string, string) error
	GetVPCCIDRs() []string
	GetDNSInfo() ([]string, []string, error)
	CloudStatusKeeper() StatusKeeper
	GetSubnets() ([]SubnetAttributes, error)
	GetAvailabilityZones() ([]string, error)
	GetAttributes() CloudAttributes
	IsAvailable() (bool, error)
}

type CloudInstance

type CloudInstance struct {
	ID       string
	NodeName string
}

type ContainerInstance

type ContainerInstance struct {
	ID string
}

type Image

type Image struct {
	ID           string
	Name         string
	RootDevice   string
	CreationTime *time.Time
}

type IngressRule

type IngressRule struct {
	Port          int
	PortRangeSize int
	Protocol      api.Protocol
	Source        string
}

Diffing rules got a little nasty... We take the cross of the service ports and sourceRanges and each value becomes an IngressRule

func MakeIngressRules

func MakeIngressRules(ports []InstancePort, sourceRanges []string) []IngressRule

func NewIngressRule

func NewIngressRule(port InstancePort, source string) IngressRule

type InstancePort

type InstancePort struct {
	// Name of the Service port.
	Name string `json:"name"`
	// Protocol. Can be "TCP", "UDP" or "ICMP".
	Protocol api.Protocol `json:"protocol"`
	// Port number. Not used for "ICMP".
	Port int `json:"port"`
	// portRangeSize is the contiguous ports number that are exposed
	// by this service. Given port = 80 and portRangeSize = 100, the
	// InstancePort will represent a range of ports from 80-179 (100
	// ports in total). In this case, port means the starting port of
	// a range.
	PortRangeSize int `json:"portRangeSize,omitempty"`
}

Service port definition. This is a TCP or UDP port that a Service uses.

type LinkedAZSubnetStatus

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

func NewLinkedAZSubnetStatus

func NewLinkedAZSubnetStatus(client CloudClient) (*LinkedAZSubnetStatus, error)

func (*LinkedAZSubnetStatus) AddUnavailableInstance

func (s *LinkedAZSubnetStatus) AddUnavailableInstance(instanceType string, spot bool)

func (*LinkedAZSubnetStatus) AddUnavailableSubnet

func (s *LinkedAZSubnetStatus) AddUnavailableSubnet(instanceType string, spot bool, subnetID string)

func (*LinkedAZSubnetStatus) AddUnavailableZone

func (s *LinkedAZSubnetStatus) AddUnavailableZone(instanceType string, spot bool, zone string)

func (*LinkedAZSubnetStatus) Dump

func (s *LinkedAZSubnetStatus) Dump() []byte

func (*LinkedAZSubnetStatus) GetAllAZSubnets

func (s *LinkedAZSubnetStatus) GetAllAZSubnets(zone string, privateIP bool) []SubnetAttributes

Used in validation to figure out if a pod has a valid spec -- only valid in Amazon Cloud

func (*LinkedAZSubnetStatus) GetAllSubnets

func (s *LinkedAZSubnetStatus) GetAllSubnets() []SubnetAttributes

func (*LinkedAZSubnetStatus) GetAvailableAZSubnets

func (s *LinkedAZSubnetStatus) GetAvailableAZSubnets(instanceType, zone string, spot, privateIP bool) []SubnetAttributes

Only used in AWS, not part of the StatusKeeper interface

func (*LinkedAZSubnetStatus) GetAvailableSubnets

func (s *LinkedAZSubnetStatus) GetAvailableSubnets(instanceType string, spot, privateIP bool) []SubnetAttributes

func (*LinkedAZSubnetStatus) GetAvailableZones

func (s *LinkedAZSubnetStatus) GetAvailableZones(instanceType string, spot bool, privateIP bool) []string

func (*LinkedAZSubnetStatus) IsUnavailableSubnet

func (s *LinkedAZSubnetStatus) IsUnavailableSubnet(instanceType string, spot bool, subnetID string) bool

func (*LinkedAZSubnetStatus) IsUnavailableZone

func (s *LinkedAZSubnetStatus) IsUnavailableZone(instanceType string, spot, privateIP bool, az string) bool

func (*LinkedAZSubnetStatus) Start

func (s *LinkedAZSubnetStatus) Start()

func (*LinkedAZSubnetStatus) Stop

func (s *LinkedAZSubnetStatus) Stop()

func (*LinkedAZSubnetStatus) SupportsAvailabilityZones

func (s *LinkedAZSubnetStatus) SupportsAvailabilityZones() bool

type LoadBalancer

type LoadBalancer struct {
	Type             string
	ServiceName      string
	LoadBalancerName string
	Instances        sets.String
	Ports            []InstancePort
	SecurityGroupID  string
	Internal         bool
	Annotations      map[string]string
	DNSName          string
	IPAddress        string
}

type MockCloudClient

type MockCloudClient struct {
	Instances          map[string]CloudInstance
	ContainerInstances map[string]ContainerInstance

	ControllerID string
	InsideVPC    bool
	VPCCIDRs     []string
	Subnets      []SubnetAttributes

	Starter             func(node *api.Node, image Image, metadata string) (*StartNodeResult, error)
	SpotStarter         func(node *api.Node, image Image, metadata string) (*StartNodeResult, error)
	Stopper             func(instanceID string) error
	Waiter              func(node *api.Node) ([]api.NetworkAddress, error)
	Lister              func() ([]CloudInstance, error)
	Resizer             func(node *api.Node, size int64) (error, bool)
	ContainerAuthorizer func() (string, string, error)
	ImageGetter         func(BootImageSpec) (Image, error)

	InstanceListerFilter func([]string) ([]CloudInstance, error)
	InstanceLister       func() ([]CloudInstance, error)

	DNSInfoGetter func() ([]string, []string, error)

	RouteRemover func(string, string) error
	RouteAdder   func(string, string) error

	StatusKeeperGetter func() StatusKeeper
	SubnetGetter       func() ([]SubnetAttributes, error)
	AZGetter           func() ([]string, error)

	AvailabilityChecker func() (bool, error)

	// Container Instance Funcs
	ContainerClusterEnsurer          func() error
	ContainerInstanceLister          func() ([]ContainerInstance, error)
	ContainerInstanceListerFilter    func(instIDs []string) ([]ContainerInstance, error)
	ContainerInstancesStatusesGetter func(instIDs []string) (map[string][]api.UnitStatus, error)
	ContainerInstanceRunner          func(*api.Pod) (string, error)
	ContainerInstanceStopper         func(string) error
	ContainerInstanceWaiter          func(*api.Pod) (*api.Pod, error)
}

func NewMockClient

func NewMockClient() *MockCloudClient

func (*MockCloudClient) AddIAMPermissions added in v0.0.15

func (m *MockCloudClient) AddIAMPermissions(node *api.Node, permissions string) error

func (*MockCloudClient) AddInstanceTags

func (m *MockCloudClient) AddInstanceTags(string, map[string]string) error

func (*MockCloudClient) AddInstances

func (e *MockCloudClient) AddInstances(insts ...CloudInstance)

func (*MockCloudClient) AddRoute

func (e *MockCloudClient) AddRoute(destinationCIDR, instanceID string) error

func (*MockCloudClient) AttachSecurityGroups

func (m *MockCloudClient) AttachSecurityGroups(node *api.Node, groups []string) error

func (*MockCloudClient) CloudStatusKeeper

func (c *MockCloudClient) CloudStatusKeeper() StatusKeeper

func (*MockCloudClient) ConnectWithPublicIPs

func (e *MockCloudClient) ConnectWithPublicIPs() bool

func (*MockCloudClient) CreateSGName

func (e *MockCloudClient) CreateSGName(svcName string) string

func (*MockCloudClient) EnsureContainerInstanceCluster

func (m *MockCloudClient) EnsureContainerInstanceCluster() error

func (*MockCloudClient) EnsureMilpaSecurityGroups

func (c *MockCloudClient) EnsureMilpaSecurityGroups([]string, []string) error

func (*MockCloudClient) GetAttributes

func (m *MockCloudClient) GetAttributes() CloudAttributes

func (*MockCloudClient) GetAvailabilityZones

func (c *MockCloudClient) GetAvailabilityZones() ([]string, error)

func (*MockCloudClient) GetBootSecurityGroupIDs

func (m *MockCloudClient) GetBootSecurityGroupIDs() []string

func (*MockCloudClient) GetContainerInstancesStatuses

func (m *MockCloudClient) GetContainerInstancesStatuses(instIDs []string) (map[string][]api.UnitStatus, error)

func (*MockCloudClient) GetDNSInfo

func (e *MockCloudClient) GetDNSInfo() ([]string, []string, error)

func (*MockCloudClient) GetImage added in v0.0.3

func (m *MockCloudClient) GetImage(spec BootImageSpec) (Image, error)

func (*MockCloudClient) GetRegistryAuth

func (m *MockCloudClient) GetRegistryAuth() (string, string, error)

func (*MockCloudClient) GetSubnets

func (c *MockCloudClient) GetSubnets() ([]SubnetAttributes, error)

func (*MockCloudClient) GetVPCCIDRs

func (e *MockCloudClient) GetVPCCIDRs() []string

func (*MockCloudClient) IsAvailable

func (c *MockCloudClient) IsAvailable() (bool, error)

func (*MockCloudClient) ListContainerInstances

func (m *MockCloudClient) ListContainerInstances() ([]ContainerInstance, error)

func (*MockCloudClient) ListContainerInstancesFilterID

func (m *MockCloudClient) ListContainerInstancesFilterID(insts []string) ([]ContainerInstance, error)

func (*MockCloudClient) ListInstances

func (c *MockCloudClient) ListInstances() ([]CloudInstance, error)

func (*MockCloudClient) ListInstancesFilterID

func (c *MockCloudClient) ListInstancesFilterID(iid []string) ([]CloudInstance, error)

func (*MockCloudClient) ModifySourceDestinationCheck

func (e *MockCloudClient) ModifySourceDestinationCheck(iid string, enable bool) error

func (*MockCloudClient) RemoveRoute

func (e *MockCloudClient) RemoveRoute(destinationCIDR, nextHop string) error

func (*MockCloudClient) ResizeVolume

func (m *MockCloudClient) ResizeVolume(node *api.Node, size int64) (error, bool)

func (*MockCloudClient) SetBootSecurityGroupIDs

func (m *MockCloudClient) SetBootSecurityGroupIDs([]string)

func (*MockCloudClient) SetSustainedCPU

func (m *MockCloudClient) SetSustainedCPU(n *api.Node, enabled bool) error

func (*MockCloudClient) StartContainerInstance

func (m *MockCloudClient) StartContainerInstance(pod *api.Pod) (string, error)

func (*MockCloudClient) StartNode

func (m *MockCloudClient) StartNode(node *api.Node, image Image, metadata string) (*StartNodeResult, error)

func (*MockCloudClient) StartSpotNode

func (m *MockCloudClient) StartSpotNode(node *api.Node, image Image, metadata string) (*StartNodeResult, error)

func (*MockCloudClient) StopContainerInstance

func (m *MockCloudClient) StopContainerInstance(instID string) error

func (*MockCloudClient) StopInstance

func (m *MockCloudClient) StopInstance(instanceID string) error

func (*MockCloudClient) WaitForContainerInstanceRunning

func (m *MockCloudClient) WaitForContainerInstanceRunning(pod *api.Pod) (*api.Pod, error)

func (*MockCloudClient) WaitForRunning

func (m *MockCloudClient) WaitForRunning(node *api.Node) ([]api.NetworkAddress, error)

type NoCapacityError

type NoCapacityError struct {
	// If both AZ and SubnetID are empty, we have no capacity
	// for this instance in the entire region
	OriginalError string
	AZ            string
	SubnetID      string
}

func (*NoCapacityError) Error

func (e *NoCapacityError) Error() string

type SecurityGroup

type SecurityGroup struct {
	ID           string
	Name         string
	Ports        []InstancePort
	SourceRanges []string
}

func NewSecurityGroup

func NewSecurityGroup(id, name string, ports []InstancePort, sources []string) SecurityGroup

type SecurityGroupIdentifier

type SecurityGroupIdentifier struct {
	ID   string
	Name string
}

List instances only gives us security identifier

type SortableSliceOfPorts

type SortableSliceOfPorts []InstancePort

Allow ports to be sorted

func (SortableSliceOfPorts) Len

func (p SortableSliceOfPorts) Len() int

func (SortableSliceOfPorts) Less

func (p SortableSliceOfPorts) Less(i, j int) bool

func (SortableSliceOfPorts) Swap

func (p SortableSliceOfPorts) Swap(i, j int)

type StartNodeResult

type StartNodeResult struct {
	InstanceID       string
	AvailabilityZone string
}

type StatusKeeper

type StatusKeeper interface {
	Start()
	Stop()
	Dump() []byte
	SupportsAvailabilityZones() bool
	GetAllSubnets() []SubnetAttributes
	GetAvailableZones(instanceType string, spot bool, privateIP bool) []string
	GetAvailableSubnets(instanceType string, spot, privateIP bool) []SubnetAttributes
	AddUnavailableInstance(instanceType string, spot bool)
	AddUnavailableZone(instanceType string, spot bool, zone string)
	AddUnavailableSubnet(instanceType string, spot bool, subnetID string)
	IsUnavailableZone(instanceType string, spot, privateIP bool, az string) bool
}

Status is a structure that details the layout of the cloud environment and also includes info on transient state of instance availability Various parts of the system need to know what is available and where or whether they can create nodes in subnets. This is used to figure that out. The node controller also catches errors from node starts and writes availability here. Reads can come from any goroutine, subnets are protected by a mutex TimeoutMaps have mutexes built into them.

type SubnetAddressAffinity

type SubnetAddressAffinity string
const (
	PublicAddress  SubnetAddressAffinity = "Public"
	PrivateAddress SubnetAddressAffinity = "Private"
	AnyAddress     SubnetAddressAffinity = "Any"
)

type SubnetAttributes

type SubnetAttributes struct {
	Name string
	ID   string
	CIDR string
	AZ   string
	// In AWS subnets we use the subnets private/public address by default
	// flag to decide where to launch public and private nodes.  We store
	// that info in AddressAffinity.  In Azure, it's likely we don't have
	// that type of affinity (there's some interesting NAT options in azure)
	// so we don't really care what subnet our public and private addresses
	// go in.  Also, this is half baked so if you have an idea of a better
	// way to specify placement, knock yourself out.
	AddressAffinity SubnetAddressAffinity
	// In AWS and Azure (pretty sure...), we can get availability
	// stats However, they're harder to come by in GCE.  That said, in
	// GCE you can resize your subnets and we can always query
	// instances and bucket them.
	AvailableAddresses int
}

type UnsupportedInstanceError

type UnsupportedInstanceError struct {
	OriginalError string
}

func (*UnsupportedInstanceError) Error

func (e *UnsupportedInstanceError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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