Documentation
¶
Index ¶
- func New(cfg clablabruntime.Config) (clablabruntime.LabRuntime, error)
- type Runtime
- func (r *Runtime) Attach(ctx context.Context, req clablabruntime.AttachRequest, ...) error
- func (r *Runtime) Capture(ctx context.Context, req clablabruntime.CaptureRequest, w io.Writer) error
- func (r *Runtime) CaptureInterfaces(ctx context.Context, req clablabruntime.NodeRequest) ([]clablabruntime.CaptureInterface, error)
- func (r *Runtime) CheckSupport(ctx context.Context, identity clablabruntime.Identity) error
- func (r *Runtime) Deploy(ctx context.Context, req clablabruntime.DeployRequest) (*clablabruntime.LabState, error)
- func (r *Runtime) Destroy(ctx context.Context, req clablabruntime.DestroyRequest) error
- func (r *Runtime) DialPort(ctx context.Context, req clablabruntime.NodeRequest, port int) (net.Conn, error)
- func (r *Runtime) Exec(ctx context.Context, req clablabruntime.ExecRequest) (*clabexec.ExecResult, error)
- func (r *Runtime) Inspect(ctx context.Context, req clablabruntime.InspectRequest) (*clablabruntime.LabState, error)
- func (r *Runtime) InspectInterfaces(ctx context.Context, req clablabruntime.NodeRequest) ([]*clabtypes.ContainerInterfaces, error)
- func (r *Runtime) LabExists(ctx context.Context, req clablabruntime.InspectRequest) (bool, error)
- func (r *Runtime) List(ctx context.Context, req clablabruntime.ListRequest) ([]*clablabruntime.LabState, error)
- func (r *Runtime) LocateNode(ctx context.Context, req clablabruntime.NodeRequest) ([]clablabruntime.NodeLocation, error)
- func (r *Runtime) Manifests(ctx context.Context, req clablabruntime.DeployRequest) ([]clablabruntime.Manifest, error)
- func (r *Runtime) Plan(ctx context.Context, req clablabruntime.DeployRequest) (*clablabruntime.DeployPlan, error)
- func (r *Runtime) Restart(ctx context.Context, req clablabruntime.NodeRequest) error
- func (r *Runtime) SampleStats(ctx context.Context, req clablabruntime.InspectRequest) ([]clablabruntime.NodeStats, error)
- func (r *Runtime) Save(ctx context.Context, req clablabruntime.SaveRequest) (*clablabruntime.SaveResult, error)
- func (r *Runtime) Start(ctx context.Context, req clablabruntime.NodeRequest) error
- func (r *Runtime) Stop(ctx context.Context, req clablabruntime.NodeRequest) error
- func (r *Runtime) StreamEvents(ctx context.Context, req clablabruntime.EventStreamRequest) (<-chan clablabruntime.Event, <-chan error, error)
- func (r *Runtime) StreamLogs(ctx context.Context, req clablabruntime.LogRequest, w io.Writer) error
- func (r *Runtime) Validate(ctx context.Context, req clablabruntime.DeployRequest) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(cfg clablabruntime.Config) (clablabruntime.LabRuntime, error)
New returns the c9s lab runtime. It does not load the kubeconfig: the Kubernetes clients are created on the first operation that needs the cluster.
Types ¶
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func (*Runtime) Attach ¶ added in v0.83.0
func (r *Runtime) Attach( ctx context.Context, req clablabruntime.AttachRequest, streams clablabruntime.AttachStreams, ) error
Attach runs an interactive command in a node's device container, or in the container the request names, with stdin, an optional TTY and terminal resizing.
func (*Runtime) Capture ¶ added in v0.83.0
func (r *Runtime) Capture( ctx context.Context, req clablabruntime.CaptureRequest, w io.Writer, ) error
Capture streams pcapng from lab link interfaces to w: one section, one Interface Description Block per target in request order named <node>:<interface>, then the packets of every target.
Each node's interfaces are captured by one clabwire process in the node's pod. clabwire limits a capture to one hour, so a longer capture (or one without Duration) chains captures: the next one starts before the current one ends, and the stream switches at a cut in the overlap. See captureChain for how packets of the overlap are kept once.
Packets go out in timestamp order across nodes, through a reorder buffer (captureReorder).
Every clabwire process runs with stdin attached and --stop-on-stdin-close: a Kubernetes exec does not stop its process when the stream closes, so containerlab closes stdin whenever a segment ends (the capture ends, fails, its output fails, or a newer segment took over) and clabwire ends the capture itself.
Capture returns when Duration has passed, PacketLimit packets were written, or ctx ends; an ended ctx is not an error. Every block reaches w in one write, so the stream is a valid capture whenever it stops. A clabwire Denied or Failed audit record is returned as an error.
func (*Runtime) CaptureInterfaces ¶ added in v0.83.0
func (r *Runtime) CaptureInterfaces( ctx context.Context, req clablabruntime.NodeRequest, ) ([]clablabruntime.CaptureInterface, error)
CaptureInterfaces lists the capturable lab link interfaces of the requested nodes, or of every node, as clabwire reports them, with their peers. Node names are reported as the topology spells them.
func (*Runtime) CheckSupport ¶ added in v0.83.0
CheckSupport checks that the cluster runs a clabernetes release with the contract the c9s runtime needs, and returns an error wrapping labruntime.ErrUnsupportedRuntimeVersion that names the required release when it does not. Every cluster operation runs the same check once per runtime instance; servers call it at startup to fail early.
func (*Runtime) Deploy ¶
func (r *Runtime) Deploy( ctx context.Context, req clablabruntime.DeployRequest, ) (*clablabruntime.LabState, error)
func (*Runtime) Destroy ¶
func (r *Runtime) Destroy(ctx context.Context, req clablabruntime.DestroyRequest) error
func (*Runtime) DialPort ¶ added in v0.83.0
func (r *Runtime) DialPort( ctx context.Context, req clablabruntime.NodeRequest, port int, ) (net.Conn, error)
DialPort opens a connection to a TCP port of a node's pod through the Kubernetes port-forward subresource.
func (*Runtime) Exec ¶
func (r *Runtime) Exec( ctx context.Context, req clablabruntime.ExecRequest, ) (*clabexec.ExecResult, error)
func (*Runtime) Inspect ¶
func (r *Runtime) Inspect( ctx context.Context, req clablabruntime.InspectRequest, ) (*clablabruntime.LabState, error)
func (*Runtime) InspectInterfaces ¶ added in v0.83.0
func (r *Runtime) InspectInterfaces( ctx context.Context, req clablabruntime.NodeRequest, ) ([]*clabtypes.ContainerInterfaces, error)
InspectInterfaces lists the interfaces of the requested nodes, or of every running node, in the shape of `inspect interfaces`, with the interfaces the interface events report: the lab link interfaces and their aliases as clabwire lists them, the management interface and loopback. Per node (named <lab>-<node> like in inspect) it reports the MAC address, index, MTU and operational state read from sysfs in the device container. A node whose device container has no shell reports its link interfaces without these attributes.
func (*Runtime) LabExists ¶
func (r *Runtime) LabExists( ctx context.Context, req clablabruntime.InspectRequest, ) (bool, error)
func (*Runtime) List ¶
func (r *Runtime) List( ctx context.Context, req clablabruntime.ListRequest, ) ([]*clablabruntime.LabState, error)
func (*Runtime) LocateNode ¶ added in v0.83.0
func (r *Runtime) LocateNode( ctx context.Context, req clablabruntime.NodeRequest, ) ([]clablabruntime.NodeLocation, error)
LocateNode reports the pod, primary device container, Node UID and exposed ports of the requested nodes, or of every node of the lab when the request names none. Node names are accepted as the topology or as the cluster spells them.
func (*Runtime) Manifests ¶
func (r *Runtime) Manifests( ctx context.Context, req clablabruntime.DeployRequest, ) ([]clablabruntime.Manifest, error)
Manifests renders the resources a deploy would create for the topology, in the order the runtime applies them, without contacting the cluster. The bundle is the managed lab Namespace when containerlab would create one, the staged ConfigMaps every node file mounts from, and then either the Topology resource or, for a lab deployed without one, the NodeProfile, Link, and Node resources compiled client-side. Every object carries the labels the runtime relies on to discover the lab later, so a bundle applied by hand stays manageable with inspect, destroy, and the node lifecycle commands.
func (*Runtime) Plan ¶
func (r *Runtime) Plan( ctx context.Context, req clablabruntime.DeployRequest, ) (*clablabruntime.DeployPlan, error)
Plan compiles the c9s topology and returns the complete primitive/configuration diff against the running cluster without changing any resource.
func (*Runtime) Restart ¶
func (r *Runtime) Restart(ctx context.Context, req clablabruntime.NodeRequest) error
Restart replaces the Pod of every requested node once, through a new restart token on its primary Node. A stopped node is started with the same patch.
func (*Runtime) SampleStats ¶ added in v0.83.0
func (r *Runtime) SampleStats( ctx context.Context, req clablabruntime.InspectRequest, ) ([]clablabruntime.NodeStats, error)
SampleStats reports the CPU and memory usage of every running node of a lab from the resource metrics API, summing the node's device containers.
func (*Runtime) Save ¶
func (r *Runtime) Save( ctx context.Context, req clablabruntime.SaveRequest, ) (*clablabruntime.SaveResult, error)
func (*Runtime) Start ¶
func (r *Runtime) Start(ctx context.Context, req clablabruntime.NodeRequest) error
func (*Runtime) Stop ¶
func (r *Runtime) Stop(ctx context.Context, req clablabruntime.NodeRequest) error
func (*Runtime) StreamEvents ¶
func (r *Runtime) StreamEvents( ctx context.Context, req clablabruntime.EventStreamRequest, ) (<-chan clablabruntime.Event, <-chan error, error)
func (*Runtime) StreamLogs ¶ added in v0.83.0
func (r *Runtime) StreamLogs( ctx context.Context, req clablabruntime.LogRequest, w io.Writer, ) error
StreamLogs writes the log of a node's device container, or of the container the request names, to w.
func (*Runtime) Validate ¶
func (r *Runtime) Validate(ctx context.Context, req clablabruntime.DeployRequest) error
Validate compiles the containerlab/c9s subset and stages all local-path inputs in memory. Lossy-but-deployable fields produce warnings; structurally impossible constructs remain errors. Validation deliberately performs no Kubernetes reads or writes.