utils

package
v0.14.6 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 34 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath             = "/var/lib/kubelet/config.yaml"
	DefaultPodResourcesSocketPath = "/var/lib/kubelet/pod-resources/kubelet.sock"
)
View Source
const (
	// LabelRole contains the key for the role label
	LabelRole = "node-role.kubernetes.io"
	// LabelHostname contains the key for the hostname label
	LabelHostname = "kubernetes.io/hostname"
)
View Source
const (
	// RoleWorker contains the worker role
	RoleWorker = "worker"
)

Variables

This section is empty.

Functions

func AllocatableResourceListFromNodeResourceTopology

func AllocatableResourceListFromNodeResourceTopology(nodeTopo *v1alpha2.NodeResourceTopology) map[string]corev1.ResourceList

AllocatableResourceListFromNodeResourceTopology extract the map zone:allocatableResources from the given NodeResourceTopology instance.

func CompareAllocatableResources

func CompareAllocatableResources(expected, got map[string]corev1.ResourceList) (string, string, int, bool)

CompareAllocatableResources compares `expected` and `got` map zone:allocatableResources respectively (see: AllocatableResourceListFromNodeResourceTopology), and informs the caller if the maps are equal. Here `equal` means the same zoneNames with the same resources, where the resources are equal if they have the same resources with the same quantities. Returns the name of the different zone, the name of the different resources within the zone, the comparison result (same semantic as strings.Compare) and a boolean that reports if the resourceLists are consistent. See `CompareResourceList`.

func CompareResourceList

func CompareResourceList(expected, got corev1.ResourceList) (string, int, bool)

CompareResourceList compares `expected` and `got` ResourceList respectively, and informs the caller if the two ResourceList are equal. Here `equal` means the same resources with the same quantities. Returns the different resource, the comparison result (same semantic as strings.Compare) and a boolean that reports if the resourceLists are consistent. The ResourceLists are consistent only if the represent the same resource set (all the resources listed in one are also present in the another; no ResourceList is a superset nor a subset of the other)

func ConfigureRBAC

func ConfigureRBAC(ctx context.Context, cs clientset.Interface, ns string) error

ConfigureRBAC creates required RBAC configuration

func CreateNfdCRDs

CreateNfdCRDs creates the NodeFeatureRule CRD in the API server.

func CreateNodeFeature added in v0.14.0

func CreateNodeFeature(ctx context.Context, cli nfdclientset.Interface, namespace, name, nodeName string) error

CreateNodeFeature creates a dummy NodeFeature object for a node

func CreateNodeFeatureRulesFromFile

func CreateNodeFeatureRulesFromFile(ctx context.Context, cli nfdclientset.Interface, filename string) error

CreateNodeFeatureRuleFromFile creates a NodeFeatureRule object from a given file located under test data directory.

func CreateNodeResourceTopologies

func CreateNodeResourceTopologies(ctx context.Context, extClient extclient.Interface) (*apiextensionsv1.CustomResourceDefinition, error)

CreateNodeResourceTopologies creates the NodeResourceTopology in the cluster if the CRD doesn't exists already. Returns the CRD golang object present in the cluster.

func CreateNodeResourceTopology added in v0.14.0

func CreateNodeResourceTopology(ctx context.Context, topologyClient *topologyclientset.Clientset, nodeName string) error

CreateNodeResourceTopology creates a dummy NodeResourceTopology object for a node

func CreateOrUpdateNodeFeaturesFromFile added in v0.13.0

func CreateOrUpdateNodeFeaturesFromFile(ctx context.Context, cli nfdclientset.Interface, filename, namespace, nodename string) ([]string, error)

CreateOrUpdateNodeFeaturesFromFile creates/updates a NodeFeature object from a given file located under test data directory.

func CreateService

func CreateService(ctx context.Context, cs clientset.Interface, ns string) (*corev1.Service, error)

CreateService creates nfd-master Service

func DeconfigureRBAC

func DeconfigureRBAC(ctx context.Context, cs clientset.Interface, ns string) error

DeconfigureRBAC removes RBAC configuration

func FilterNodesWithEnoughCores

func FilterNodesWithEnoughCores(nodes []corev1.Node, cpuAmount string) ([]corev1.Node, error)

FilterNodesWithEnoughCores returns all nodes with at least the amount of given CPU allocatable

func GetNodeTopology

func GetNodeTopology(ctx context.Context, topologyClient *topologyclientset.Clientset, nodeName string) *v1alpha2.NodeResourceTopology

GetNodeTopology returns the NodeResourceTopology data for the node identified by `nodeName`.

func GetNodesByRole

func GetNodesByRole(ctx context.Context, f *framework.Framework, role string) ([]corev1.Node, error)

GetByRole returns all nodes with the specified role

func GetNodesBySelector

func GetNodesBySelector(ctx context.Context, f *framework.Framework, selector labels.Selector) ([]corev1.Node, error)

GetBySelector returns all nodes with the specified selector

func GetWorkerNodes

func GetWorkerNodes(ctx context.Context, f *framework.Framework) ([]corev1.Node, error)

GetWorkerNodes returns all nodes labeled as worker

func IsValidNodeTopology

func IsValidNodeTopology(nodeTopology *v1alpha2.NodeResourceTopology, kubeletConfig *kubeletconfig.KubeletConfiguration) bool

IsValidNodeTopology checks the provided NodeResourceTopology object if it is well-formad, internally consistent and consistent with the given kubelet config object. Returns true if the NodeResourceTopology object is consistent and well formet, false otherwise; if return false, logs the failure reason.

func NewConfigMap

func NewConfigMap(name, key, data string) *corev1.ConfigMap

CreateConfigMap is a helper for creating a simple ConfigMap object with one key.

func NewNodeResourceTopologies

func NewNodeResourceTopologies() (*apiextensionsv1.CustomResourceDefinition, error)

NewNodeResourceTopologies makes a CRD golang object representing NodeResourceTopology definition

func UpdateConfigMap added in v0.13.0

func UpdateConfigMap(ctx context.Context, c clientset.Interface, name, namespace, key, data string) error

UpdateConfigMap is a helper for updating a ConfigMap object.

func UpdateNodeFeatureRulesFromFile

func UpdateNodeFeatureRulesFromFile(ctx context.Context, cli nfdclientset.Interface, filename string) error

UpdateNodeFeatureRulesFromFile updates existing NodeFeatureRule object from a given file located under test data directory.

Types

type E2EConfig

type E2EConfig struct {
	DefaultFeatures *struct {
		LabelWhitelist      lookupMap
		AnnotationWhitelist lookupMap
		Nodes               []NodeConfig
	}

	Kubelet *KubeletConfig
}

func GetConfig

func GetConfig() (*E2EConfig, error)

func (*E2EConfig) GetKubeletConfig

func (conf *E2EConfig) GetKubeletConfig() KubeletConfig

GetKubeletConfig returns a KubeletConfig object with default values, possibly overridden by user settings.

type KubeletConfig

type KubeletConfig struct {
	ConfigPath             string
	PodResourcesSocketPath string
}

type NodeConfig

type NodeConfig struct {
	Name                     string
	NodeNameRegexp           string
	ExpectedLabelValues      map[string]string
	ExpectedLabelKeys        lookupMap
	ExpectedAnnotationValues map[string]string
	ExpectedAnnotationKeys   lookupMap
	// contains filtered or unexported fields
}

func FindNodeConfig

func FindNodeConfig(cfg *E2EConfig, nodeName string) *NodeConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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