utils

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EKSIdleNodepoolInstanceType is the instance type of idle nodepool.
	//
	// NOTE: The EKS cloud provider will delete all the NOT-READY nodes
	// which aren't managed by it. When kwok-controller fails to update
	// virtual node's lease, the EKS cloud provider would delete that
	// virtual node. It's unexpected behavior. In order to avoid this case,
	// we should create a idle nodepool with one node and use that node's
	// provider ID for all the virtual nodes so that EKS cloud provider
	// won't delete our virtual nodes.
	EKSIdleNodepoolInstanceType = "m4.large"
)

Functions

func BuildClientset

func BuildClientset(kubeCfgPath string) (*kubernetes.Clientset, error)

BuildClientset returns kubernetes clientset.

func CreateConfigmaps added in v0.3.3

func CreateConfigmaps(ctx context.Context, kubeCfgPath string,
	cmAmount int, cmSize int, cmGroupSize int, namespace string, timeout time.Duration) error

Creates configmaps for benchmark.

func CreateTempFileWithContent

func CreateTempFileWithContent(data []byte) (_name string, _cleanup func() error, retErr error)

CreateTempFileWithContent creates temporary file with data.

func DeleteConfigmaps added in v0.3.3

func DeleteConfigmaps(ctx context.Context, kubeCfgPath string, namespace string, timeout time.Duration) error

Delete configmaps for benchmark.

func DeployAndRepeatRollingUpdateDeployments

func DeployAndRepeatRollingUpdateDeployments(
	ctx context.Context,
	kubeCfgPath string,
	releaseName string,
	total, replica, paddingBytes int,
	internal time.Duration,
) (rollingUpdateFn, cleanupFn func(), retErr error)

DeployAndRepeatRollingUpdateDeployments deploys and repeats to rolling-update deployments.

func DeployRunnerGroup

func DeployRunnerGroup(ctx context.Context,
	kubeCfgPath, runnerImage, rgCfgFile string,
	runnerFlowControl, runnerGroupAffinity string) (*types.RunnerGroupsReport, error)

DeployRunnerGroup deploys runner group for benchmark.

func FetchAPIServerCores

func FetchAPIServerCores(ctx context.Context, kubeCfgPath string) (map[string]int, error)

FetchAPIServerCores fetchs core number for each kube-apiserver.

func FetchNodeProviderIDByType

func FetchNodeProviderIDByType(ctx context.Context, kubeCfgPath string, instanceType string) (string, error)

FetchNodeProviderIDByType is used to get one node's provider id with a given instance type.

func NSLookup

func NSLookup(domainURL string) ([]string, error)

NSLookup returns ips for URL.

func NewRunnerGroupSpecFileFromEmbed

func NewRunnerGroupSpecFileFromEmbed(target string, tweakFn func(*types.RunnerGroupSpec) error) (_name string, _cleanup func() error, _ error)

NewRunnerGroupSpecFileFromEmbed reads load profile (RunnerGroupSpec) from embed memory and marshals it into temporary file. Use it when invoking kperf binary instead of package.

func NewRunnerGroupSpecFromYAML

func NewRunnerGroupSpecFromYAML(data []byte, tweakFn func(*types.RunnerGroupSpec) error) (*types.RunnerGroupSpec, error)

NewRunnerGroupSpecFromYAML returns RunnerGroupSpec instance from yaml data.

func RepeatJobWithPod

func RepeatJobWithPod(ctx context.Context, kubeCfgPath string, namespace string, target string, internal time.Duration)

RepeatJobWithPod repeats to deploy 3k pods.

Types

type KperfRunner

type KperfRunner struct {
	// contains filtered or unexported fields
}

KperfRunner is the wrapper of exec.Command to execute kperf command.

func NewKperfRunner

func NewKperfRunner(kubeCfgPath string, runnerImage string) *KperfRunner

func (*KperfRunner) DeleteNodepool

func (kr *KperfRunner) DeleteNodepool(ctx context.Context, timeout time.Duration, name string) error

DeleteNodepool deletes a virtual nodepool by a given name.

func (*KperfRunner) NewNodepool

func (kr *KperfRunner) NewNodepool(
	ctx context.Context,
	timeout time.Duration,
	name string, nodes int, cpu, memory, maxPods int,
	affinity string,
	sharedProviderID string,
) error

NewNodepool creates new virtual nodepool.

func (*KperfRunner) RGDelete

func (kr *KperfRunner) RGDelete(ctx context.Context, timeout time.Duration) error

RGDelete deletes runner group.

func (*KperfRunner) RGResult

func (kr *KperfRunner) RGResult(ctx context.Context, timeout time.Duration) (string, error)

RGResult fetches runner group's result.

func (*KperfRunner) RGRun

func (kr *KperfRunner) RGRun(ctx context.Context, timeout time.Duration, rgCfgPath, flowcontrol, affinity string) error

RGRun deploys runner group into kubernetes cluster.

type KubectlRunner

type KubectlRunner struct {
	// contains filtered or unexported fields
}

KubectlRunner is the wrapper of exec.Command to execute kubectl command.

func NewKubectlRunner

func NewKubectlRunner(kubeCfgPath string, namespace string) *KubectlRunner

func (*KubectlRunner) Apply

func (kr *KubectlRunner) Apply(ctx context.Context, timeout time.Duration, filePath string) error

Apply runs apply subcommand.

func (*KubectlRunner) CreateNamespace

func (kr *KubectlRunner) CreateNamespace(ctx context.Context, timeout time.Duration, name string) error

CreateNamespace creates a new namespace.

func (*KubectlRunner) Delete

func (kr *KubectlRunner) Delete(ctx context.Context, timeout time.Duration, filePath string) error

Delete runs delete subcommand.

func (*KubectlRunner) DeleteNamespace

func (kr *KubectlRunner) DeleteNamespace(ctx context.Context, timeout time.Duration, name string) error

DeleteNamespace delete a namespace.

func (*KubectlRunner) DeploymentRestart

func (kr *KubectlRunner) DeploymentRestart(ctx context.Context, timeout time.Duration, name string) error

DeploymentRestart restats a deployment.

func (*KubectlRunner) DeploymentRolloutStatus

func (kr *KubectlRunner) DeploymentRolloutStatus(ctx context.Context, timeout time.Duration, name string) error

DeploymentRolloutStatus watches the rollout status of a deployment.

func (*KubectlRunner) FQDN

func (kr *KubectlRunner) FQDN(ctx context.Context, timeout time.Duration) (string, error)

FQDN returns the FQDN of the cluster.

func (*KubectlRunner) Metrics

func (kr *KubectlRunner) Metrics(ctx context.Context, timeout time.Duration, fqdn, ip string) ([]byte, error)

Metrics returns the metrics for a specific kube-apiserver.

func (*KubectlRunner) ServerSideApplyWithData

func (kr *KubectlRunner) ServerSideApplyWithData(ctx context.Context, timeout time.Duration, data string) error

ServerSideApplyWithData runs kubectl apply with --server-side=true, with input data piped through stdin.

func (*KubectlRunner) Wait

func (kr *KubectlRunner) Wait(ctx context.Context, timeout time.Duration, condition, waitTimeout, target string) error

Wait runs wait subcommand.

Jump to

Keyboard shortcuts

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