cmd

package
v1.19.6 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 49 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PluginMain added in v1.19.0

func PluginMain(opts ...Option)

PluginMain is the main entry point for the Cilium CNI plugin.

Types

type Cmd

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

Cmd provides methods for the CNI ADD, DEL and CHECK commands.

func (*Cmd) Add

func (cmd *Cmd) Add(args *skel.CmdArgs) (err error)

func (*Cmd) Check

func (cmd *Cmd) Check(args *skel.CmdArgs) error

Check implements the cni CHECK verb. It ensures that the interface is configured correctly

Currently, it verifies that - endpoint exists in the agent and is healthy - the interface in the container is sane

func (*Cmd) Del

func (cmd *Cmd) Del(args *skel.CmdArgs) error

Del is invoked on CNI DEL

Note: ENI specific attributes do not need to be released as the ENIs and ENI IPs can be reused and are not released until the node terminates.

func (*Cmd) Status added in v1.18.0

func (cmd *Cmd) Status(args *skel.CmdArgs) error

Status implements the cni STATUS verb. Currently, it

  • checks cilium-cni connectivity with cilium-agent using healthz endpoint
  • If cilium-cni depends on delegated plugins (host-local, azure etc) for IPAM, cilium-cni invokes the STATUS API of the delegated plugins and passes the result back.

type CmdState

type CmdState struct {
	IP6       netip.Addr
	IP6routes []route.Route
	IP6rules  []route.Rule
	IP4       netip.Addr
	IP4routes []route.Route
	IP4rules  []route.Rule
	HostAddr  *models.NodeAddressing
}

type ConfigurationParams

type ConfigurationParams struct {
	Log     *slog.Logger
	Conf    *models.DaemonConfigurationStatus
	Args    *skel.CmdArgs
	CniArgs *types.ArgsSpec
}

ConfigurationParams contains the arguments and Cilium configuration of a CNI invocation. Those fields may be used by custom implementations of the EndpointConfigurator interface to customize the CNI ADD call.

type DefaultConfigurator

type DefaultConfigurator struct{}

DefaultConfigurator is the default endpoint configurator. It configures a single endpoint for the interface name provided by the CNI ADD invocation, using an auto-selected IPAM pool.

func (*DefaultConfigurator) GetConfigurations

GetConfigurations returns a single a default configuration

type EndpointConfiguration

type EndpointConfiguration interface {
	// IfName specifies the container interface name to be used for this endpoint
	IfName() string
	// IPAMPool specifies which IPAM pool the endpoint's IP should be allocated from
	IPAMPool() string

	// PrepareEndpoint returns the interface configuration 'cmd' of the container
	// namespace as well as the template for the endpoint creation request 'ep'.
	PrepareEndpoint(ipam *models.IPAMResponse) (cmd *CmdState, ep *models.EndpointChangeRequest, err error)
}

EndpointConfiguration determines the configuration of an endpoint to be created during a CNI ADD invocation.

type EndpointConfigurator

type EndpointConfigurator interface {
	GetConfigurations(p ConfigurationParams) ([]EndpointConfiguration, error)
}

EndpointConfigurator returns a list of endpoint configurations for a given CNI ADD invocation. If the CNI ADD invocation should result in multiple endpoints being created, it may return multiple endpoint configurations, one for each endpoint.

type OnConfigReady added in v1.19.0

type OnConfigReady interface {
	OnConfigReady(netConf *types.NetConf, cniArgs *types.ArgsSpec, conf *models.DaemonConfigurationStatus) error
}

OnConfigReady is invoked at the beginning of [(*Cmd).Add], right after the CNI network configuration, CNI arguments and the Cilium agent configuration were loaded. It may be used to sets up internal state of the hook.

type OnIPAMReady added in v1.19.0

type OnIPAMReady interface {
	OnIPAMReady(ipam *models.IPAMResponse) error
}

OnIPAMReady is invoked after IPAM configuration was validated. It may be used to derive further endpoint configuration related to IPAM.

type OnInterfaceConfigReady added in v1.19.0

type OnInterfaceConfigReady interface {
	OnInterfaceConfigReady(cmd *CmdState, ep *models.EndpointChangeRequest, res *cniTypesV1.Result) error
}

OnInterfaceConfigReady is invoked right before the pod's network interface pair is configured and the endpoint creation request is sent to the daemon. It may be used to modify the endpoint creation request, the command state and the CNI result accumulated so far.

type OnLinkConfigReady added in v1.19.0

type OnLinkConfigReady interface {
	OnLinkConfigReady(linkConfig *connector.LinkConfig) error
}

OnLinkConfigReady is invoked before the datapath connectors are called to create the pod's network links (i.e. veth or netkit pairs). It may be used to further modify the link configuration.

type Option

type Option func(cmd *Cmd)

Option allows the customization of the Cmd implementation

func WithEPConfigurator

func WithEPConfigurator(cfg EndpointConfigurator) Option

WithEPConfigurator is used to create a Cmd instance with a custom endpoint configurator. The endpoint configurator can be used to customize the creation of endpoints during the CNI ADD invocation. This function is exported to be accessed outside the tree.

func WithOnConfigReady added in v1.19.0

func WithOnConfigReady(f OnConfigReady) Option

WithOnConfigReady adds a new callback to be invoked after the CNI network configuration, CNI arguments and the Cilium agent configuration were loaded.

func WithOnIPAMReady added in v1.19.0

func WithOnIPAMReady(f OnIPAMReady) Option

WithOnIPAMReady adds a new callback to be invoked after IPAM configuration was validated.

func WithOnInterfaceConfigReady added in v1.19.0

func WithOnInterfaceConfigReady(f OnInterfaceConfigReady) Option

WithOnInterfaceConfigReady adds a new callback to be invoked before the pod's network interface pair is configured.

func WithOnLinkConfigReady added in v1.19.0

func WithOnLinkConfigReady(f OnLinkConfigReady) Option

WithOnLinkConfigReady adds a new callback to be invoked before the datapath connectors are called to create the pod's network links.

func WithVersion added in v1.19.0

func WithVersion(version string) Option

WithVersion overrides the version reported by the CNI plugin binary in its about string.

Jump to

Keyboard shortcuts

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