Documentation ¶
Index ¶
- Constants
- func AddVxLanInterface(vxlan VxLAN) (err error)
- func AppendHostsFileEntries(containers []runtime.GenericContainer, labname string) error
- func BindIfacesWithTC(if1, if2 string) (err error)
- func DeleteEntriesFromHostsFile(labname string) error
- func GetLinksByNamePrefix(prefix string) ([]netlink.Link, error)
- func RetrieveSSHAgentKeys() ([]ssh.PublicKey, error)
- func RetrieveSSHPubKeysFromFiles() ([]ssh.PublicKey, error)
- func RuntimeInitializer(name string) (string, runtime.Initializer, error)
- func SetIngressMirror(src, dst string) (err error)
- type CLab
- func (c *CLab) BuildGraphFromDeployedLab(g *GraphTopo, containers []runtime.GenericContainer)
- func (c *CLab) BuildGraphFromTopo(g *GraphTopo)
- func (c *CLab) CheckTopologyDefinition(ctx context.Context) error
- func (c *CLab) CreateAuthzKeysFile() error
- func (c *CLab) CreateNetwork(ctx context.Context) error
- func (c *CLab) CreateNodes(ctx context.Context, maxWorkers uint, dm dependency_manager.DependencyManager) (*sync.WaitGroup, error)
- func (c *CLab) DeleteNodes(ctx context.Context, workers uint, serialNodes map[string]struct{})
- func (c *CLab) GenerateDotGraph() error
- func (c *CLab) GenerateExports(ctx context.Context, f io.Writer, p string) error
- func (c *CLab) GenerateInventories() error
- func (c *CLab) GenerateMermaidGraph(direction string) error
- func (c *CLab) GetLinkNodes() map[string]links.Node
- func (c *CLab) GetNodeRuntime(contName string) (runtime.ContainerRuntime, error)
- func (c *CLab) GetSpecialLinkNodes() map[string]links.Node
- func (c *CLab) GetTopology(topo, varsFile string) error
- func (c *CLab) GlobalRuntime() runtime.ContainerRuntime
- func (c *CLab) HasKind(k string) bool
- func (c *CLab) ListContainers(ctx context.Context, filter []*types.GenericFilter) ([]runtime.GenericContainer, error)
- func (c *CLab) ListNodesContainers(ctx context.Context) ([]runtime.GenericContainer, error)
- func (c *CLab) ListNodesContainersIgnoreNotFound(ctx context.Context) ([]runtime.GenericContainer, error)
- func (c *CLab) LoadKernelModules() error
- func (c *CLab) LoadOrGenerateCA(caCertInput *cert.CACSRInput) error
- func (c *CLab) NewNode(nodeName, nodeRuntime string, nodeDef *types.NodeDefinition, idx int) error
- func (c *CLab) RegisterNodes()
- func (c *CLab) RemoveHostOrBridgeVeth(l *types.Link) (err error)
- func (c *CLab) ResolveLinks() error
- func (c *CLab) RetrieveSSHPubKeys() ([]ssh.PublicKey, error)
- func (c *CLab) ServeTopoGraph(tmpl, staticDir, srv string, topoD TopoData) error
- func (c *CLab) SetClabIntfsEnvVar()
- func (c *CLab) VerifyContainersUniqueness(ctx context.Context) error
- func (c *CLab) WaitForExternalNodeDependencies(ctx context.Context, nodeName string)
- type ClabOption
- type Config
- type GraphTopo
- type Link
- type TopoData
- type TopologyExport
- type VxLAN
Constants ¶
const (
// veth link mtu.
DefaultVethLinkMTU = 9500
)
Variables ¶
This section is empty.
Functions ¶
func AddVxLanInterface ¶
AddVxLanInterface creates VxLan interface by given vxlan object.
func AppendHostsFileEntries ¶ added in v0.16.2
func AppendHostsFileEntries(containers []runtime.GenericContainer, labname string) error
func BindIfacesWithTC ¶
BindIfacesWithTC creates TC ingress mirred redirection between a pair of interfaces to make them virtually form a kind of a veth pair see https://netdevops.me/2021/transparently-redirecting-packets/frames-between-interfaces/#4-tc-to-the-rescue used https://github.com/redhat-nfvpe/koko/blob/bd156c82bf25837545fb109c69c7b91c3457b318/api/koko_api.go#L224 and https://gist.github.com/mcastelino/7d85f4164ffdaf48242f9281bb1d0f9b#gistcomment-2734521
func DeleteEntriesFromHostsFile ¶ added in v0.16.2
func GetLinksByNamePrefix ¶ added in v0.14.0
GetLinksByNamePrefix returns a list of links whose name matches a prefix.
func RetrieveSSHAgentKeys ¶ added in v0.44.0
RetrieveSSHAgentKeys retrieves public keys registered with the ssh-agent.
func RetrieveSSHPubKeysFromFiles ¶ added in v0.44.0
RetrieveSSHPubKeysFromFiles retrieves public keys from the ~/.ssh/*.authorized_keys and ~/.ssh/*.pub files.
func RuntimeInitializer ¶ added in v0.44.0
func RuntimeInitializer(name string) (string, runtime.Initializer, error)
RuntimeInitializer returns a runtime initializer function for a provided runtime name.
func SetIngressMirror ¶
SetIngressMirror sets TC to mirror ingress from given port as MirrorIngress.
Types ¶
type CLab ¶
type CLab struct { Config *Config `json:"config,omitempty"` TopoPaths *types.TopoPaths Nodes map[string]nodes.Node `json:"nodes,omitempty"` Links map[int]links.Link `json:"links,omitempty"` Endpoints []links.Endpoint Runtimes map[string]runtime.ContainerRuntime `json:"runtimes,omitempty"` // reg is a registry of node kinds Reg *nodes.NodeRegistry Cert *cert.Cert // List of SSH public keys extracted from the ~/.ssh/authorized_keys file // and ~/.ssh/*.pub files. // The keys are used to enable key-based SSH access for the nodes. SSHPubKeys []ssh.PublicKey // contains filtered or unexported fields }
func NewContainerLab ¶
func NewContainerLab(opts ...ClabOption) (*CLab, error)
NewContainerLab function defines a new container lab.
func (*CLab) BuildGraphFromDeployedLab ¶ added in v0.25.0
func (c *CLab) BuildGraphFromDeployedLab(g *GraphTopo, containers []runtime.GenericContainer)
func (*CLab) BuildGraphFromTopo ¶ added in v0.25.0
func (*CLab) CheckTopologyDefinition ¶
CheckTopologyDefinition runs topology checks and returns any errors found. This function runs after topology file is parsed and all nodes/links are initialized.
func (*CLab) CreateAuthzKeysFile ¶ added in v0.22.0
CreateAuthzKeysFile creates the authorized_keys file in the lab directory using the public ssh keys retrieved from agent and local files.
func (*CLab) CreateNetwork ¶ added in v0.24.0
func (*CLab) CreateNodes ¶
func (c *CLab) CreateNodes(ctx context.Context, maxWorkers uint, dm dependency_manager.DependencyManager, ) (*sync.WaitGroup, error)
CreateNodes schedules nodes creation and returns a waitgroup for all nodes. Nodes interdependencies are created in this function.
func (*CLab) DeleteNodes ¶ added in v0.15.0
func (*CLab) GenerateDotGraph ¶ added in v0.43.0
GenerateDotGraph generates a graph of the lab topology.
func (*CLab) GenerateExports ¶ added in v0.26.0
GenerateExports generates various export files and writes it to a lab location.
func (*CLab) GenerateInventories ¶
GenerateInventories generate various inventory files and writes it to a lab location.
func (*CLab) GenerateMermaidGraph ¶ added in v0.43.0
func (*CLab) GetLinkNodes ¶ added in v0.46.0
GetLinkNodes returns all CLab.Nodes nodes as links.Nodes enriched with the special nodes - host and mgmt-net. The CLab nodes are copied to a new map and thus clab.Node interface is converted to link.Node.
func (*CLab) GetNodeRuntime ¶ added in v0.15.0
func (c *CLab) GetNodeRuntime(contName string) (runtime.ContainerRuntime, error)
func (*CLab) GetSpecialLinkNodes ¶ added in v0.46.0
GetSpecialLinkNodes returns a map of special nodes that are used to resolve links. Special nodes are host and mgmt-bridge nodes that are not typically present in the topology file but are required to resolve links.
func (*CLab) GetTopology ¶
GetTopology parses the topology file into c.Conf structure as well as populates the TopoFile structure with the topology file related information.
func (*CLab) GlobalRuntime ¶ added in v0.15.0
func (c *CLab) GlobalRuntime() runtime.ContainerRuntime
func (*CLab) HasKind ¶ added in v0.25.0
HasKind returns true if kind k is found in the list of nodes.
func (*CLab) ListContainers ¶
func (c *CLab) ListContainers(ctx context.Context, filter []*types.GenericFilter) ([]runtime.GenericContainer, error)
ListContainers lists all containers using provided filter.
func (*CLab) ListNodesContainers ¶ added in v0.34.0
ListNodesContainers lists all containers based on the nodes stored in clab instance.
func (*CLab) ListNodesContainersIgnoreNotFound ¶ added in v0.44.0
func (c *CLab) ListNodesContainersIgnoreNotFound(ctx context.Context) ([]runtime.GenericContainer, error)
ListNodesContainersIgnoreNotFound lists all containers based on the nodes stored in clab instance, ignoring errors for non found containers.
func (*CLab) LoadKernelModules ¶ added in v0.41.0
LoadKernelModules loads containerlab-required kernel modules.
func (*CLab) LoadOrGenerateCA ¶ added in v0.37.0
func (c *CLab) LoadOrGenerateCA(caCertInput *cert.CACSRInput) error
LoadOrGenerateCA loads the CA certificate from the storage, or generates a new one if it does not exist.
func (*CLab) RegisterNodes ¶ added in v0.35.0
func (c *CLab) RegisterNodes()
RegisterNodes registers all the nodes/kinds supported by containerlab.
func (*CLab) RemoveHostOrBridgeVeth ¶ added in v0.32.4
RemoveHostOrBridgeVeth tries to remove veths connected to the host network namespace or a linux bridge and does nothing in case they are not found.
func (*CLab) ResolveLinks ¶ added in v0.44.0
ResolveLinks resolves raw links to the actual link types and stores them in the CLab.Links map.
func (*CLab) RetrieveSSHPubKeys ¶ added in v0.44.0
RetrieveSSHPubKeys retrieves the PubKeys from the different sources SSHAgent as well as all home dir based /.ssh/*.pub files.
func (*CLab) ServeTopoGraph ¶ added in v0.25.0
func (*CLab) SetClabIntfsEnvVar ¶ added in v0.44.3
func (c *CLab) SetClabIntfsEnvVar()
setClabIntfsEnvVar sets CLAB_INTFS env var for each node which holds the number of interfaces a node expects to have (without mgmt interfaces).
func (*CLab) VerifyContainersUniqueness ¶
VerifyContainersUniqueness ensures that nodes defined in the topology do not have names of the existing containers additionally it checks that the lab name is unique and no containers are currently running with the same lab name label.
func (*CLab) WaitForExternalNodeDependencies ¶ added in v0.32.0
WaitForExternalNodeDependencies makes nodes that have a reference to an external container network-namespace (network-mode: container:<NAME>) to wait until the referenced container is in started status. The wait time is 15 minutes by default.
type ClabOption ¶
func WithKeepMgmtNet ¶ added in v0.15.0
func WithKeepMgmtNet() ClabOption
func WithNodeFilter ¶ added in v0.39.0
func WithNodeFilter(nodeFilter []string) ClabOption
WithNodeFilter option sets a filter for nodes to be deployed. A filter is a list of node names to be deployed, names are provided exactly as they are listed in the topology file. Since this is altering the clab.config.Topology.[Nodes,Links] it must only be called after WithTopoFile.
func WithRuntime ¶ added in v0.14.0
func WithRuntime(name string, rtconfig *runtime.RuntimeConfig) ClabOption
WithRuntime option sets a container runtime to be used by containerlab.
func WithTimeout ¶
func WithTimeout(dur time.Duration) ClabOption
func WithTopoPath ¶ added in v0.45.0
func WithTopoPath(path, varsFile string) ClabOption
type Config ¶
type Config struct { Name string `json:"name,omitempty"` Prefix *string `json:"prefix,omitempty"` Mgmt *types.MgmtNet `json:"mgmt,omitempty"` Settings *types.Settings `json:"settings,omitempty"` Topology *types.Topology `json:"topology,omitempty"` // the debug flag value as passed via cli // may be used by other packages to enable debug logging Debug bool `json:"debug"` }
Config defines lab configuration as it is provided in the YAML file.
type GraphTopo ¶ added in v0.25.0
type GraphTopo struct { Nodes []types.ContainerDetails `json:"nodes,omitempty"` Links []Link `json:"links,omitempty"` }
type TopologyExport ¶ added in v0.26.0
type TopologyExport struct { Name string `json:"name"` Type string `json:"type"` Clab *CLab `json:"clab,omitempty"` NodeConfigs map[string]*types.NodeConfig `json:"nodeconfigs,omitempty"` }
TopologyExport holds a combination of CLab structure and map of NodeConfig types, which expands Node definitions with dynamically created values.
type VxLAN ¶
type VxLAN struct { Name string // interface name ParentIf string // parent interface name ID int // VxLan ID Remote net.IP // VxLan destination address MTU int // VxLan Interface MTU (with VxLan encap), used mirroring UDPPort int // VxLan UDP port (src/dest, no range, single value) }
VxLAN is a structure to describe vxlan endpoint adopted from https://github.com/redhat-nfvpe/koko/blob/bd156c82bf25837545fb109c69c7b91c3457b318/api/koko_api.go#L46