hns

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHcnEndpoint

func AddHcnEndpoint(epName string, expectedNetworkId string, namespace string, makeEndpoint HcnEndpointMakerFunc) (*hcn.HostComputeEndpoint, error)

AddHcnEndpoint attaches a HostComputeEndpoint to the given namespace.

func AddHnsEndpoint added in v1.0.0

func AddHnsEndpoint(epName string, expectedNetworkId string, containerID string, netns string, makeEndpoint HnsEndpointMakerFunc) (*hcsshim.HNSEndpoint, error)

AddHnsEndpoint attaches an HNSEndpoint to a container specified by containerID.

func ConstructEndpointName

func ConstructEndpointName(containerID string, netNs string, networkName string) string

ConstructEndpointName constructs endpoint id which is used to identify an endpoint from HNS/HCN.

func ConstructHcnResult

func ConstructHcnResult(hcnNetwork *hcn.HostComputeNetwork, hcnEndpoint *hcn.HostComputeEndpoint) (*current.Result, error)

ConstructHcnResult constructs the CNI result for the HostComputeEndpoint.

func ConstructHnsResult added in v1.0.0

func ConstructHnsResult(hnsNetwork *hcsshim.HNSNetwork, hnsEndpoint *hcsshim.HNSEndpoint) (*current.Result, error)

ConstructHnsResult constructs the CNI result for the HNSEndpoint.

func GenerateHcnEndpoint

func GenerateHcnEndpoint(epInfo *EndpointInfo, n *NetConf) (*hcn.HostComputeEndpoint, error)

GenerateHcnEndpoint generates a HostComputeEndpoint with given info and config.

func GenerateHnsEndpoint

func GenerateHnsEndpoint(epInfo *EndpointInfo, n *NetConf) (*hcsshim.HNSEndpoint, error)

GenerateHnsEndpoint generates an HNSEndpoint with given info and config.

func GetDefaultDestinationPrefix added in v0.8.2

func GetDefaultDestinationPrefix(ip *net.IP) string

GetDefaultDestinationPrefix returns the default destination prefix according to the given IP type.

func GetIpString

func GetIpString(ip *net.IP) string

GetIpString returns the given IP as a string.

func GetSandboxContainerID

func GetSandboxContainerID(containerID string, netNs string) string

GetSandboxContainerID returns the sandbox ID of this pod.

func RemoveHcnEndpoint

func RemoveHcnEndpoint(epName string) error

RemoveHcnEndpoint removes the given name endpoint from namespace.

func RemoveHnsEndpoint added in v1.0.0

func RemoveHnsEndpoint(epName string, netns string, containerID string) error

RemoveHnsEndpoint detaches the given name endpoint from container specified by containerID, or removes the given name endpoint completely.

Types

type EndpointInfo

type EndpointInfo struct {
	EndpointName string
	DNS          types.DNS
	NetworkName  string
	NetworkId    string
	Gateway      net.IP
	IpAddress    net.IP
}

type HcnEndpointMakerFunc

type HcnEndpointMakerFunc func() (*hcn.HostComputeEndpoint, error)

type HnsEndpointMakerFunc added in v1.0.0

type HnsEndpointMakerFunc func() (*hcsshim.HNSEndpoint, error)

type NetConf

type NetConf struct {
	types.NetConf
	// ApiVersion specifies the policies type of HNS or HCN, select one of [1, 2].
	// HNS is the v1 API, which is the default version and applies to dockershim.
	// HCN is the v2 API, which can leverage HostComputeNamespace and use in containerd.
	ApiVersion int `json:"apiVersion,omitempty"`
	// Policies specifies the policy list for HNSEndpoint or HostComputeEndpoint.
	Policies []Policy `json:"policies,omitempty"`
	// RuntimeConfig represents the options to be passed in by the runtime.
	RuntimeConfig RuntimeConfig `json:"runtimeConfig"`
	// LoopbackDSR specifies whether to support loopback direct server return.
	LoopbackDSR bool `json:"loopbackDSR,omitempty"`
}

NetConf is the CNI spec

func (*NetConf) ApplyDefaultPAPolicy

func (n *NetConf) ApplyDefaultPAPolicy(address string)

ApplyDefaultPAPolicy applies an endpoint PA policy in HNS/HCN.

func (*NetConf) ApplyLoopbackDSRPolicy added in v1.0.0

func (n *NetConf) ApplyLoopbackDSRPolicy(ip *net.IP)

ApplyLoopbackDSRPolicy configures the given IP to support loopback DSR.

func (*NetConf) ApplyOutboundNatPolicy

func (n *NetConf) ApplyOutboundNatPolicy(exceptionCIDR string)

ApplyOutboundNatPolicy applies the sNAT policy in HNS/HCN and configures the given CIDR as an exception.

func (*NetConf) ApplyPortMappingPolicy added in v0.8.6

func (n *NetConf) ApplyPortMappingPolicy(portMappings []PortMapEntry)

ApplyPortMappingPolicy applies the host/container port mapping policies in HNS/HCN.

func (*NetConf) GetDNS

func (n *NetConf) GetDNS() types.DNS

GetDNS returns the DNS values if they are there use that else use netconf supplied DNS.

func (*NetConf) GetHNSEndpointPolicies added in v1.0.0

func (n *NetConf) GetHNSEndpointPolicies() []json.RawMessage

GetHNSEndpointPolicies converts the configuration policies to HNSEndpoint policies.

func (*NetConf) GetHostComputeEndpointPolicies added in v1.0.0

func (n *NetConf) GetHostComputeEndpointPolicies() []hcn.EndpointPolicy

GetHostComputeEndpointPolicies converts the configuration policies to HostComputeEndpoint policies.

type Policy added in v1.0.0

type Policy struct {
	Name  string          `json:"name"`
	Value json.RawMessage `json:"value"`
}

type PortMapEntry added in v0.8.6

type PortMapEntry struct {
	HostPort      int    `json:"hostPort"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol"`
	HostIP        string `json:"hostIP,omitempty"`
}

func (*PortMapEntry) GetProtocolEnum added in v1.0.0

func (p *PortMapEntry) GetProtocolEnum() (uint32, error)

type RuntimeConfig

type RuntimeConfig struct {
	DNS      RuntimeDNS     `json:"dns"`
	PortMaps []PortMapEntry `json:"portMappings,omitempty"`
}

type RuntimeDNS

type RuntimeDNS struct {
	Nameservers []string `json:"servers,omitempty"`
	Search      []string `json:"searches,omitempty"`
}

Jump to

Keyboard shortcuts

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