cni

package
v1.4.50 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 19 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// CNI commands.
	Cmd = "CNI_COMMAND"
	// CmdAdd - CNI ADD command.
	CmdAdd = "ADD"
	// CmdGet - CNI GET command.
	CmdGet = "GET"
	// CmdDel - CNI DEL command.
	CmdDel = "DEL"
	// CmdUpdate - CNI UPDATE command.
	CmdUpdate = "UPDATE"
	// CmdVersion - CNI VERSION command.
	CmdVersion = "VERSION"

	// nonstandard CNI spec command, used to dump CNI state to stdout
	CmdGetEndpointsState = "GET_ENDPOINT_STATE"

	// CNI errors.
	ErrRuntime = 100
)
View Source
const (
	Internal = "internal"
)
View Source
const (
	PolicyStr string = "Policy"
)

Variables

This section is empty.

Functions

func CallPlugin

func CallPlugin(plugin PluginApi, cmd string, args *cniSkel.CmdArgs, nwCfg *NetworkConfig) (*cniTypes.Result, error)

CallPlugin calls the given CNI plugin through the internal interface.

func GetPoliciesFromNwCfg

func GetPoliciesFromNwCfg(kvp []KVPair) []policy.Policy

GetPoliciesFromNwCfg returns network policies from network config.

Types

type IPAM

type IPAM struct {
	Mode          string `json:"mode,omitempty"`
	Type          string `json:"type"`
	Environment   string `json:"environment,omitempty"`
	AddrSpace     string `json:"addressSpace,omitempty"`
	Subnet        string `json:"subnet,omitempty"`
	Address       string `json:"ipAddress,omitempty"`
	QueryInterval string `json:"queryInterval,omitempty"`
}

type K8SPodEnvArgs

type K8SPodEnvArgs struct {
	cniTypes.CommonArgs
	K8S_POD_NAMESPACE          cniTypes.UnmarshallableString `json:"K8S_POD_NAMESPACE,omitempty"`
	K8S_POD_NAME               cniTypes.UnmarshallableString `json:"K8S_POD_NAME,omitempty"`
	K8S_POD_INFRA_CONTAINER_ID cniTypes.UnmarshallableString `json:"K8S_POD_INFRA_CONTAINER_ID,omitempty"`
}

func ParseCniArgs

func ParseCniArgs(args string) (*K8SPodEnvArgs, error)

ParseCniArgs unmarshals cni arguments.

type KVPair

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

KVPair represents a K-V pair of a json object.

type NetworkConfig

type NetworkConfig struct {
	CNIVersion                    string          `json:"cniVersion,omitempty"`
	Name                          string          `json:"name,omitempty"`
	Type                          string          `json:"type,omitempty"`
	Mode                          string          `json:"mode,omitempty"`
	Master                        string          `json:"master,omitempty"`
	AdapterName                   string          `json:"adapterName,omitempty"`
	Bridge                        string          `json:"bridge,omitempty"`
	LogLevel                      string          `json:"logLevel,omitempty"`
	LogTarget                     string          `json:"logTarget,omitempty"`
	InfraVnetAddressSpace         string          `json:"infraVnetAddressSpace,omitempty"`
	IPV6Mode                      string          `json:"ipv6Mode,omitempty"`
	ServiceCidrs                  string          `json:"serviceCidrs,omitempty"`
	VnetCidrs                     string          `json:"vnetCidrs,omitempty"`
	PodNamespaceForDualNetwork    []string        `json:"podNamespaceForDualNetwork,omitempty"`
	IPsToRouteViaHost             []string        `json:"ipsToRouteViaHost,omitempty"`
	MultiTenancy                  bool            `json:"multiTenancy,omitempty"`
	EnableSnatOnHost              bool            `json:"enableSnatOnHost,omitempty"`
	EnableExactMatchForPodName    bool            `json:"enableExactMatchForPodName,omitempty"`
	DisableHairpinOnHostInterface bool            `json:"disableHairpinOnHostInterface,omitempty"`
	DisableIPTableLock            bool            `json:"disableIPTableLock,omitempty"`
	CNSUrl                        string          `json:"cnsurl,omitempty"`
	ExecutionMode                 string          `json:"executionMode,omitempty"`
	IPAM                          IPAM            `json:"ipam,omitempty"`
	DNS                           cniTypes.DNS    `json:"dns,omitempty"`
	RuntimeConfig                 RuntimeConfig   `json:"runtimeConfig,omitempty"`
	WindowsSettings               WindowsSettings `json:"windowsSettings,omitempty"`
	AdditionalArgs                []KVPair        `json:"AdditionalArgs,omitempty"`
}

NetworkConfig represents Azure CNI plugin network configuration.

func ParseNetworkConfig

func ParseNetworkConfig(b []byte) (*NetworkConfig, error)

ParseNetworkConfig unmarshals network configuration from bytes.

func (*NetworkConfig) Serialize

func (nwcfg *NetworkConfig) Serialize() []byte

Serialize marshals a network configuration to bytes.

type Plugin

type Plugin struct {
	*common.Plugin
	// contains filtered or unexported fields
}

Plugin is the parent class for CNI plugins.

func NewPlugin

func NewPlugin(name, version string) (*Plugin, error)

NewPlugin creates a new CNI plugin.

func (*Plugin) DelegateAdd

func (plugin *Plugin) DelegateAdd(pluginName string, nwCfg *NetworkConfig) (*cniTypesCurr.Result, error)

DelegateAdd calls the given plugin's ADD command and returns the result.

func (*Plugin) DelegateDel

func (plugin *Plugin) DelegateDel(pluginName string, nwCfg *NetworkConfig) error

DelegateDel calls the given plugin's DEL command and returns the result.

func (*Plugin) Error

func (plugin *Plugin) Error(err error) *cniTypes.Error

Error creates and logs a structured CNI error.

func (*Plugin) Errorf

func (plugin *Plugin) Errorf(format string, args ...interface{}) *cniTypes.Error

Errorf creates and logs a custom CNI error according to a format specifier.

func (*Plugin) Execute

func (plugin *Plugin) Execute(api PluginApi) (err error)

Execute executes the CNI command.

func (*Plugin) Initialize

func (plugin *Plugin) Initialize(config *common.PluginConfig) error

Initialize initializes the plugin.

func (*Plugin) InitializeKeyValueStore

func (plugin *Plugin) InitializeKeyValueStore(config *common.PluginConfig) error

Initialize key-value store

func (*Plugin) RetriableError

func (plugin *Plugin) RetriableError(err error) *cniTypes.Error

RetriableError logs and returns a CNI error with the TryAgainLater error code

func (*Plugin) Uninitialize

func (plugin *Plugin) Uninitialize()

Uninitialize uninitializes the plugin.

func (*Plugin) UninitializeKeyValueStore

func (plugin *Plugin) UninitializeKeyValueStore() error

Uninitialize key-value store

type PluginApi

type PluginApi interface {
	Add(args *cniSkel.CmdArgs) error
	Get(args *cniSkel.CmdArgs) error
	Delete(args *cniSkel.CmdArgs) error
	Update(args *cniSkel.CmdArgs) error
}

CNI contract.

type PortMapping

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

type RuntimeConfig

type RuntimeConfig struct {
	PortMappings []PortMapping    `json:"portMappings,omitempty"`
	DNS          RuntimeDNSConfig `json:"dns,omitempty"`
}

type RuntimeDNSConfig

type RuntimeDNSConfig struct {
	Servers  []string `json:"servers,omitempty"`
	Searches []string `json:"searches,omitempty"`
	Options  []string `json:"options,omitempty"`
}

https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/dockershim/network/cni/cni.go#L104

type WindowsSettings

type WindowsSettings struct {
	EnableLoopbackDSR           bool `json:"enableLoopbackDSR,omitempty"`
	HnsTimeoutDurationInSeconds int  `json:"hnsTimeoutDurationInSeconds,omitempty"`
}

Directories

Path Synopsis
telemetry

Jump to

Keyboard shortcuts

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