Documentation ¶
Index ¶
- Constants
- type Bind
- type CertificateAuthority
- type CertificateConfig
- type ConfigDispatcher
- type ContainerDetails
- type DNSConfig
- type Endpoint
- type Exec
- type ExecPhase
- type ExecTarget
- type Execs
- type Extras
- type FailBehaviour
- type GenericFilter
- type GenericPortBinding
- type HealthcheckConfig
- type HostRequirements
- type K8sKindDeployExtras
- type K8sKindExtras
- type LabData
- type LicensePolicy
- type Link
- type MgmtNet
- type NodeConfig
- type NodeDefinition
- func (n *NodeDefinition) GetAutoRemove() *bool
- func (n *NodeDefinition) GetBinds() []string
- func (n *NodeDefinition) GetCertificateConfig() *CertificateConfig
- func (n *NodeDefinition) GetCmd() string
- func (n *NodeDefinition) GetConfigDispatcher() *ConfigDispatcher
- func (n *NodeDefinition) GetDns() *DNSConfig
- func (n *NodeDefinition) GetEnforceStartupConfig() *bool
- func (n *NodeDefinition) GetEntrypoint() string
- func (n *NodeDefinition) GetEnv() map[string]string
- func (n *NodeDefinition) GetEnvFiles() []string
- func (n *NodeDefinition) GetExec() []string
- func (n *NodeDefinition) GetExtras() *Extras
- func (n *NodeDefinition) GetGroup() string
- func (n *NodeDefinition) GetHealthcheckConfig() *HealthcheckConfig
- func (n *NodeDefinition) GetImage() string
- func (n *NodeDefinition) GetImagePullPolicy() string
- func (n *NodeDefinition) GetKind() string
- func (n *NodeDefinition) GetLabels() map[string]string
- func (n *NodeDefinition) GetLicense() string
- func (n *NodeDefinition) GetMgmtIPv4() string
- func (n *NodeDefinition) GetMgmtIPv6() string
- func (n *NodeDefinition) GetNetworkMode() string
- func (n *NodeDefinition) GetNodeCPU() float64
- func (n *NodeDefinition) GetNodeCPUSet() string
- func (n *NodeDefinition) GetNodeKernel() string
- func (n *NodeDefinition) GetNodeMemory() string
- func (n *NodeDefinition) GetNodeRuntime() string
- func (n *NodeDefinition) GetNodeSandbox() string
- func (n *NodeDefinition) GetPorts() []string
- func (n *NodeDefinition) GetPostion() string
- func (n *NodeDefinition) GetPublish() []string
- func (n *NodeDefinition) GetRestartPolicy() string
- func (n *NodeDefinition) GetStages() *Stages
- func (n *NodeDefinition) GetStartupConfig() string
- func (n *NodeDefinition) GetStartupDelay() uint
- func (n *NodeDefinition) GetSuppressStartupConfig() *bool
- func (n *NodeDefinition) GetSysctls() map[string]string
- func (n *NodeDefinition) GetType() string
- func (n *NodeDefinition) GetUser() string
- func (n *NodeDefinition) ImportEnvs()
- func (n *NodeDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
- type PubkeyAuthValue
- type PullPolicyValue
- type SSHConfig
- type Settings
- type StageBase
- type StageConfigure
- type StageCreate
- type StageCreateLinks
- type StageExit
- type StageHealthy
- type Stages
- type TopoPaths
- func (t *TopoPaths) AnsibleInventoryFileAbsPath() string
- func (t *TopoPaths) AuthorizedKeysFilename() string
- func (t *TopoPaths) CaCSRAbsFilename() string
- func (t *TopoPaths) CaCertAbsFilename() string
- func (t *TopoPaths) CaKeyAbsFilename() string
- func (*TopoPaths) ClabTmpDir() string
- func (t *TopoPaths) GraphDir() string
- func (t *TopoPaths) GraphFilename(ext string) string
- func (t *TopoPaths) NodeCertAbsFilename(nodeName string) string
- func (t *TopoPaths) NodeCertCSRAbsFilename(nodeName string) string
- func (t *TopoPaths) NodeCertKeyAbsFilename(nodeName string) string
- func (t *TopoPaths) NodeDir(nodeName string) string
- func (t *TopoPaths) NodeTLSDir(nodename string) string
- func (t *TopoPaths) SSHConfigPath() string
- func (t *TopoPaths) SetExternalCaFiles(certFile, keyFile string) error
- func (t *TopoPaths) SetLabDir(p string) (err error)
- func (t *TopoPaths) SetLabDirByPrefix(topologyName string) (err error)
- func (t *TopoPaths) SetTopologyFilePath(topologyFile string) error
- func (t *TopoPaths) StartupConfigDownloadFileAbsPath(node, postfix string) string
- func (t *TopoPaths) TLSBaseDir() string
- func (t *TopoPaths) TopoExportFile() string
- func (t *TopoPaths) TopologyBakFileAbsPath() string
- func (t *TopoPaths) TopologyFileDir() string
- func (t *TopoPaths) TopologyFileIsSet() bool
- func (t *TopoPaths) TopologyFilenameAbsPath() string
- func (t *TopoPaths) TopologyFilenameBase() string
- func (t *TopoPaths) TopologyFilenameWithoutExt() string
- func (t *TopoPaths) TopologyLabDir() string
- type Topology
- func (t *Topology) GetCertificateConfig(name string) *CertificateConfig
- func (t *Topology) GetDefaults() *NodeDefinition
- func (t *Topology) GetHealthCheckConfig(name string) *HealthcheckConfig
- func (t *Topology) GetKind(kind string) *NodeDefinition
- func (t *Topology) GetKinds() map[string]*NodeDefinition
- func (t *Topology) GetNodeAutoRemove(name string) bool
- func (t *Topology) GetNodeBinds(name string) ([]string, error)
- func (t *Topology) GetNodeCPU(name string) float64
- func (t *Topology) GetNodeCPUSet(name string) string
- func (t *Topology) GetNodeCmd(name string) string
- func (t *Topology) GetNodeConfigDispatcher(name string) *ConfigDispatcher
- func (t *Topology) GetNodeDns(name string) *DNSConfig
- func (t *Topology) GetNodeEnforceStartupConfig(name string) bool
- func (t *Topology) GetNodeEntrypoint(name string) string
- func (t *Topology) GetNodeEnv(name string) map[string]string
- func (t *Topology) GetNodeEnvFiles(name string) []string
- func (t *Topology) GetNodeExec(name string) []string
- func (t *Topology) GetNodeExtras(name string) *Extras
- func (t *Topology) GetNodeGroup(name string) string
- func (t *Topology) GetNodeImage(name string) string
- func (t *Topology) GetNodeImagePullPolicy(name string) PullPolicyValue
- func (t *Topology) GetNodeKernel(name string) string
- func (t *Topology) GetNodeKind(name string) string
- func (t *Topology) GetNodeLabels(name string) map[string]string
- func (t *Topology) GetNodeLicense(name string) string
- func (t *Topology) GetNodeMemory(name string) string
- func (t *Topology) GetNodeNetworkMode(name string) string
- func (t *Topology) GetNodePorts(name string) (nat.PortSet, nat.PortMap, error)
- func (t *Topology) GetNodePosition(name string) string
- func (t *Topology) GetNodePublish(name string) []string
- func (t *Topology) GetNodeRuntime(name string) string
- func (t *Topology) GetNodeSandbox(name string) string
- func (t *Topology) GetNodeStartupConfig(name string) string
- func (t *Topology) GetNodeStartupDelay(name string) uint
- func (t *Topology) GetNodeSuppressStartupConfig(name string) bool
- func (t *Topology) GetNodeType(name string) string
- func (t *Topology) GetNodeUser(name string) string
- func (t *Topology) GetRestartPolicy(name string) string
- func (t *Topology) GetStages(name string) (*Stages, error)
- func (t *Topology) GetSysCtl(name string) map[string]string
- func (t *Topology) ImportEnvs()
- type WaitFor
- type WaitForList
- type WaitForStage
Constants ¶
const ( // LicensePolicyRequired means a node should exit if no license provided. LicensePolicyRequired = "required" // LicensePolicyWarn means a node should warn (but not exit) if no license provided. LicensePolicyWarn = "warn" // LicensePolicyNone means a node doesn't care about a license. LicensePolicyNone = "none" )
const ( CertFileSuffix = ".pem" KeyFileSuffix = ".key" CSRFileSuffix = ".csr" )
const (
// env var containing the expected number of interfaces injected into every container.
CLAB_ENV_INTFS = "CLAB_INTFS"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bind ¶ added in v0.43.0
type Bind struct {
// contains filtered or unexported fields
}
Bind represents a bind mount.
type CertificateAuthority ¶ added in v0.44.0
type CertificateAuthority struct { // Cert is the path to the CA certificate file in the External CA mode of operation. Cert string `yaml:"cert"` // Key is the path to the CA private key file in the External CA mode of operation. Key string `yaml:"key"` // KeySize is the size of the CA private key in bits // when containerlab is in charge of the CA generation. KeySize int `yaml:"key-size"` // ValidityDuration is the duration of the CA certificate validity // when containerlab is in charge of the CA generation. ValidityDuration time.Duration `yaml:"validity-duration"` }
CertificateAuthority is the structure for global containerlab certificate authority settings.
type CertificateConfig ¶ added in v0.39.0
type CertificateConfig struct { // default false value indicates that the node does not use TLS Issue *bool `yaml:"issue,omitempty"` // KeySize is the size of the key in bits KeySize int `yaml:"key-size,omitempty"` // ValidityDuration is the duration of the certificate validity ValidityDuration time.Duration `yaml:"validity-duration"` // list of subject Alternative Names (SAN) to be added to the node's certificate SANs []string `yaml:"sans,omitempty"` }
CertificateConfig represents TLS parameters set for a node.
func (*CertificateConfig) Merge ¶ added in v0.44.0
func (c *CertificateConfig) Merge(x *CertificateConfig) *CertificateConfig
Merge merges the given CertificateConfig into the current one.
type ConfigDispatcher ¶ added in v0.15.0
type ConfigDispatcher struct {
Vars map[string]interface{} `yaml:"vars,omitempty"`
}
ConfigDispatcher represents the config of a configuration machine that is responsible to execute configuration commands on the nodes after they started.
func (*ConfigDispatcher) GetVars ¶ added in v0.15.0
func (cd *ConfigDispatcher) GetVars() map[string]interface{}
type ContainerDetails ¶ added in v0.25.0
type ContainerDetails struct { LabName string `json:"lab_name,omitempty"` LabPath string `json:"labPath,omitempty"` Name string `json:"name,omitempty"` ContainerID string `json:"container_id,omitempty"` Image string `json:"image,omitempty"` Kind string `json:"kind,omitempty"` Group string `json:"group,omitempty"` State string `json:"state,omitempty"` IPv4Address string `json:"ipv4_address,omitempty"` IPv6Address string `json:"ipv6_address,omitempty"` Ports []*GenericPortBinding `json:"ports,omitempty"` Owner string `json:"owner,omitempty"` }
ContainerDetails contains information that is commonly outputted to tables or graphs.
type DNSConfig ¶ added in v0.35.0
type DNSConfig struct { // DNS servers Servers []string `yaml:"servers,omitempty"` // DNS options Options []string `yaml:"options,omitempty"` // DNS Search Domains Search []string `yaml:"search,omitempty"` }
DNSConfig represents DNS configuration options a node has.
type Endpoint ¶
type Endpoint struct { Node *NodeConfig // e1-x, eth, etc EndpointName string // mac address MAC string }
Endpoint is a struct that contains information of a link endpoint.
type Exec ¶ added in v0.59.0
type Exec struct { Command string `yaml:"command,omitempty"` Target ExecTarget `yaml:"target,omitempty"` Phase ExecPhase `yaml:"phase,omitempty"` }
func (*Exec) InitDefaults ¶ added in v0.59.0
func (c *Exec) InitDefaults()
InitDefaults sets default values for Exec.
type ExecPhase ¶ added in v0.59.0
type ExecPhase string
const ( // CommandExecutionPhaseEnter represents a command to be executed when the node enters the stage. CommandExecutionPhaseEnter ExecPhase = "on-enter" // CommandExecutionPhaseExit represents a command to be executed when the node exits the stage. CommandExecutionPhaseExit ExecPhase = "on-exit" )
type ExecTarget ¶ added in v0.59.0
type ExecTarget string
const ( // CommandTargetContainer determines that the commands are meant to be executed within the container CommandTargetContainer ExecTarget = "container" // CommandTargetHost determines that the commands are meant to be executed on the host system CommandTargetHost ExecTarget = "host" )
type Execs ¶ added in v0.52.0
type Execs []*Exec
Execs represents a list of Exec configurations.
func (Execs) HasCommands ¶ added in v0.52.0
HasCommands returns true if the Execs contains at least one command.
func (Execs) InitDefaults ¶ added in v0.59.0
func (execs Execs) InitDefaults()
InitDefaults sets default values for Execs.
type Extras ¶ added in v0.18.0
type Extras struct { // Nokia SR Linux agents. As of now just the agents spec files can be provided here SRLAgents []string `yaml:"srl-agents,omitempty"` // Proxy address that mysocketctl will use MysocketProxy string `yaml:"mysocket-proxy,omitempty"` // paths to files which are to be copied to ceos flash dir CeosCopyToFlash []string `yaml:"ceos-copy-to-flash,omitempty"` // k8s-kind node specific options K8sKind *K8sKindExtras `yaml:"k8s_kind,omitempty"` }
Extras contains extra node parameters which are not entitled to be part of a generic node config.
type FailBehaviour ¶ added in v0.36.0
type FailBehaviour int
const ( FailBehaviourLog FailBehaviour = iota FailBehaviourError )
type GenericFilter ¶ added in v0.15.0
type GenericFilter struct { // defined by now "label" / "name" [then only Match is required] FilterType string // defines e.g. the label name for FilterType "label" Field string // = | != | exists Operator string // match value Match string }
func FilterFromLabelStrings ¶ added in v0.15.0
func FilterFromLabelStrings(labels []string) []*GenericFilter
FilterFromLabelStrings creates a GenericFilter based on the list of label=value pairs or just label entries. A filter of type `label` is created. For each label=value input label, a filter with the Field matching the label and Match matching the value is created. For each standalone label, a filter with Operator=exists and Field matching the label is created.
type GenericPortBinding ¶ added in v0.43.0
type GenericPortBinding struct { HostIP string `json:"host_ip,omitempty"` HostPort int `json:"host_port,omitempty"` ContainerPort int `json:"port,omitempty"` Protocol string `json:"protocol,omitempty"` }
GenericPortBinding represents a port binding.
func (*GenericPortBinding) String ¶ added in v0.43.0
func (p *GenericPortBinding) String() string
type HealthcheckConfig ¶ added in v0.49.0
type HealthcheckConfig struct { // Test is the command to run to check the health of the container Test []string `yaml:"test,omitempty"` // Interval is the time to wait between checks in seconds Interval int `yaml:"interval,omitempty"` // Timeout is the time in seconds to wait before considering the check to have hung Timeout int `yaml:"timeout,omitempty"` // Retries is the number of consecutive failures needed to consider a container as unhealthy Retries int `yaml:"retries,omitempty"` // StartPeriod is the time to wait for the container to initialize // before starting health-retries countdown in seconds StartPeriod int `yaml:"start-period,omitempty"` }
HealthcheckConfig represents healthcheck parameters set for a container.
func (*HealthcheckConfig) GetIntervalDuration ¶ added in v0.49.0
func (h *HealthcheckConfig) GetIntervalDuration() time.Duration
GetIntervalDuration returns the interval as time.Duration.
func (*HealthcheckConfig) GetStartPeriodDuration ¶ added in v0.49.0
func (h *HealthcheckConfig) GetStartPeriodDuration() time.Duration
GetStartPeriodDuration returns the start period as time.Duration.
func (*HealthcheckConfig) GetTimeoutDuration ¶ added in v0.49.0
func (h *HealthcheckConfig) GetTimeoutDuration() time.Duration
GetTimeoutDuration returns the timeout as time.Duration.
type HostRequirements ¶ added in v0.26.0
type HostRequirements struct { SSSE3 bool `json:"ssse3,omitempty"` // ssse3 cpu instruction // indicates that KVM virtualization is required for this node to run VirtRequired bool `json:"virt-required,omitempty"` // the minimum amount of vcpus this node requires MinVCPU int `json:"min-vcpu,omitempty"` MinVCPUFailAction FailBehaviour `json:"min-vcpu-fail-action,omitempty"` // The minimum amount of memory this node requires MinAvailMemoryGb int `json:"min-free-memory,omitempty"` MinAvailMemoryGbFailAction FailBehaviour `json:"min-free-memory-fail-action,omitempty"` }
func NewHostRequirements ¶ added in v0.36.0
func NewHostRequirements() *HostRequirements
NewHostRequirements is the constructor for new HostRequirements structs.
func (*HostRequirements) Verify ¶ added in v0.34.0
func (h *HostRequirements) Verify(kindName, nodeName string) error
Verify runs verification checks against the host requirements set for a node.
type K8sKindDeployExtras ¶ added in v0.52.0
type K8sKindDeployExtras struct {
Wait *string `yaml:"wait,omitempty"`
}
K8sKindDeployExtras represents the options used for the kind cluster creation. It is aligned with the `kind create cluster` command options, but exposes only the ones that are relevant for containerlab.
type K8sKindExtras ¶ added in v0.52.0
type K8sKindExtras struct {
Deploy *K8sKindDeployExtras `yaml:"deploy,omitempty"`
}
K8sKindExtras represents the k8s-kind-specific extra options.
type LabData ¶ added in v0.31.0
type LabData struct {
Containers []ContainerDetails `json:"containers"`
}
type LicensePolicy ¶ added in v0.40.0
type LicensePolicy string
LicensePolicy is a value of LicensePolicy.
type Link ¶
type Link struct { A *Endpoint B *Endpoint MTU int Labels map[string]string Vars map[string]interface{} }
Link is a struct that contains the information of a link between 2 containers.
type MgmtNet ¶
type MgmtNet struct { Network string `yaml:"network,omitempty" json:"network,omitempty"` // container runtime network name Bridge string `yaml:"bridge,omitempty" json:"bridge,omitempty"` // linux bridge backing the runtime network IPv4Subnet string `yaml:"ipv4-subnet,omitempty" json:"ipv4-subnet,omitempty"` IPv4Gw string `yaml:"ipv4-gw,omitempty" json:"ipv4-gw,omitempty"` IPv4Range string `yaml:"ipv4-range,omitempty" json:"ipv4-range,omitempty"` IPv6Subnet string `yaml:"ipv6-subnet,omitempty" json:"ipv6-subnet,omitempty"` IPv6Gw string `yaml:"ipv6-gw,omitempty" json:"ipv6-gw,omitempty"` IPv6Range string `yaml:"ipv6-range,omitempty" json:"ipv6-range,omitempty"` MTU int `yaml:"mtu,omitempty" json:"mtu,omitempty"` ExternalAccess *bool `yaml:"external-access,omitempty" json:"external-access,omitempty"` }
MgmtNet struct defines the management network options.
func (*MgmtNet) UnmarshalYAML ¶ added in v0.41.1
UnmarshalYAML is a custom unmarshaller for MgmtNet that allows to map old attributes to new ones.
type NodeConfig ¶ added in v0.15.0
type NodeConfig struct { // name of the Node inside topology YAML ShortName string `json:"shortname,omitempty"` // containerlab-prefixed unique container name LongName string `json:"longname,omitempty"` Fqdn string `json:"fqdn,omitempty"` // LabDir is a directory related to the node, it contains config items and/or other persistent state LabDir string `json:"labdir,omitempty"` Index int `json:"index,omitempty"` Group string `json:"group,omitempty"` Kind string `json:"kind,omitempty"` // path to config template file that is used for startup config generation StartupConfig string `json:"startup-config,omitempty"` // optional delay (in seconds) to wait before creating this node StartupDelay uint `json:"startup-delay,omitempty"` // when set to true will enforce the use of startup-config, even when config is present in the lab directory EnforceStartupConfig bool `json:"enforce-startup-config,omitempty"` // when set to true will prevent creation of a startup-config, for auto-provisioning testing (ZTP) SuppressStartupConfig bool `json:"suppress-startup-config,omitempty"` // when set to true will auto-remove a stopped/failed container AutoRemove bool `json:"auto-remove,omitempty"` RestartPolicy string `json:"restart-policy,omitempty"` // path to config file that is actually mounted to the container and is a result of templation ResStartupConfig string `json:"startup-config-abs-path,omitempty"` Config *ConfigDispatcher `json:"config,omitempty"` // path to config file that is actually mounted to the container and is a result of templation ResConfig string `json:"config-abs-path,omitempty"` NodeType string `json:"type,omitempty"` Position string `json:"position,omitempty"` License string `json:"license,omitempty"` Image string `json:"image,omitempty"` ImagePullPolicy PullPolicyValue `json:"image-pull-policy,omitempty"` Sysctls map[string]string `json:"sysctls,omitempty"` User string `json:"user,omitempty"` Entrypoint string `json:"entrypoint,omitempty"` Cmd string `json:"cmd,omitempty"` // Exec is a list of commands to execute inside the container backing the node. Exec []string `json:"exec,omitempty"` Env map[string]string `json:"env,omitempty"` // Bind mounts strings (src:dest:options). Binds []string `json:"binds,omitempty"` // PortBindings define the bindings between the container ports and host ports PortBindings nat.PortMap `json:"portbindings,omitempty"` // ResultingPortBindings is a list of port bindings that are actually applied to the container ResultingPortBindings []*GenericPortBinding `json:"port-bindings,omitempty"` // PortSet define the ports that should be exposed on a container PortSet nat.PortSet `json:"portset,omitempty"` // NetworkMode defines container networking mode. // If set to `host` the host networking will be used for this node, else bridged network NetworkMode string `json:"networkmode,omitempty"` // MgmtNet is the name of the docker network this node is connected to with its first interface MgmtNet string `json:"mgmt-net,omitempty"` // MgmtIntf can be used to be rendered by the default node template MgmtIntf string `json:"mgmt-intf,omitempty"` MgmtIPv4Address string `json:"mgmt-ipv4-address,omitempty"` MgmtIPv4PrefixLength int `json:"mgmt-ipv4-prefix-length,omitempty"` MgmtIPv6Address string `json:"mgmt-ipv6-address,omitempty"` MgmtIPv6PrefixLength int `json:"mgmt-ipv6-prefix-length,omitempty"` MgmtIPv4Gateway string `json:"mgmt-ipv4-gateway,omitempty"` MgmtIPv6Gateway string `json:"mgmt-ipv6-gateway,omitempty"` MacAddress string `json:"mac-address,omitempty"` ContainerID string `json:"containerid,omitempty"` TLSCert string `json:"tls-cert,omitempty"` TLSKey string `json:"-"` // Do not marshal into JSON - highly sensitive data TLSAnchor string `json:"tls-anchor,omitempty"` // TLS Certificate configuration Certificate *CertificateConfig // Healthcheck configuration parameters Healthcheck *HealthcheckConfig // NSPath string `json:"nspath,omitempty"` // network namespace path for this node // list of ports to publish with mysocketctl Publish []string `json:"publish,omitempty"` // Extra /etc/hosts entries for all nodes. ExtraHosts []string `json:"extra-hosts,omitempty"` Labels map[string]string `json:"labels,omitempty"` // container labels // Ignite sandbox and kernel imageNames Sandbox string `json:"sandbox,omitempty"` Kernel string `json:"kernel,omitempty"` // Configured container runtime Runtime string `json:"runtime,omitempty"` // Resource limits CPU float64 `json:"cpu,omitempty"` CPUSet string `json:"cpuset,omitempty"` Memory string `json:"memory,omitempty"` // Extra node parameters Extras *Extras `json:"extras,omitempty"` Stages *Stages `json:"stages,omitempty"` DNS *DNSConfig `json:"dns,omitempty"` // Kind parameters // // IsRootNamespaceBased flag indicates that a certain nodes network // namespace (usually based on the kind) is the root network namespace IsRootNamespaceBased bool // SkipUniquenessCheck prevents the pre-deploy uniqueness check, where // we check, that the given node name is not already present on the host. // Introduced to prevent the check from running with ext-containers, since // they should be present by definition. SkipUniquenessCheck bool }
NodeConfig contains information of a container element.
type NodeDefinition ¶ added in v0.15.0
type NodeDefinition struct { Kind string `yaml:"kind,omitempty"` Group string `yaml:"group,omitempty"` Type string `yaml:"type,omitempty"` StartupConfig string `yaml:"startup-config,omitempty"` StartupDelay uint `yaml:"startup-delay,omitempty"` EnforceStartupConfig *bool `yaml:"enforce-startup-config,omitempty"` SuppressStartupConfig *bool `yaml:"suppress-startup-config,omitempty"` AutoRemove *bool `yaml:"auto-remove,omitempty"` RestartPolicy string `yaml:"restart-policy,omitempty"` Config *ConfigDispatcher `yaml:"config,omitempty"` Image string `yaml:"image,omitempty"` ImagePullPolicy string `yaml:"image-pull-policy,omitempty"` License string `yaml:"license,omitempty"` Position string `yaml:"position,omitempty"` Entrypoint string `yaml:"entrypoint,omitempty"` Cmd string `yaml:"cmd,omitempty"` // list of commands to run in container Exec []string `yaml:"exec,omitempty"` // list of bind mount compatible strings Binds []string `yaml:"binds,omitempty"` // list of port bindings Ports []string `yaml:"ports,omitempty"` // user-defined IPv4 address in the management network MgmtIPv4 string `yaml:"mgmt-ipv4,omitempty"` // user-defined IPv6 address in the management network MgmtIPv6 string `yaml:"mgmt-ipv6,omitempty"` // list of ports to publish with mysocketctl Publish []string `yaml:"publish,omitempty"` // environment variables Env map[string]string `yaml:"env,omitempty"` // external file containing environment variables EnvFiles []string `yaml:"env-files,omitempty"` // linux user used in a container User string `yaml:"user,omitempty"` // container labels Labels map[string]string `yaml:"labels,omitempty"` // container networking mode. if set to `host` the host networking will be used for this node, else bridged network NetworkMode string `yaml:"network-mode,omitempty"` // Ignite sandbox and kernel imageNames Sandbox string `yaml:"sandbox,omitempty"` Kernel string `yaml:"kernel,omitempty"` // Override container runtime Runtime string `yaml:"runtime,omitempty"` // Set node CPU (cgroup or hypervisor) CPU float64 `yaml:"cpu,omitempty"` // Set node CPUs to use CPUSet string `yaml:"cpu-set,omitempty"` // Set node Memory (cgroup or hypervisor) Memory string `yaml:"memory,omitempty"` // Set the nodes Sysctl Sysctls map[string]string `yaml:"sysctls,omitempty"` // Extra options, may be kind specific Extras *Extras `yaml:"extras,omitempty"` // Deployment stages Stages *Stages `yaml:"stages,omitempty"` // DNS configuration DNS *DNSConfig `yaml:"dns,omitempty"` // Certificate configuration Certificate *CertificateConfig `yaml:"certificate,omitempty"` // Healthcheck configuration HealthCheck *HealthcheckConfig `yaml:"healthcheck,omitempty"` }
NodeDefinition represents a configuration a given node can have in the lab definition file.
func (*NodeDefinition) GetAutoRemove ¶ added in v0.32.2
func (n *NodeDefinition) GetAutoRemove() *bool
func (*NodeDefinition) GetBinds ¶ added in v0.15.0
func (n *NodeDefinition) GetBinds() []string
func (*NodeDefinition) GetCertificateConfig ¶ added in v0.39.0
func (n *NodeDefinition) GetCertificateConfig() *CertificateConfig
func (*NodeDefinition) GetCmd ¶ added in v0.15.0
func (n *NodeDefinition) GetCmd() string
func (*NodeDefinition) GetConfigDispatcher ¶ added in v0.15.0
func (n *NodeDefinition) GetConfigDispatcher() *ConfigDispatcher
func (*NodeDefinition) GetDns ¶ added in v0.35.0
func (n *NodeDefinition) GetDns() *DNSConfig
func (*NodeDefinition) GetEnforceStartupConfig ¶ added in v0.17.0
func (n *NodeDefinition) GetEnforceStartupConfig() *bool
func (*NodeDefinition) GetEntrypoint ¶ added in v0.18.0
func (n *NodeDefinition) GetEntrypoint() string
func (*NodeDefinition) GetEnv ¶ added in v0.15.0
func (n *NodeDefinition) GetEnv() map[string]string
func (*NodeDefinition) GetEnvFiles ¶ added in v0.26.0
func (n *NodeDefinition) GetEnvFiles() []string
func (*NodeDefinition) GetExec ¶ added in v0.18.0
func (n *NodeDefinition) GetExec() []string
func (*NodeDefinition) GetExtras ¶ added in v0.18.0
func (n *NodeDefinition) GetExtras() *Extras
func (*NodeDefinition) GetGroup ¶ added in v0.15.0
func (n *NodeDefinition) GetGroup() string
func (*NodeDefinition) GetHealthcheckConfig ¶ added in v0.49.0
func (n *NodeDefinition) GetHealthcheckConfig() *HealthcheckConfig
func (*NodeDefinition) GetImage ¶ added in v0.15.0
func (n *NodeDefinition) GetImage() string
func (*NodeDefinition) GetImagePullPolicy ¶ added in v0.36.0
func (n *NodeDefinition) GetImagePullPolicy() string
func (*NodeDefinition) GetKind ¶ added in v0.15.0
func (n *NodeDefinition) GetKind() string
func (*NodeDefinition) GetLabels ¶ added in v0.15.0
func (n *NodeDefinition) GetLabels() map[string]string
func (*NodeDefinition) GetLicense ¶ added in v0.15.0
func (n *NodeDefinition) GetLicense() string
func (*NodeDefinition) GetMgmtIPv4 ¶ added in v0.15.0
func (n *NodeDefinition) GetMgmtIPv4() string
func (*NodeDefinition) GetMgmtIPv6 ¶ added in v0.15.0
func (n *NodeDefinition) GetMgmtIPv6() string
func (*NodeDefinition) GetNetworkMode ¶ added in v0.15.0
func (n *NodeDefinition) GetNetworkMode() string
func (*NodeDefinition) GetNodeCPU ¶ added in v0.16.2
func (n *NodeDefinition) GetNodeCPU() float64
func (*NodeDefinition) GetNodeCPUSet ¶ added in v0.20.0
func (n *NodeDefinition) GetNodeCPUSet() string
func (*NodeDefinition) GetNodeKernel ¶ added in v0.15.0
func (n *NodeDefinition) GetNodeKernel() string
func (*NodeDefinition) GetNodeMemory ¶ added in v0.20.0
func (n *NodeDefinition) GetNodeMemory() string
func (*NodeDefinition) GetNodeRuntime ¶ added in v0.15.0
func (n *NodeDefinition) GetNodeRuntime() string
func (*NodeDefinition) GetNodeSandbox ¶ added in v0.15.0
func (n *NodeDefinition) GetNodeSandbox() string
func (*NodeDefinition) GetPorts ¶ added in v0.15.0
func (n *NodeDefinition) GetPorts() []string
func (*NodeDefinition) GetPostion ¶ added in v0.15.0
func (n *NodeDefinition) GetPostion() string
func (*NodeDefinition) GetPublish ¶ added in v0.15.0
func (n *NodeDefinition) GetPublish() []string
func (*NodeDefinition) GetRestartPolicy ¶ added in v0.59.0
func (n *NodeDefinition) GetRestartPolicy() string
func (*NodeDefinition) GetStages ¶ added in v0.51.0
func (n *NodeDefinition) GetStages() *Stages
func (*NodeDefinition) GetStartupConfig ¶ added in v0.15.0
func (n *NodeDefinition) GetStartupConfig() string
func (*NodeDefinition) GetStartupDelay ¶ added in v0.17.0
func (n *NodeDefinition) GetStartupDelay() uint
func (*NodeDefinition) GetSuppressStartupConfig ¶ added in v0.45.0
func (n *NodeDefinition) GetSuppressStartupConfig() *bool
func (*NodeDefinition) GetSysctls ¶ added in v0.26.0
func (n *NodeDefinition) GetSysctls() map[string]string
func (*NodeDefinition) GetType ¶ added in v0.15.0
func (n *NodeDefinition) GetType() string
func (*NodeDefinition) GetUser ¶ added in v0.15.0
func (n *NodeDefinition) GetUser() string
func (*NodeDefinition) ImportEnvs ¶ added in v0.17.0
func (n *NodeDefinition) ImportEnvs()
ImportEnvs imports all environment variales defined in the shell if __IMPORT_ENVS is set to true.
func (*NodeDefinition) UnmarshalYAML ¶ added in v0.41.1
func (n *NodeDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is a custom unmarshaller for NodeDefinition type that allows to map old attributes to new ones.
type PubkeyAuthValue ¶ added in v0.48.0
type PubkeyAuthValue string
const ( PubkeyAuthValueYes PubkeyAuthValue = "yes" PubkeyAuthValueNo PubkeyAuthValue = "no" PubkeyAuthValueHostBound PubkeyAuthValue = "host-bound" PubkeyAuthValueUnbound PubkeyAuthValue = "unbound" )
func (PubkeyAuthValue) String ¶ added in v0.48.0
func (p PubkeyAuthValue) String() string
type PullPolicyValue ¶ added in v0.36.0
type PullPolicyValue string
PullPolicyValue represents Image pull policy values.
const ( PullPolicyAlways PullPolicyValue = "Always" PullPolicyNever PullPolicyValue = "Never" PullPolicyIfNotPresent PullPolicyValue = "IfNotPresent" )
func ParsePullPolicyValue ¶ added in v0.36.0
func ParsePullPolicyValue(s string) PullPolicyValue
ParsePullPolicyValue parses the given string and tries to map it to a valid PullPolicyValue. Defaults to PullPolicyIfNotPresent.
type SSHConfig ¶ added in v0.48.0
type SSHConfig struct {
PubkeyAuthentication PubkeyAuthValue
}
SSHConfig is the SSH client configuration that a clab node requires.
func NewSSHConfig ¶ added in v0.48.0
func NewSSHConfig() *SSHConfig
type Settings ¶ added in v0.44.0
type Settings struct {
CertificateAuthority *CertificateAuthority `yaml:"certificate-authority"`
}
Settings is the structure for global containerlab settings.
type StageBase ¶ added in v0.51.0
type StageBase struct { WaitFor WaitForList `yaml:"wait-for,omitempty"` Execs Execs `yaml:"exec,omitempty"` }
StageBase represents a common configuration stage. Other stages embed this type to inherit its configuration options.
type StageConfigure ¶ added in v0.51.0
type StageConfigure struct {
StageBase `yaml:",inline"`
}
StageConfigure represents a stage of a given node when it enters configuration workflow.
func (*StageConfigure) Merge ¶ added in v0.52.0
func (s *StageConfigure) Merge(other *StageConfigure) error
type StageCreate ¶ added in v0.51.0
type StageCreate struct {
StageBase `yaml:",inline"`
}
StageCreate represents a creation stage of a given node.
func (*StageCreate) Merge ¶ added in v0.52.0
func (s *StageCreate) Merge(other *StageCreate) error
type StageCreateLinks ¶ added in v0.51.0
type StageCreateLinks struct {
StageBase `yaml:",inline"`
}
StageCreateLinks represents a stage of a given node when links are getting added to it.
func (*StageCreateLinks) Merge ¶ added in v0.52.0
func (s *StageCreateLinks) Merge(other *StageCreateLinks) error
type StageExit ¶ added in v0.51.0
type StageExit struct {
StageBase `yaml:",inline"`
}
StageExit represents a stage of a given node when the node reaches exit state.
type StageHealthy ¶ added in v0.51.0
type StageHealthy struct {
StageBase `yaml:",inline"`
}
StageHealthy represents a stage of a given node when it reaches healthy status.
func (*StageHealthy) Merge ¶ added in v0.52.0
func (s *StageHealthy) Merge(other *StageHealthy) error
type Stages ¶ added in v0.51.0
type Stages struct { Create *StageCreate `yaml:"create"` CreateLinks *StageCreateLinks `yaml:"create-links"` Configure *StageConfigure `yaml:"configure"` Healthy *StageHealthy `yaml:"healthy"` Exit *StageExit `yaml:"exit"` }
Stages represents a configuration of a given node deployment stage.
func (*Stages) GetWaitFor ¶ added in v0.51.0
func (s *Stages) GetWaitFor() map[WaitForStage]WaitForList
GetWaitFor returns lists of nodes that need to be waited for in a map that is indexed by the state for which this dependency is to be evaluated.
func (*Stages) InitDefaults ¶ added in v0.59.0
func (s *Stages) InitDefaults()
InitDefaults set defaults for the stages.
type TopoPaths ¶ added in v0.37.0
type TopoPaths struct {
// contains filtered or unexported fields
}
TopoPaths creates all the required absolute paths and filenames for a topology. generally all these paths are deduced from two main paths. The topology file path and the lab dir path.
func NewTopoPaths ¶ added in v0.37.0
NewTopoPaths constructs a new TopoPaths instance.
func (*TopoPaths) AnsibleInventoryFileAbsPath ¶ added in v0.37.0
AnsibleInventoryFileAbsPath returns the absolute path to the ansible-inventory file.
func (*TopoPaths) AuthorizedKeysFilename ¶ added in v0.37.0
AuthorizedKeysFilename returns the path for the generated AuthorizedKeysFile.
func (*TopoPaths) CaCSRAbsFilename ¶ added in v0.44.0
func (*TopoPaths) CaCertAbsFilename ¶ added in v0.44.0
CaCertAbsFilename returns the path to the CA cert file. If external CA is used, the path to the external CA cert file is returned. Otherwise the path to the generated CA cert file is returned.
func (*TopoPaths) CaKeyAbsFilename ¶ added in v0.44.0
CaKeyAbsFilename returns the path to the CA key file. If external CA is used, the path to the external CA key file is returned. Otherwise the path to the generated CA key file is returned.
func (*TopoPaths) ClabTmpDir ¶ added in v0.38.0
ClabTmpDir returns the path to the temporary directory where clab stores temporary and/or downloaded files. Creates the directory if it does not exist.
func (*TopoPaths) GraphFilename ¶ added in v0.37.0
GraphFilename returns the filename for a given graph file with the provided extension.
func (*TopoPaths) NodeCertAbsFilename ¶ added in v0.37.0
NodeCertAbsFilename returns the path to a cert file for the given identifier.
func (*TopoPaths) NodeCertCSRAbsFilename ¶ added in v0.37.0
NodeCertCSRAbsFilename returns the path to a csr file for the given identifier.
func (*TopoPaths) NodeCertKeyAbsFilename ¶ added in v0.37.0
NodeCertKeyAbsFilename returns the path to a key file for the given identifier.
func (*TopoPaths) NodeDir ¶ added in v0.37.0
NodeDir returns the directory in the labDir for the provided node.
func (*TopoPaths) NodeTLSDir ¶ added in v0.37.0
NodeTLSDir returns the directory that contains the certificat data for the given node.
func (*TopoPaths) SSHConfigPath ¶ added in v0.47.0
SSHConfigPath returns the topology dependent ssh config file name.
func (*TopoPaths) SetExternalCaFiles ¶ added in v0.44.0
SetExternalCaFiles sets the paths for the cert and key files if externally generated should be used.
func (*TopoPaths) SetLabDirByPrefix ¶ added in v0.48.4
SetLabDirByPrefix sets the labDir foldername (no abs path, but the last element) usually the topology name.
func (*TopoPaths) SetTopologyFilePath ¶ added in v0.37.0
SetTopologyFilePath sets the topology file path.
func (*TopoPaths) StartupConfigDownloadFileAbsPath ¶ added in v0.38.0
StartupConfigDownloadFileAbsPath returns the absolute path to the startup-config file when it is downloaded from a remote location to the clab temp directory.
func (*TopoPaths) TLSBaseDir ¶ added in v0.37.0
TLSBaseDir returns the path of the TLS directory structure.
func (*TopoPaths) TopoExportFile ¶ added in v0.37.0
TopoExportFile returns the path for the topology-export file.
func (*TopoPaths) TopologyBakFileAbsPath ¶ added in v0.37.0
TopologyBakFileAbsPath returns the backup topology file name.
func (*TopoPaths) TopologyFileDir ¶ added in v0.37.0
TopologyFileDir returns the abs path to the topology file directory.
func (*TopoPaths) TopologyFileIsSet ¶ added in v0.37.0
func (*TopoPaths) TopologyFilenameAbsPath ¶ added in v0.37.0
TopologyFilenameAbsPath returns the absolute path to the topology file.
func (*TopoPaths) TopologyFilenameBase ¶ added in v0.37.0
TopologyFilenameBase returns the full filename of the topology file without any additional paths.
func (*TopoPaths) TopologyFilenameWithoutExt ¶ added in v0.37.0
TopologyFilenameWithoutExt returns the topology file name without the file extension.
func (*TopoPaths) TopologyLabDir ¶ added in v0.37.0
TopologyLabDir returns the lab directory.
type Topology ¶ added in v0.15.0
type Topology struct { Defaults *NodeDefinition `yaml:"defaults,omitempty"` Kinds map[string]*NodeDefinition `yaml:"kinds,omitempty"` Nodes map[string]*NodeDefinition `yaml:"nodes,omitempty"` Links []*links.LinkDefinition `yaml:"links,omitempty"` }
Topology represents a lab topology.
func NewTopology ¶ added in v0.15.0
func NewTopology() *Topology
func (*Topology) GetCertificateConfig ¶ added in v0.39.0
func (t *Topology) GetCertificateConfig(name string) *CertificateConfig
GetCertificateConfig returns the certificate configuration for the given node.
func (*Topology) GetDefaults ¶ added in v0.15.0
func (t *Topology) GetDefaults() *NodeDefinition
func (*Topology) GetHealthCheckConfig ¶ added in v0.49.0
func (t *Topology) GetHealthCheckConfig(name string) *HealthcheckConfig
func (*Topology) GetKind ¶ added in v0.15.0
func (t *Topology) GetKind(kind string) *NodeDefinition
func (*Topology) GetKinds ¶ added in v0.15.0
func (t *Topology) GetKinds() map[string]*NodeDefinition
func (*Topology) GetNodeAutoRemove ¶ added in v0.32.2
func (*Topology) GetNodeBinds ¶ added in v0.15.0
func (*Topology) GetNodeCPU ¶ added in v0.16.2
func (*Topology) GetNodeCPUSet ¶ added in v0.20.0
func (*Topology) GetNodeCmd ¶ added in v0.15.0
func (*Topology) GetNodeConfigDispatcher ¶ added in v0.15.0
func (t *Topology) GetNodeConfigDispatcher(name string) *ConfigDispatcher
func (*Topology) GetNodeDns ¶ added in v0.35.0
func (*Topology) GetNodeEnforceStartupConfig ¶ added in v0.17.0
func (*Topology) GetNodeEntrypoint ¶ added in v0.18.0
func (*Topology) GetNodeEnv ¶ added in v0.15.0
func (*Topology) GetNodeEnvFiles ¶ added in v0.26.0
func (*Topology) GetNodeExec ¶ added in v0.18.0
func (*Topology) GetNodeExtras ¶ added in v0.18.0
GetNodeExtras returns the 'extras' section for the given node.
func (*Topology) GetNodeGroup ¶ added in v0.15.0
func (*Topology) GetNodeImage ¶ added in v0.15.0
func (*Topology) GetNodeImagePullPolicy ¶ added in v0.36.0
func (t *Topology) GetNodeImagePullPolicy(name string) PullPolicyValue
func (*Topology) GetNodeKernel ¶ added in v0.15.0
func (*Topology) GetNodeKind ¶ added in v0.15.0
func (*Topology) GetNodeLabels ¶ added in v0.15.0
func (*Topology) GetNodeLicense ¶ added in v0.15.0
func (*Topology) GetNodeMemory ¶ added in v0.20.0
func (*Topology) GetNodeNetworkMode ¶ added in v0.15.0
func (*Topology) GetNodePorts ¶ added in v0.15.0
func (*Topology) GetNodePosition ¶ added in v0.15.0
func (*Topology) GetNodePublish ¶ added in v0.15.0
func (*Topology) GetNodeRuntime ¶ added in v0.15.0
func (*Topology) GetNodeSandbox ¶ added in v0.15.0
func (*Topology) GetNodeStartupConfig ¶ added in v0.15.0
func (*Topology) GetNodeStartupDelay ¶ added in v0.17.0
func (*Topology) GetNodeSuppressStartupConfig ¶ added in v0.45.0
func (*Topology) GetNodeType ¶ added in v0.15.0
func (*Topology) GetNodeUser ¶ added in v0.15.0
func (*Topology) GetRestartPolicy ¶ added in v0.59.0
func (*Topology) GetStages ¶ added in v0.51.0
GetStages return the configuration stages set for the given node. It merges the default, kind and node stages into a single Stages struct with node stages taking precedence over kind stages and default stages.
func (*Topology) GetSysCtl ¶ added in v0.26.0
GetSysCtl return the Sysctl configuration for the given node.
func (*Topology) ImportEnvs ¶ added in v0.17.0
func (t *Topology) ImportEnvs()
type WaitFor ¶ added in v0.51.0
type WaitFor struct { Node string `json:"node"` // the node that is to be waited for Stage WaitForStage `json:"stage,omitempty"` // the stage that the node must have completed }
WaitFor represents the wait-for configuration for a node deployment stage.
type WaitForList ¶ added in v0.51.0
type WaitForList []*WaitFor
WaitForList is a list of WaitFor configurations.
type WaitForStage ¶ added in v0.51.0
type WaitForStage string
WaitForStage defines the stages that nodes go through during the deployment process. They are used to define and enforce dependencies between nodes.
const ( // WaitForCreate is the wait stage name for a node creation stage. WaitForCreate WaitForStage = "create" // WaitForCreateLinks is the wait stage name for a node create-links stage. WaitForCreateLinks WaitForStage = "create-links" // WaitForConfigure is the wait stage name for a node configure stage. WaitForConfigure WaitForStage = "configure" // WaitForHealthy is the wait stage name for a node healthy stage. WaitForHealthy WaitForStage = "healthy" // WaitForExit is the wait stage name for a node exit stage. WaitForExit WaitForStage = "exit" )
func GetWaitForStages ¶ added in v0.51.0
func GetWaitForStages() []WaitForStage
GetWaitForStages returns list of wait for stages that are used to init Waitgroups for all the states.