nad

package
v0.0.0-...-d0642ff Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGVR

GetGVR returns nad's GroupVersionResource which could be used for Clean function.

Types

type Builder

type Builder struct {
	Definition *nadV1.NetworkAttachmentDefinition
	Object     *nadV1.NetworkAttachmentDefinition
	// contains filtered or unexported fields
}

Builder provides struct for NAD object which contains connection to cluster and the NAD object itself.

func List

func List(apiClient *clients.Settings, nsname string) ([]*Builder, error)

List returns NADs inventory in the given namespace.

func NewBuilder

func NewBuilder(apiClient *clients.Settings, name, nsname string) *Builder

NewBuilder creates a new instance of NetworkAttachmentDefinition Builder. arguments: "apiClient" - the nad network client.

"name"      -       the name of the nad network.
"nsname"    -       the nad network namespace.

return value: the created Builder.

func Pull

func Pull(apiClient *clients.Settings, name, nsname string) (*Builder, error)

Pull pulls existing networkattachmentdefinition from cluster.

func (*Builder) Create

func (builder *Builder) Create() (*Builder, error)

Create builds a NetworkAttachmentDefinition resource with the builder configuration.

if the creation failed, the builder errorMsg will be updated.

return value: the builder itself with the NAD object if the creation succeeded.

an error if any occurred.

func (*Builder) Delete

func (builder *Builder) Delete() error

Delete removes NetworkAttachmentDefinition resource with the builder definition. (If NAD does not exist, nothing is done) and a nil error is returned. return value: an error if any occurred.

func (*Builder) Exists

func (builder *Builder) Exists() bool

Exists checks if a NAD is exists in the builder. return value: true - NAD exists.

false   - NAD does not exist.

func (*Builder) Get

func (builder *Builder) Get() (*nadV1.NetworkAttachmentDefinition, error)

Get returns CatalogSource object if found.

func (*Builder) GetString

func (builder *Builder) GetString() (string, error)

GetString prints NetworkAttachmentDefinition resource. return value: the builder details in json string format, and an error if any occurred.

func (*Builder) Update

func (builder *Builder) Update() (*Builder, error)

Update renovates the existing NAD object with nad definition in builder.

func (*Builder) WithMasterPlugin

func (builder *Builder) WithMasterPlugin(masterPlugin *MasterPlugin) *Builder

WithMasterPlugin defines master plugin configuration in the NetworkAttachmentDefinition spec.

func (*Builder) WithPlugins

func (builder *Builder) WithPlugins(name string, plugins *[]Plugin) *Builder

WithPlugins defines nad with group of plugins.

type Capability

type Capability struct {
	Mac bool `json:"mac,omitempty"`
	IPs bool `json:"ips,omitempty"`
}

Capability tells if the plugin supports MAC.

type IPAM

type IPAM struct {
	Type       string     `json:"type,omitempty"`
	AddrRange  string     `json:"range,omitempty"`
	RangeStart string     `json:"range_start,omitempty"`
	RangeEnd   string     `json:"range_end,omitempty"`
	Gateway    string     `json:"gateway,omitempty"`
	Exclude    []string   `json:"exclude,omitempty"`
	Routes     []Routes   `json:"routes,omitempty"`
	IPRanges   []IPRanges `json:"ipRanges,omitempty"`
}

IPAM container the IPAM configuration for a NAD.

func IPAMStatic

func IPAMStatic() *IPAM

IPAMStatic returns static ipam type.

func IPAMWhereAbouts

func IPAMWhereAbouts(ipRange, gateway string) *IPAM

IPAMWhereAbouts returns WhereAbout ipam type.

func WhereAboutsAppendRange

func WhereAboutsAppendRange(ipam *IPAM, ipRange, gateway string) *IPAM

WhereAboutsAppendRange returns WhereAbout ipam type with additional address range.

type IPRanges

type IPRanges struct {
	Range   string `json:"range,omitempty"`
	Gateway string `json:"gateway,omitempty"`
}

IPRanges contains ip range for WhereAbout IPAM plugin.

type Link struct {
	Name string `json:"name,omitempty"`
}

Link contains the link name of a link.

type MasterBondPlugin

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

MasterBondPlugin provides struct for MasterPlugin to create a NAD for bonded interfaces.

func NewMasterBondPlugin

func NewMasterBondPlugin(name, mode string) *MasterBondPlugin

NewMasterBondPlugin creates new instance of MasterBondPlugin.

func (*MasterBondPlugin) GetMasterPluginConfig

func (plugin *MasterBondPlugin) GetMasterPluginConfig() (*MasterPlugin, error)

GetMasterPluginConfig returns master plugin if error is not occur.

func (*MasterBondPlugin) WithCapabilities

func (plugin *MasterBondPlugin) WithCapabilities(capabilities *Capability) *MasterBondPlugin

WithCapabilities defines Capabilities configuration to MasterBondPlugin.

func (*MasterBondPlugin) WithFailOverMac

func (plugin *MasterBondPlugin) WithFailOverMac(failOverMac int) *MasterBondPlugin

WithFailOverMac defines FailOverMac configuration to MasterBondPlugin.

func (*MasterBondPlugin) WithIPAM

func (plugin *MasterBondPlugin) WithIPAM(ipam *IPAM) *MasterBondPlugin

WithIPAM defines IPAM configuration to MasterBondPlugin.

func (plugin *MasterBondPlugin) WithLinks(links []Link) *MasterBondPlugin

WithLinks defines Links configuration to MasterBondPlugin.

func (*MasterBondPlugin) WithLinksInContainer

func (plugin *MasterBondPlugin) WithLinksInContainer(linksInContainer bool) *MasterBondPlugin

WithLinksInContainer defines linksInContainer configuration to MasterBondPlugin.

func (*MasterBondPlugin) WithMiimon

func (plugin *MasterBondPlugin) WithMiimon(miimon int) *MasterBondPlugin

WithMiimon defines Miimon configuration to MasterBondPlugin.

func (*MasterBondPlugin) WithVLANInContainer

func (plugin *MasterBondPlugin) WithVLANInContainer(vlan uint16) *MasterBondPlugin

WithVLANInContainer defines a VLAN ID configuration to MasterBondPlugin.

type MasterBridgePlugin

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

MasterBridgePlugin provides struct for MasterPlugin set to bridge in NetworkAttachmentDefinition.

func NewMasterBridgePlugin

func NewMasterBridgePlugin(name, bridgeName string) *MasterBridgePlugin

NewMasterBridgePlugin creates new instance of MasterBridgePlugin.

func (*MasterBridgePlugin) GetMasterPluginConfig

func (plugin *MasterBridgePlugin) GetMasterPluginConfig() (*MasterPlugin, error)

GetMasterPluginConfig returns master plugin if error does not occur.

func (*MasterBridgePlugin) WithIPAM

func (plugin *MasterBridgePlugin) WithIPAM(ipam *IPAM) *MasterBridgePlugin

WithIPAM defines IPAM configuration to MasterBridgePlugin. Default is empty.

type MasterIPVlanPlugin

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

MasterIPVlanPlugin provides struct for MasterPlugin set to IP vlan in NetworkAttachmentDefinition.

func NewMasterIPVlanPlugin

func NewMasterIPVlanPlugin(name string) *MasterIPVlanPlugin

NewMasterIPVlanPlugin creates new instance of MasterIP VlanPlugin.

func (*MasterIPVlanPlugin) GetMasterPluginConfig

func (plugin *MasterIPVlanPlugin) GetMasterPluginConfig() (*MasterPlugin, error)

GetMasterPluginConfig returns master plugin if error does not occur.

func (*MasterIPVlanPlugin) WithIPAM

func (plugin *MasterIPVlanPlugin) WithIPAM(ipam *IPAM) *MasterIPVlanPlugin

WithIPAM defines IPAM configuration to MasterIPVlanPlugin. Default is empty.

func (*MasterIPVlanPlugin) WithLinkInContainer

func (plugin *MasterIPVlanPlugin) WithLinkInContainer() *MasterIPVlanPlugin

WithLinkInContainer defines MasterIPVlanPlugin using linkInContainer feature.

func (*MasterIPVlanPlugin) WithMasterInterface

func (plugin *MasterIPVlanPlugin) WithMasterInterface(masterInterfaceName string) *MasterIPVlanPlugin

WithMasterInterface defines master interface to MasterVlanPlugin. Default is cn0.

type MasterMacVlanPlugin

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

MasterMacVlanPlugin provides struct for NetworkAttachmentDefinition Master plugin with macvlan configuration.

func NewMasterMacVlanPlugin

func NewMasterMacVlanPlugin(name string) *MasterMacVlanPlugin

NewMasterMacVlanPlugin creates new instance of MasterMacVlanPlugin.

func (*MasterMacVlanPlugin) GetMasterPluginConfig

func (plugin *MasterMacVlanPlugin) GetMasterPluginConfig() (*MasterPlugin, error)

GetMasterPluginConfig returns master plugin if error is not occur.

func (*MasterMacVlanPlugin) WithIPAM

func (plugin *MasterMacVlanPlugin) WithIPAM(ipam *IPAM) *MasterMacVlanPlugin

WithIPAM defines IPAM configuration to MasterMacVlanPlugin. Default is empty.

func (*MasterMacVlanPlugin) WithLinkInContainer

func (plugin *MasterMacVlanPlugin) WithLinkInContainer() *MasterMacVlanPlugin

WithLinkInContainer defines MasterMacVlan plugin using linkInContainer feature.

func (*MasterMacVlanPlugin) WithMasterInterface

func (plugin *MasterMacVlanPlugin) WithMasterInterface(master string) *MasterMacVlanPlugin

WithMasterInterface defines master interface to MasterMacVlanPlugin. Default is cn0.

func (*MasterMacVlanPlugin) WithMode

func (plugin *MasterMacVlanPlugin) WithMode(mode string) *MasterMacVlanPlugin

WithMode defines macvlan type to MasterMacVlanPlugin. Default is bridge.

type MasterPlugin

type MasterPlugin struct {
	CniVersion       string      `json:"cniVersion,omitempty"`
	Name             string      `json:"name,omitempty"`
	Type             string      `json:"type,omitempty"`
	Master           string      `json:"master,omitempty"`
	Mode             string      `json:"mode,omitempty"`
	Plugins          *[]Plugin   `json:"plugins,omitempty"`
	Bridge           string      `json:"bridge,omitempty"`
	Ipam             *IPAM       `json:"ipam,omitempty"`
	LinksInContainer bool        `json:"linksInContainer,omitempty"`
	LinkInContainer  bool        `json:"linkInContainer,omitempty"`
	VlanID           uint16      `json:"vlanId,omitempty"`
	FailOverMac      int         `json:"failOverMac,omitempty"`
	Miimon           string      `json:"miimon,omitempty"`
	Mtu              int         `json:"mtu,omitempty"`
	Links            []Link      `json:"links,omitempty"`
	Capabilities     *Capability `json:"capabilities,omitempty"`
}

MasterPlugin contains the master plugin configuration for a NAD.

type MasterVlanPlugin

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

MasterVlanPlugin provides struct for MasterPlugin set to vlan in NetworkAttachmentDefinition.

func NewMasterVlanPlugin

func NewMasterVlanPlugin(name string, vlanID uint16) *MasterVlanPlugin

NewMasterVlanPlugin creates new instance of MasterVlanPlugin.

func (*MasterVlanPlugin) GetMasterPluginConfig

func (plugin *MasterVlanPlugin) GetMasterPluginConfig() (*MasterPlugin, error)

GetMasterPluginConfig returns master plugin if error does not occur.

func (*MasterVlanPlugin) WithIPAM

func (plugin *MasterVlanPlugin) WithIPAM(ipam *IPAM) *MasterVlanPlugin

WithIPAM defines IPAM configuration to MasterVlanPlugin. Default is empty.

func (*MasterVlanPlugin) WithLinkInContainer

func (plugin *MasterVlanPlugin) WithLinkInContainer() *MasterVlanPlugin

WithLinkInContainer defines MasterVlanPlugin using linkInContainer feature.

func (*MasterVlanPlugin) WithMasterInterface

func (plugin *MasterVlanPlugin) WithMasterInterface(masterInterfaceName string) *MasterVlanPlugin

WithMasterInterface defines master interface to MasterVlanPlugin. Default is cn0.

type Plugin

type Plugin struct {
	LinksInContainer bool              `json:"linksInContainer,omitempty"`
	IPMasq           bool              `json:"ipMasq,omitempty"`
	IsGateway        bool              `json:"isGateway,omitempty"`
	IsDefaultGateway bool              `json:"isDefaultGateway,omitempty"`
	ForceAddress     bool              `json:"forceAddress,omitempty"`
	HairpinMode      bool              `json:"hairpinMode,omitempty"`
	PromiscuousMode  bool              `json:"promiscuousMode,omitempty"`
	FailOverMac      int               `json:"failOverMac,omitempty"`
	CNIVersion       string            `json:"cniVersion,omitempty"`
	Name             string            `json:"name,omitempty"`
	Type             string            `json:"type,omitempty"`
	Bridge           string            `json:"bridge,omitempty"`
	Master           string            `json:"master,omitempty"`
	Vlan             string            `json:"vlan,omitempty"`
	Mtu              string            `json:"mtu,omitempty"`
	VrfName          string            `json:"vrfName,omitempty"`
	Mode             string            `json:"mode,omitempty"`
	Miimon           string            `json:"miimon,omitempty"`
	Capabilities     *Capability       `json:"capabilities,omitempty"`
	Sysctl           map[string]string `json:"sysctl,omitempty"`
	Links            []Link            `json:"links,omitempty"`
	Ipam             *IPAM             `json:"ipam,omitempty"`
	Owner            int               `json:"owner,omitempty"`
	Group            int               `json:"group,omitempty"`
	MultiQueue       bool              `json:"multiQueue,omitempty"`
	SelinuxContext   string            `json:"selinuxcontext,omitempty"`
}

Plugin contains all plugin details and information of a single plugin.

func TapPlugin

func TapPlugin(owner, group int, multiQueue bool) *Plugin

TapPlugin returns tap network plugin configuration.

func TuningMacPlugin

func TuningMacPlugin(macCap bool) *Plugin

TuningMacPlugin returns mac plugin configuration.

func TuningSysctlPlugin

func TuningSysctlPlugin(macCap bool, sysctlConfig map[string]string) *Plugin

TuningSysctlPlugin returns sysctl plugin configuration.

type Routes

type Routes struct {
	Dst string `json:"dst,omitempty"`
	Gw  string `json:"gw,omitempty"`
}

Routes represent routing entries for IPAM plugin.

Jump to

Keyboard shortcuts

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