ecscni

package
v0.0.0-...-cf8c7a6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 47

Documentation

Index

Constants

View Source
const (

	// TaskIAMRoleEndpoint is the endpoint of ecs-agent exposes credentials for
	// task IAM role
	TaskIAMRoleEndpoint = "169.254.170.2/32"
	// CapabilityAWSVPCNetworkingMode is the capability string, which when
	// present in the output of the '--capabilities' command of a CNI plugin
	// indicates that the plugin can support the ECS "awsvpc" network mode
	CapabilityAWSVPCNetworkingMode = "awsvpc-network-mode"
	// VPCENIPluginName is the binary of the vpc-eni plugin
	VPCENIPluginName = "vpc-eni"
)
View Source
const (
	// ECSVPCENIPluginExecutable is the name of vpc-eni executable.
	ECSVPCENIPluginExecutable = "vpc-eni.exe"
	// TaskHNSNetworkNamePrefix is the prefix of the HNS network used for task ENI.
	TaskHNSNetworkNamePrefix = "task"
	// ECSBridgeNetworkName is the name of the HNS network used as ecs-bridge.
	ECSBridgeNetworkName = "nat"

	// DefaultENIName is the name of eni interface name in the container namespace
	DefaultENIName = "eth0"
)

Variables

This section is empty.

Functions

func NewVPCENIPluginConfigForECSBridgeSetup

func NewVPCENIPluginConfigForECSBridgeSetup(cfg *Config) (*libcni.NetworkConfig, error)

NewVPCENIPluginConfigForECSBridgeSetup creates the configuration required by vpc-eni plugin to setup ecs-bridge endpoint for the task.

func NewVPCENIPluginConfigForTaskNSSetup

func NewVPCENIPluginConfigForTaskNSSetup(eni *ni.NetworkInterface, cfg *Config) (*libcni.NetworkConfig, error)

NewVPCENIPluginConfigForTaskNSSetup is used to create the configuration of vpc-eni plugin for task namespace setup.

Types

type CNIClient

type CNIClient interface {
	// Version returns the version of the plugin
	Version(string) (string, error)
	// Capabilities returns the capabilities supported by a plugin
	Capabilities(string) ([]string, error)
	// SetupNS sets up the namespace of container
	SetupNS(context.Context, *Config, time.Duration) (*cniTypesCurrent.Result, error)
	// CleanupNS cleans up the container namespace
	CleanupNS(context.Context, *Config, time.Duration) error
	// ReleaseIPResource marks the ip available in the ipam db
	ReleaseIPResource(context.Context, *Config, time.Duration) error
}

CNIClient defines the method of setting/cleaning up container namespace

func NewClient

func NewClient(pluginsPath string) CNIClient

NewClient creates a client of ecscni which is used to invoke the plugin

type Config

type Config struct {
	// PluginsPath indicates the path where cni plugins are located
	PluginsPath string
	// MinSupportedCNIVersion is the minimum cni spec version supported
	MinSupportedCNIVersion string
	// ContainerID is the id of container of which to set up the network namespace
	ContainerID string
	// ContainerPID is the pid of the container
	ContainerPID string
	// ContainerNetNS is the container namespace
	ContainerNetNS string
	// BridgeName is the name used to create the bridge
	BridgeName string
	// IPAMV4Address is the ipv4 used to assign from ipam
	IPAMV4Address *cniTypes.IPNet
	// ID is the information associate with ip in ipam
	ID string
	// BlockInstanceMetadata specifies if InstanceMetadata endpoint should be blocked
	BlockInstanceMetadata bool
	// AdditionalLocalRoutes specifies additional routes to be added to the task namespace
	AdditionalLocalRoutes []cniTypes.IPNet
	// NetworkConfigs is the list of CNI network configurations to be invoked
	NetworkConfigs []*NetworkConfig
	// InstanceENIDNSServerList stores the list of dns servers for the primary instance ENI.
	// Currently, this field is only populated for Windows and is used during task networking setup.
	InstanceENIDNSServerList []string
}

Config contains all the information to set up the container namespace using the plugins

type NamespaceHelper

type NamespaceHelper interface {
	ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *ni.NetworkInterface, config *Config, result *cniTypesCurrent.Result) error
}

NamespaceHelper defines the methods for performing additional actions to setup/clean the task namespace. Task namespace in awsvpc network mode is configured using pause container which is the first container launched for the task. These commands are executed inside that container.

func NewNamespaceHelper

func NewNamespaceHelper(client dockerapi.DockerClient) NamespaceHelper

NewNamespaceHelper returns a new instance of NamespaceHelper interface.

type NetworkConfig

type NetworkConfig struct {
	// IfName is the name of the network interface device, to be set within the
	// network namespace.
	IfName string
	// CNINetworkConfig is the network configuration required to invoke the CNI plugin
	CNINetworkConfig *libcni.NetworkConfig
}

NetworkConfig wraps CNI library's NetworkConfig object. It tracks the interface device name (the IfName param required to invoke AddNetwork) along with libcni's NetworkConfig object. The IfName is required to be set to invoke `AddNetwork` method when invoking plugins to set up the network namespace.

type VPCENIPluginConfig

type VPCENIPluginConfig struct {
	// Type is the cni plugin name.
	Type string `json:"type,omitempty"`
	// CNIVersion is the cni spec version to use.
	CNIVersion string `json:"cniVersion,omitempty"`
	// DNS is used to pass DNS information to the plugin.
	DNS types.DNS `json:"dns"`
	// ENIName is the name of the eni on the instance.
	ENIName string `json:"eniName"`
	// ENIMACAddress is the MAC address of the eni.
	ENIMACAddress string `json:"eniMACAddress"`
	// ENIIPAddresses is the is the ipv4 of eni.
	ENIIPAddresses []string `json:"eniIPAddresses"`
	// GatewayIPAddresses specifies the IPv4 address of the subnet gateway for the eni.
	GatewayIPAddresses []string `json:"gatewayIPAddresses"`
	// UseExistingNetwork specifies if existing network should be used instead of creating a new one.
	UseExistingNetwork bool `json:"useExistingNetwork"`
	// BlockIMDS specifies if the IMDS should be blocked for the created endpoint.
	BlockIMDS bool `json:"blockInstanceMetadata"`
}

VPCENIPluginConfig contains all the information required to invoke the vpc-eni plugin.

Directories

Path Synopsis
Package mock_ecscni is a generated GoMock package.
Package mock_ecscni is a generated GoMock package.
Package mock_types is a generated GoMock package.
Package mock_types is a generated GoMock package.
Package mock_libcni is a generated GoMock package.
Package mock_libcni is a generated GoMock package.

Jump to

Keyboard shortcuts

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