cns

package
v1.4.12 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 17 Imported by: 7

Documentation

Index

Constants

View Source
const (
	SetOrchestratorType                      = "/network/setorchestratortype"
	CreateOrUpdateNetworkContainer           = "/network/createorupdatenetworkcontainer"
	DeleteNetworkContainer                   = "/network/deletenetworkcontainer"
	GetNetworkContainerStatus                = "/network/getnetworkcontainerstatus"
	PublishNetworkContainer                  = "/network/publishnetworkcontainer"
	UnpublishNetworkContainer                = "/network/unpublishnetworkcontainer"
	GetInterfaceForContainer                 = "/network/getinterfaceforcontainer"
	GetNetworkContainerByOrchestratorContext = "/network/getnetworkcontainerbyorchestratorcontext"
	AttachContainerToNetwork                 = "/network/attachcontainertonetwork"
	DetachContainerFromNetwork               = "/network/detachcontainerfromnetwork"
	RequestIPConfig                          = "/network/requestipconfig"
	ReleaseIPConfig                          = "/network/releaseipconfig"
	DebugIPAddresses                         = "/debug/ipaddresses"
	DebugPodContext                          = "/debug/podcontext"
	DebugRestData                            = "/debug/restdata"
)

Container Network Service DNC Contract

View Source
const (
	AzureContainerInstance = "AzureContainerInstance"
	WebApps                = "WebApps"
	Docker                 = "Docker"
	Basic                  = "Basic"
	JobObject              = "JobObject"
	COW                    = "COW" // Container on Windows
)

NetworkContainer Types

View Source
const (
	Kubernetes      = "Kubernetes"
	ServiceFabric   = "ServiceFabric"
	Batch           = "Batch"
	DBforPostgreSQL = "DBforPostgreSQL"
	AzureFirstParty = "AzureFirstParty"
	KubernetesCRD   = "KubernetesCRD"
)

Orchestrator Types

View Source
const (
	Vlan  = "Vlan"
	Vxlan = "Vxlan"
)

Encap Types

View Source
const (
	Direct         = "Direct"
	Managed        = "Managed"
	CRD            = "CRD"
	MultiTenantCRD = "MultiTenantCRD"
)

ChannelMode :- CNS channel modes

View Source
const (
	KubernetesPodInfoScheme podInfoScheme = iota
	InterfaceIDPodInfoScheme
)
View Source
const (
	ActionTypeAllow  string = "Allow"
	ActionTypeBlock  string = "Block"
	DirectionTypeIn  string = "In"
	DirectionTypeOut string = "Out"
)
View Source
const (
	SetEnvironmentPath            = "/network/environment"
	CreateNetworkPath             = "/network/create"
	DeleteNetworkPath             = "/network/delete"
	CreateHnsNetworkPath          = "/network/hns/create"
	DeleteHnsNetworkPath          = "/network/hns/delete"
	ReserveIPAddressPath          = "/network/ip/reserve"
	ReleaseIPAddressPath          = "/network/ip/release"
	GetHostLocalIPPath            = "/network/ip/hostlocal"
	GetIPAddressUtilizationPath   = "/network/ip/utilization"
	GetUnhealthyIPAddressesPath   = "/network/ipaddresses/unhealthy"
	GetHealthReportPath           = "/network/health"
	NumberOfCPUCoresPath          = "/hostcpucores"
	CreateHostNCApipaEndpointPath = "/network/createhostncapipaendpoint"
	DeleteHostNCApipaEndpointPath = "/network/deletehostncapipaendpoint"
	NmAgentSupportedApisPath      = "/network/nmagentsupportedapis"
	V1Prefix                      = "/v0.1"
	V2Prefix                      = "/v0.2"
)

Container Network Service remote API Contract

View Source
const (
	SwiftPrefix = "Swift_"
)

NetworkContainer Prefixes

Variables

View Source
var ErrDuplicateIP = errors.New("duplicate IP detected in CNS initialization")

ErrDuplicateIP indicates that a duplicate IP has been detected during a reconcile.

View Source
var GlobalPodInfoScheme podInfoScheme

Functions

This section is empty.

Types

type AttachContainerToNetworkResponse

type AttachContainerToNetworkResponse struct {
	Response Response
}

AttachContainerToNetworkResponse specifies response of attaching network container to network.

type ConfigureContainerNetworkingRequest

type ConfigureContainerNetworkingRequest struct {
	Containerid        string
	NetworkContainerid string
}

ConfigureContainerNetworkingRequest - specifies request to attach/detach container to network.

type CreateHnsNetworkRequest

type CreateHnsNetworkRequest struct {
	NetworkName          string
	NetworkType          string
	NetworkAdapterName   string            `json:",omitempty"`
	SourceMac            string            `json:",omitempty"`
	Policies             []json.RawMessage `json:",omitempty"`
	MacPools             []MacPool         `json:",omitempty"`
	Subnets              []SubnetInfo
	DNSSuffix            string `json:",omitempty"`
	DNSServerList        string `json:",omitempty"`
	DNSServerCompartment uint32 `json:",omitempty"`
	ManagementIP         string `json:",omitempty"`
	AutomaticDNS         bool   `json:",omitempty"`
}

CreateHnsNetworkRequest describes request to create the HNS network.

type CreateHostNCApipaEndpointRequest

type CreateHostNCApipaEndpointRequest struct {
	NetworkContainerID string
}

CreateHostNCApipaEndpointRequest describes request for create apipa endpoint for host container connectivity for the given network container

type CreateHostNCApipaEndpointResponse

type CreateHostNCApipaEndpointResponse struct {
	Response   Response
	EndpointID string
}

CreateHostNCApipaEndpointResponse describes response for create apipa endpoint request for host container connectivity.

type CreateNetworkContainerRequest

type CreateNetworkContainerRequest struct {
	Version                    string
	NetworkContainerType       string
	NetworkContainerid         string // Mandatory input.
	PrimaryInterfaceIdentifier string // Primary CA.
	AuthorizationToken         string
	LocalIPConfiguration       IPConfiguration
	OrchestratorContext        json.RawMessage
	IPConfiguration            IPConfiguration
	SecondaryIPConfigs         map[string]SecondaryIPConfig // uuid is key
	MultiTenancyInfo           MultiTenancyInfo
	CnetAddressSpace           []IPSubnet // To setup SNAT (should include service endpoint vips).
	Routes                     []Route
	AllowHostToNCCommunication bool
	AllowNCToHostCommunication bool
	EndpointPolicies           []NetworkContainerRequestPolicies
}

CreateNetworkContainerRequest specifies request to create a network container or network isolation boundary.

type CreateNetworkContainerResponse

type CreateNetworkContainerResponse struct {
	Response Response
}

CreateNetworkContainerResponse specifies response of creating a network container.

type CreateNetworkRequest

type CreateNetworkRequest struct {
	NetworkName          string
	OverlayConfiguration OverlayConfiguration
	Options              map[string]interface{}
}

CreateNetworkRequest describes request to create the network.

type DeleteHnsNetworkRequest

type DeleteHnsNetworkRequest struct {
	NetworkName string
}

DeleteHnsNetworkRequest describes request to delete the HNS network.

type DeleteHostNCApipaEndpointRequest

type DeleteHostNCApipaEndpointRequest struct {
	NetworkContainerID string
}

DeleteHostNCApipaEndpointRequest describes request for deleting apipa endpoint created for host NC connectivity.

type DeleteHostNCApipaEndpointResponse

type DeleteHostNCApipaEndpointResponse struct {
	Response Response
}

DeleteHostNCApipaEndpointResponse describes response for delete host NC apipa endpoint request.

type DeleteNetworkContainerRequest

type DeleteNetworkContainerRequest struct {
	NetworkContainerid string
}

DeleteNetworkContainerRequest specifies the details about the request to delete a specifc network container.

type DeleteNetworkContainerResponse

type DeleteNetworkContainerResponse struct {
	Response Response
}

DeleteNetworkContainerResponse describes the response to delete a specifc network container.

type DeleteNetworkRequest

type DeleteNetworkRequest struct {
	NetworkName string
}

DeleteNetworkRequest describes request to delete the network.

type DetachContainerFromNetworkResponse

type DetachContainerFromNetworkResponse struct {
	Response Response
}

DetachContainerFromNetworkResponse specifies response of detaching network container from network.

type GetIPAddressStateResponse

type GetIPAddressStateResponse struct {
	IPAddresses []IPAddressState
	Response    Response
}

GetIPAddressStateResponse is used in CNS IPAM mode as a response to get IP address state

type GetIPAddressStatusResponse

type GetIPAddressStatusResponse struct {
	IPConfigurationStatus []IPConfigurationStatus
	Response              Response
}

GetIPAddressStatusResponse is used in CNS IPAM mode as a response to get IP address, state and Pod info

type GetIPAddressesRequest

type GetIPAddressesRequest struct {
	IPConfigStateFilter []IPConfigState
}

GetIPAddressesRequest is used in CNS IPAM mode to get the states of IPConfigs The IPConfigStateFilter is a slice of IP's to fetch from CNS that match those states

type GetIPAddressesResponse

type GetIPAddressesResponse struct {
	Response    Response
	IPAddresses []string
}

GetIPAddressesResponse describes response containing requested ip addresses.

type GetInterfaceForContainerRequest

type GetInterfaceForContainerRequest struct {
	NetworkContainerID string
}

GetInterfaceForContainerRequest specifies the container ID for which interface needs to be identified.

type GetInterfaceForContainerResponse

type GetInterfaceForContainerResponse struct {
	NetworkContainerVersion string
	NetworkInterface        NetworkInterface
	CnetAddressSpace        []IPSubnet
	DNSServers              []string
	Response                Response
}

GetInterfaceForContainerResponse specifies the interface for a given container ID.

type GetNetworkContainerRequest

type GetNetworkContainerRequest struct {
	NetworkContainerid  string
	OrchestratorContext json.RawMessage
}

GetNetworkContainerRequest specifies the details about the request to retrieve a specifc network container.

type GetNetworkContainerResponse

type GetNetworkContainerResponse struct {
	NetworkContainerID         string
	IPConfiguration            IPConfiguration
	Routes                     []Route
	CnetAddressSpace           []IPSubnet
	MultiTenancyInfo           MultiTenancyInfo
	PrimaryInterfaceIdentifier string
	LocalIPConfiguration       IPConfiguration
	Response                   Response
	AllowHostToNCCommunication bool
	AllowNCToHostCommunication bool
}

GetNetworkContainerResponse describes the response to retrieve a specifc network container.

type GetNetworkContainerStatusRequest

type GetNetworkContainerStatusRequest struct {
	NetworkContainerid string
}

GetNetworkContainerStatusRequest specifies the details about the request to retrieve status of a specifc network container.

type GetNetworkContainerStatusResponse

type GetNetworkContainerStatusResponse struct {
	NetworkContainerid string
	Version            string
	AzureHostVersion   string
	Response           Response
}

GetNetworkContainerStatusResponse specifies response of retriving a network container status.

type GetPodContextResponse

type GetPodContextResponse struct {
	PodContext map[string]string
	Response   Response
}

GetPodContextResponse is used in CNS Client debug mode to get mapping of Orchestrator Context to Pod IP UUID

type HTTPService

type HTTPService interface {
	common.ServiceAPI
	SendNCSnapShotPeriodically(context.Context, int)
	SetNodeOrchestrator(*SetOrchestratorTypeRequest)
	SyncNodeStatus(string, string, string, json.RawMessage) (types.ResponseCode, string)
	GetPendingProgramIPConfigs() []IPConfigurationStatus
	GetAvailableIPConfigs() []IPConfigurationStatus
	GetAllocatedIPConfigs() []IPConfigurationStatus
	GetPendingReleaseIPConfigs() []IPConfigurationStatus
	GetPodIPConfigState() map[string]IPConfigurationStatus
	MarkIPAsPendingRelease(numberToMark int) (map[string]IPConfigurationStatus, error)
}

HTTPService describes the min API interface that every service should have.

type HostIPInfo

type HostIPInfo struct {
	Gateway   string
	PrimaryIP string
	Subnet    string
}

DeleteNetworkContainerRequest specifies the details about the request to delete a specifc network container.

type HostLocalIPAddressResponse

type HostLocalIPAddressResponse struct {
	Response  Response
	IPAddress string
}

HostLocalIPAddressResponse describes reponse that returns the host local IP Address.

type IPAMPoolMonitor

type IPAMPoolMonitor interface {
	Start(ctx context.Context, poolMonitorRefreshMilliseconds int) error
	Update(scalar v1alpha.Scaler, spec v1alpha.NodeNetworkConfigSpec)
	GetStateSnapshot() IpamPoolMonitorStateSnapshot
}

type IPAddressState

type IPAddressState struct {
	IPAddress string
	State     string
}

IPAddressState Only used in the GetIPConfig API to return IP's that match a filter

type IPAddressesUtilizationResponse

type IPAddressesUtilizationResponse struct {
	Response  Response
	Available int
	Reserved  int
	Unhealthy int
}

IPAddressesUtilizationResponse describes response for ip address utilization.

type IPConfigRequest

type IPConfigRequest struct {
	DesiredIPAddress    string
	PodInterfaceID      string
	InfraContainerID    string
	OrchestratorContext json.RawMessage
}

func (IPConfigRequest) String added in v1.2.6

func (i IPConfigRequest) String() string

type IPConfigResponse

type IPConfigResponse struct {
	PodIpInfo PodIpInfo
	Response  Response
}

IPConfigResponse is used in CNS IPAM mode as a response to CNI ADD

type IPConfigState added in v1.4.10

type IPConfigState string

IPConfig States for CNS IPAM

const (
	// Available IPConfigState for available IPs.
	Available IPConfigState = "Available"
	// Allocated IPConfigState for allocated IPs.
	Allocated IPConfigState = "Allocated"
	// PendingRelease IPConfigState for pending release IPs.
	PendingRelease IPConfigState = "PendingRelease"
	// PendingProgramming IPConfigState for pending programming IPs.
	PendingProgramming IPConfigState = "PendingProgramming"
)

type IPConfiguration

type IPConfiguration struct {
	IPSubnet         IPSubnet
	DNSServers       []string
	GatewayIPAddress string
}

IPConfiguration contains details about ip config to provision in the VM.

type IPConfigurationStatus

type IPConfigurationStatus struct {
	NCID      string
	ID        string // uuid
	IPAddress string
	State     IPConfigState
	PodInfo   PodInfo
}

This is used for KubernetesCRD orchestrator Type where NC has multiple ips. This struct captures the state for SecondaryIPs associated to a given NC

func (IPConfigurationStatus) String

func (i IPConfigurationStatus) String() string

func (*IPConfigurationStatus) UnmarshalJSON

func (i *IPConfigurationStatus) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom unmarshaller for IPConfigurationStatus that is capable of unmarshalling to interface type `PodInfo` contained in the struct. Without this custom unmarshaller, the default unmarshaller can't deserialize the json data in to that interface type.

type IPSubnet

type IPSubnet struct {
	IPAddress    string
	PrefixLength uint8
}

IPSubnet contains ip subnet.

func (*IPSubnet) GetIPNet

func (ips *IPSubnet) GetIPNet() (net.IP, *net.IPNet, error)

GetIPNet converts the IPSubnet to the standard net type

type IpamPoolMonitorStateSnapshot

type IpamPoolMonitorStateSnapshot struct {
	MinimumFreeIps           int64
	MaximumFreeIps           int64
	UpdatingIpsNotInUseCount int
	CachedNNC                v1alpha.NodeNetworkConfig
}

IpamPoolMonitorStateSnapshot struct to expose state values for IPAMPoolMonitor struct

type KubernetesPodInfo

type KubernetesPodInfo struct {
	PodName      string
	PodNamespace string
}

type MacPool

type MacPool struct {
	StartMacAddress string
	EndMacAddress   string
}

MacPool is assoicated with HNS network and represents a list of macaddresses available to the network

type MultiTenancyInfo

type MultiTenancyInfo struct {
	EncapType string
	ID        int // This can be vlanid, vxlanid, gre-key etc. (depends on EnacapType).
}

MultiTenancyInfo contains encap type and id.

type NetworkContainerRequestPolicies

type NetworkContainerRequestPolicies struct {
	Type         string
	EndpointType string
	Settings     json.RawMessage
}

NetworkContainerRequestPolicies - specifies policies associated with create network request

func (*NetworkContainerRequestPolicies) Validate

func (networkContainerRequestPolicy *NetworkContainerRequestPolicies) Validate() error

Validate - Validates network container request policies

type NetworkInterface

type NetworkInterface struct {
	Name      string
	IPAddress string
}

NetworkInterface specifies the information that can be used to unquely identify an interface.

type NmAgentSupportedApisRequest

type NmAgentSupportedApisRequest struct {
	GetNmAgentSupportedApisURL string
}

type NmAgentSupportedApisResponse

type NmAgentSupportedApisResponse struct {
	Response      Response
	SupportedApis []string
}

type NodeConfiguration

type NodeConfiguration struct {
	NodeIP     string
	NodeID     string
	NodeSubnet Subnet
}

NodeConfiguration describes confguration for a node in overlay network.

type NodeInfoResponse

type NodeInfoResponse struct {
	NetworkContainers []CreateNetworkContainerRequest
}

NodeInfoResponse - Struct to hold the node info response.

type NodeRegisterRequest

type NodeRegisterRequest struct {
	NumCPU               int
	NmAgentSupportedApis []string
}

NodeRegisterRequest - Struct to hold the node register request.

type NumOfCPUCoresResponse

type NumOfCPUCoresResponse struct {
	Response      Response
	NumOfCPUCores int
}

NumOfCPUCoresResponse describes num of cpu cores present on host.

type OptionMap

type OptionMap map[string]interface{}

OptionMap describes generic options that can be passed to CNS.

type OverlayConfiguration

type OverlayConfiguration struct {
	NodeCount     int
	LocalNodeIP   string
	OverlaySubent Subnet
	NodeConfig    []NodeConfiguration
}

OverlayConfiguration describes configuration for all the nodes that are part of overlay.

type PodInfo

type PodInfo interface {
	// InfraContainerID the CRI infra container for the pod namespace.
	InfraContainerID() string
	// InterfaceID a short hash of the infra container and the primary network
	// interface of the pod net ns.
	InterfaceID() string
	// Key is a unique string representation of the PodInfo.
	Key() string
	// Name is the orchestrator pod name.
	Name() string
	// Namespace is the orchestrator pod namespace.
	Namespace() string
	// OrchestratorContext is a JSON KubernetesPodInfo
	OrchestratorContext() (json.RawMessage, error)
}

PodInfo represents the object that we are providing network for.

func NewPodInfo

func NewPodInfo(infraContainerID, interfaceID, name, namespace string) PodInfo

NewPodInfo returns an implementation of PodInfo that returns the passed configuration for their namesake functions.

func NewPodInfoFromIPConfigRequest added in v1.4.4

func NewPodInfoFromIPConfigRequest(req IPConfigRequest) (PodInfo, error)

NewPodInfoFromIPConfigRequest builds and returns an implementation of PodInfo from the provided IPConfigRequest.

func UnmarshalPodInfo

func UnmarshalPodInfo(b []byte) (PodInfo, error)

UnmarshalPodInfo wraps json.Unmarshal to return an implementation of PodInfo.

type PodInfoByIPProvider

type PodInfoByIPProvider interface {
	PodInfoByIP() (map[string]PodInfo, error)
}

PodInfoByIPProvider to be implemented by initializers which provide a map of PodInfos by IP.

type PodInfoByIPProviderFunc

type PodInfoByIPProviderFunc func() (map[string]PodInfo, error)

PodInfoByIPProviderFunc functional type which implements PodInfoByIPProvider. Allows one-off functional implementations of the PodInfoByIPProvider interface when a custom type definition is not necessary.

func (PodInfoByIPProviderFunc) PodInfoByIP

func (f PodInfoByIPProviderFunc) PodInfoByIP() (map[string]PodInfo, error)

PodInfoByIP implements PodInfoByIPProvider on PodInfByIPProviderFunc.

type PodIpInfo

type PodIpInfo struct {
	PodIPConfig                     IPSubnet
	NetworkContainerPrimaryIPConfig IPConfiguration
	HostPrimaryIPInfo               HostIPInfo
}

DeleteNetworkContainerRequest specifies the details about the request to delete a specifc network container.

type PublishNetworkContainerRequest

type PublishNetworkContainerRequest struct {
	NetworkID                         string
	NetworkContainerID                string
	JoinNetworkURL                    string
	CreateNetworkContainerURL         string
	CreateNetworkContainerRequestBody []byte
}

PublishNetworkContainerRequest specifies request to publish network container via NMAgent.

type PublishNetworkContainerResponse

type PublishNetworkContainerResponse struct {
	Response            Response
	PublishErrorStr     string
	PublishStatusCode   int
	PublishResponseBody []byte
}

PublishNetworkContainerResponse specifies the response to publish network container request.

type ReleaseIPAddressRequest

type ReleaseIPAddressRequest struct {
	ReservationID string
}

ReleaseIPAddressRequest describes request to release an IP Address.

type ReserveIPAddressRequest

type ReserveIPAddressRequest struct {
	ReservationID string
}

ReserveIPAddressRequest describes request to reserve an IP Address

type ReserveIPAddressResponse

type ReserveIPAddressResponse struct {
	Response  Response
	IPAddress string
}

ReserveIPAddressResponse describes response to reserve an IP address.

type Response

type Response struct {
	ReturnCode types.ResponseCode
	Message    string
}

Response describes generic response from CNS.

type Route

type Route struct {
	IPAddress        string
	GatewayIPAddress string
	InterfaceToUse   string
}

Route describes an entry in routing table.

type SecondaryIPConfig

type SecondaryIPConfig struct {
	IPAddress string
	// NCVesion will help in determining whether IP is in pending programming or available when reconciling.
	NCVersion int
}

SecondaryIPConfig contains IP info of SecondaryIP

type Service

type Service struct {
	*common.Service
	EndpointType string
	Listener     *acn.Listener
}

Service defines Container Networking Service.

func NewService

func NewService(name, version, channelMode string, store store.KeyValueStore) (*Service, error)

NewService creates a new Service object.

func (*Service) Initialize

func (service *Service) Initialize(config *common.ServiceConfig) error

Initialize initializes the service and starts the listener.

func (*Service) ParseOptions

func (service *Service) ParseOptions(options OptionMap) OptionMap

ParseOptions returns generic options from a libnetwork request.

func (*Service) SendErrorResponse

func (service *Service) SendErrorResponse(w http.ResponseWriter, errMsg error)

SendErrorResponse sends and logs an error response.

func (*Service) StartListener

func (service *Service) StartListener(config *common.ServiceConfig) error

func (*Service) Uninitialize

func (service *Service) Uninitialize()

Uninitialize cleans up the plugin.

type SetEnvironmentRequest

type SetEnvironmentRequest struct {
	Location    string
	NetworkType string
}

SetEnvironmentRequest describes the Request to set the environment in CNS.

type SetOrchestratorTypeRequest

type SetOrchestratorTypeRequest struct {
	OrchestratorType string
	DncPartitionKey  string
	NodeID           string
}

SetOrchestratorTypeRequest specifies the orchestrator type for the node.

type Subnet

type Subnet struct {
	IPAddress    string
	PrefixLength int
}

Subnet contains the ip address and the number of bits in prefix.

type SubnetInfo

type SubnetInfo struct {
	AddressPrefix  string
	GatewayAddress string
	Policies       []json.RawMessage `json:",omitempty"`
}

SubnetInfo is assoicated with HNS network and represents a list of subnets available to the network

type UnpublishNetworkContainerRequest

type UnpublishNetworkContainerRequest struct {
	NetworkID                 string
	NetworkContainerID        string
	JoinNetworkURL            string
	DeleteNetworkContainerURL string
}

UnpublishNetworkContainerRequest specifies request to unpublish network container via NMAgent.

type UnpublishNetworkContainerResponse

type UnpublishNetworkContainerResponse struct {
	Response              Response
	UnpublishErrorStr     string
	UnpublishStatusCode   int
	UnpublishResponseBody []byte
}

UnpublishNetworkContainerResponse specifies the response to unpublish network container request.

type ValidAclPolicySetting

type ValidAclPolicySetting struct {
	Protocols       string `json:","`
	Action          string `json:","`
	Direction       string `json:","`
	LocalAddresses  string `json:","`
	RemoteAddresses string `json:","`
	LocalPorts      string `json:","`
	RemotePorts     string `json:","`
	RuleType        string `json:","`
	Priority        uint16 `json:","`
}

ValidAclPolicySetting - Used to validate ACL policy

Jump to

Keyboard shortcuts

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