node

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	StatusPending Status = "PENDING"
	StatusRunning Status = "RUNNING"
	StatusFailed  Status = "FAILED"
	StatusUnknown Status = "UNKNOWN"

	ConfigVolumeName = "startup-config-volume"

	OndatraRoleLabel = "ondatra-role"
	OndatraRoleDUT   = "DUT"
	OndatraRoleATE   = "ATE"
)
View Source
const (
	DefaultInitContainerImage = "us-west1-docker.pkg.dev/kne-external/kne/networkop/init-wait:ga"
)

Variables

This section is empty.

Functions

func ToEnvVar

func ToEnvVar(kv map[string]string) []corev1.EnvVar

func ToResourceRequirements

func ToResourceRequirements(kv map[string]string) corev1.ResourceRequirements

func Vendor

func Vendor(v tpb.Vendor, fn NewNodeFn)

Vendor registers the vendor type with the topology manager.

Types

type Certer

type Certer interface {
	GenerateSelfSigned(context.Context) error
}

Certer provides an interface for working with certs on nodes.

type ConfigPusher

type ConfigPusher interface {
	ConfigPush(context.Context, io.Reader) error
}

ConfigPusher provides an interface for performing config pushes to the node.

type Impl

type Impl struct {
	Namespace  string
	KubeClient kubernetes.Interface
	RestConfig *rest.Config
	Proto      *tpb.Node
	BasePath   string
	Kubecfg    string
}

Impl is a topology node in the cluster.

func (*Impl) BackToBackLoop added in v0.1.16

func (n *Impl) BackToBackLoop() bool

BackToBackLoop returns a bool indicating if the node supports a single link connecting two ports on the same node. By default this is false.

func (*Impl) Create

func (n *Impl) Create(ctx context.Context) error

Create will create the node in the k8s cluster with all services and config maps.

func (*Impl) CreateConfig

func (n *Impl) CreateConfig(ctx context.Context) (*corev1.Volume, error)

CreateConfig creates a boot config for the node based on the underlying proto. A volume containing the boot config is returned. If the config size is <3MB then a ConfigMap is created as the volume source. Else a temporary file is written with the boot config to serve as a HostPath volume source.

func (*Impl) CreatePod

func (n *Impl) CreatePod(ctx context.Context) error

CreatePod creates a Pod for the Node based on the underlying proto.

func (*Impl) CreateService

func (n *Impl) CreateService(ctx context.Context) error

CreateService creates services for the node based on the underlying proto.

func (*Impl) Delete

func (n *Impl) Delete(ctx context.Context) error

Delete remove the node from the cluster.

func (*Impl) DeleteConfig

func (n *Impl) DeleteConfig(ctx context.Context) error

DeleteConfig removes the node configmap from the cluster if it exists. If a config file hostPath was used for the boot config volume, clean the file up instead.

func (*Impl) DeleteResource

func (n *Impl) DeleteResource(ctx context.Context) error

DeleteResource removes the resource definition for the Node.

func (*Impl) DeleteService

func (n *Impl) DeleteService(ctx context.Context) error

DeleteService removes the service definition for the Node.

func (*Impl) Exec

func (n *Impl) Exec(ctx context.Context, cmd []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

Exec will make a connection via spdy transport to the Pod and execute the provided command. It will wire up stdin, stdout, stderr to provided io channels.

func (*Impl) GetCLIConn added in v0.1.3

func (n *Impl) GetCLIConn(platform string, opts []scrapliutil.Option) (*scraplinetwork.Driver, error)

GetCLIConn attempts to open the transport channel towards a Network OS and perform scrapligo OnOpen actions for a given platform. Retries indefinitely till success and returns a scrapligo network driver instance.

func (*Impl) GetNamespace

func (n *Impl) GetNamespace() string

func (*Impl) GetProto

func (n *Impl) GetProto() *tpb.Node

func (*Impl) Name

func (n *Impl) Name() string

Name returns the name of the node.

func (*Impl) PatchCLIConnOpen added in v0.1.3

func (n *Impl) PatchCLIConnOpen(bin string, cliCmd []string, opts []scrapliutil.Option) []scrapliutil.Option

PatchCLIConnOpen sets up scrapligo options to work with a tty provided by the combination of the bin binary, namespace and the name of the node plus cliCMd command. In the context of kne this command is typically `kubectl exec cliCmd`.

func (*Impl) Pods

func (n *Impl) Pods(ctx context.Context) ([]*corev1.Pod, error)

Pod returns the pod definition for the node.

func (*Impl) Services

func (n *Impl) Services(ctx context.Context) ([]*corev1.Service, error)

Service returns the service definition for the node.

func (*Impl) Status

func (n *Impl) Status(ctx context.Context) (Status, error)

Status returns the current node state.

func (*Impl) String added in v0.1.15

func (n *Impl) String() string

func (*Impl) TopologySpecs

func (n *Impl) TopologySpecs(context.Context) ([]*topologyv1.Topology, error)

func (*Impl) ValidateConstraints added in v0.1.15

func (n *Impl) ValidateConstraints() error

ValidateConstraints will check the host constraints and returns a list of errors for cases which do not meet the constraints

type Implementation

type Implementation interface {
	// TopologySpecs provides a custom implementation for providing
	// one or more meshnet resource spec for a node type
	TopologySpecs(context.Context) ([]*topologyv1.Topology, error)
	// Create provides a custom implementation of pod creation
	// for a node type. Requires context, Kubernetes client interface and namespace.
	Create(context.Context) error
	// Status provides a custom implementation of accessing vendor node status.
	// Requires context, Kubernetes client interface and namespace.
	Status(context.Context) (Status, error)
	// Delete provides a custom implementation of pod creation
	// for a node type. Requires context, Kubernetes client interface and namespace.
	Delete(context.Context) error
	// Pods provides a custom implementation for querying all pods created for
	// for a node. Requires context, Kubernetes client interface and namespace.
	Pods(context.Context) ([]*corev1.Pod, error)
	// Services provides a custom implementation for querying all services created for
	// for a node. Requires context, Kubernetes client interface and namespace.
	Services(context.Context) ([]*corev1.Service, error)
	// BackToBackLoop returns a bool if the node supports links directly between
	// two ports on the same node.
	BackToBackLoop() bool
}

type Interface

type Interface interface {
	Name() string
	GetNamespace() string
	GetProto() *tpb.Node
	String() string
}

type NewNodeFn

type NewNodeFn func(n *Impl) (Node, error)

type Node

type Node interface {
	Interface
	Implementation
}

Node is the base interface for all node implementations in KNE.

func New

func New(namespace string, pb *tpb.Node, kClient kubernetes.Interface, rCfg *rest.Config, bp, kubecfg string) (Node, error)

New creates a new node for use in the k8s cluster. Configure will push the node to the cluster.

type Resetter

type Resetter interface {
	ResetCfg(ctx context.Context) error
}

Resetter provides Reset interface to nodes.

type Status added in v0.1.3

type Status string

Directories

Path Synopsis
Package openconfig implmements node definitions for nodes from the OpenConfig vendor.
Package openconfig implmements node definitions for nodes from the OpenConfig vendor.

Jump to

Keyboard shortcuts

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