cni

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package cni configures the Container Networking Interface

Index

Constants

View Source
const (
	// DefaultPodCIDR is the default CIDR to use in minikube CNI's.
	DefaultPodCIDR = "10.244.0.0/16"

	// DefaultConfDir is the default CNI Config Directory path
	DefaultConfDir = "/etc/cni/net.d"
)

Variables

This section is empty.

Functions

func ConfigureDefaultBridgeCNIs added in v1.29.0

func ConfigureDefaultBridgeCNIs(r Runner, networkPlugin string) error

ConfigureDefaultBridgeCNIs configures all default bridge CNIs on a node (designated by runner). If network plugin is set (could be, eg "cni" or "kubenet"), it will disable all default bridges to avoid conflicts. Otherwise, it will configure all default bridges to match DefaultPodCIDR subnet range. It's usually called before deploying new CNI and on node restarts, to avoid conflicts and flip-flopping of pods' ip addresses. It is caller's responsibility to restart container runtime for these changes to take effect.

func ConfigureLoopbackCNI added in v1.29.0

func ConfigureLoopbackCNI(r Runner, disable bool) error

ConfigureLoopbackCNI configures loopback cni. If disable is true, sets extension of its config file in /etc/cni/net.d to "mk_disabled". Otherwise, ensures loopback cni has expected version ("1.0.0") and valid name ("loopback") in its config file in /etc/cni/net.d. Note: cri-o is leaving out name atm (https://github.com/cri-o/cri-o/pull/6273). Avoid errors like: - Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "..." network for pod "...": networkPlugin cni failed to set up pod "..." network: missing network name:, - failed to clean up sandbox container "..." network for pod "...": networkPlugin cni failed to teardown pod "..." network: missing network name] It is caller's responsibility to restart container runtime for these changes to take effect.

func GenerateCiliumYAML added in v1.24.0

func GenerateCiliumYAML() ([]byte, error)

GenerateCiliumYAML generates the .yaml file

func IsDisabled added in v1.16.0

func IsDisabled(cc config.ClusterConfig) bool

IsDisabled checks if CNI is disabled

Types

type Bridge

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

Bridge is a simple CNI manager for single-node usage

func (Bridge) Apply

func (c Bridge) Apply(r Runner) error

Apply enables the CNI

func (Bridge) CIDR

func (c Bridge) CIDR() string

CIDR returns the default CIDR used by this CNI

func (Bridge) String

func (c Bridge) String() string

String returns a string representation of this CNI

type Calico added in v1.12.1

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

Calico is the Calico CNI manager

func (Calico) Apply added in v1.12.1

func (c Calico) Apply(r Runner) error

Apply enables the CNI

func (Calico) CIDR added in v1.12.1

func (c Calico) CIDR() string

CIDR returns the default CIDR used by this CNI

func (Calico) String added in v1.12.1

func (c Calico) String() string

String returns a string representation of this CNI

type Cilium added in v1.12.1

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

Cilium is the Cilium CNI manager

func (Cilium) Apply added in v1.12.1

func (c Cilium) Apply(r Runner) error

Apply enables the CNI

func (Cilium) CIDR added in v1.12.1

func (c Cilium) CIDR() string

CIDR returns the default CIDR used by this CNI

func (Cilium) String added in v1.12.1

func (c Cilium) String() string

String returns a string representation of this CNI

type Custom

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

Custom is a CNI manager than applies a user-specified manifest

func NewCustom

func NewCustom(cc config.ClusterConfig, manifest string) (Custom, error)

NewCustom returns a well-formed Custom CNI manager

func (Custom) Apply

func (c Custom) Apply(r Runner) error

Apply enables the CNI

func (Custom) CIDR

func (c Custom) CIDR() string

CIDR returns the default CIDR used by this CNI

func (Custom) String

func (c Custom) String() string

String returns a string representation of this CNI

type Disabled

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

Disabled is a CNI manager than does nothing

func (Disabled) Apply

func (c Disabled) Apply(_ Runner) error

Apply enables the CNI

func (Disabled) CIDR

func (c Disabled) CIDR() string

CIDR returns the default CIDR used by this CNI

func (Disabled) String

func (c Disabled) String() string

String returns a string representation

type Flannel

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

Flannel is the Flannel CNI manager

func (Flannel) Apply

func (c Flannel) Apply(r Runner) error

Apply enables the CNI

func (Flannel) CIDR

func (c Flannel) CIDR() string

CIDR returns the default CIDR used by this CNI

func (Flannel) String

func (c Flannel) String() string

String returns a string representation of this CNI

type KindNet

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

KindNet is the KindNet CNI manager

func (KindNet) Apply

func (c KindNet) Apply(r Runner) error

Apply enables the CNI

func (KindNet) CIDR

func (c KindNet) CIDR() string

CIDR returns the default CIDR used by this CNI

func (KindNet) String

func (c KindNet) String() string

String returns a string representation of this CNI

type Manager

type Manager interface {
	// Apply a CNI. The provided runner is for the control plane
	Apply(Runner) error

	// CIDR returns the default CIDR used by this CNI
	CIDR() string

	// String representation
	String() string
}

Manager is a common interface for CNI

func New

func New(cc *config.ClusterConfig) (Manager, error)

New returns a new CNI manager

type Runner

type Runner interface {
	RunCmd(cmd *exec.Cmd) (*command.RunResult, error)
	Copy(assets.CopyableFile) error
}

Runner is the subset of command.Runner this package consumes

Jump to

Keyboard shortcuts

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