loadtest

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

README

Load testing Cluster controller

Load test requires 3 components:

  • Test server that simulates cluster-hub and the scenarios.
  • Kwok controller to simulate nodes/pods
  • Cluster controller itself.

Optionally, observability stack helps identify problems with the deployment.

Local run

This runs all 3 components as local processes against a cluster. Useful for debugging. https://github.com/arl/statsviz can be used for local observability.

Start kwok:

 kwok --kubeconfig=~/.kube/config \
    --manage-all-nodes=false \
    --manage-nodes-with-annotation-selector=kwok.x-k8s.io/node=fake \
    --node-lease-duration-seconds=40 \
    --cidr=10.0.0.1/24 \
    --node-ip=10.0.0.1

Run the test server on port 8080 against your current kubeconfig context:

KUBECONFIG=~/.kube/config PORT=8080 go run . test-server

After starting, start cluster controller with some dummy values and point it to the test server:

API_KEY=dummy API_URL=http://localhost:8080 CLUSTER_ID=D30A163C-C5DF-4CC8-985C-D1449398295E KUBECONFIG=~/.kube/config LOG_LEVEL=4 LEADER_ELECTION_NAMESPACE=default METRICS_ENABLED=true go run .                     

Deployment in cluster

Running the command below will build the local cluster controller, push it to a repository and deploy all 3 required components + observability stack into the current cluster. Both the cluster controller and the test server will use the same image but will run in different modes.

make deploy-loadtest DOCKER_REPOSITORY=<repository_for_iamge> VERSION=<tag> ARCH=amd64

If you wish to skip deploying cluster controller, prefix make with DEPLOY_CLUSTER_CONTROLLER=false. Be sure to update the existing cluster controller to use the deployed test server's URL.

If you wish to use different repository for cluster controller and for test server, pass LOAD_TEST_IMAGE_REPOSITORY and LOAD_TEST_IMAGE_TAG env vars to the command.

The deploy command also includes prometheus and grafana. Use kubectl port-forward -n castai-agent svc/observability-service 3000:3000 to reach the grafana instance. There is already a preconfigured dashboard available on the instance.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpServer

func NewHttpServer(ctx context.Context, cfg Config, testServer *CastAITestServer) error

Types

type CastAITestServer

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

CastAITestServer acts as simple cluster hub mock replacement. It exposes a way to "push" actions to the cluster controller via GetActionsPushChannel and can be used as an implementation of the server interface that cluster controller expects to call.

func NewTestServer

func NewTestServer(logger *slog.Logger, cfg TestServerConfig) *CastAITestServer

func (*CastAITestServer) AckAction

func (c *CastAITestServer) AckAction(ctx context.Context, actionID string, req *castai.AckClusterActionRequest) error

func (*CastAITestServer) ExecuteActions

func (c *CastAITestServer) ExecuteActions(ctx context.Context, actions []castai.ClusterAction)

ExecuteActions pushes the list of actions to the queue for cluster controller to process. This method returns when all actions are acked or context is cancelled.

func (*CastAITestServer) GetActions

func (c *CastAITestServer) GetActions(ctx context.Context, _ string) ([]*castai.ClusterAction, error)

func (*CastAITestServer) SendLog

func (c *CastAITestServer) SendLog(ctx context.Context, e *castai.LogEntry) error

type Config

type Config struct {
	// Port where the mock server to listen on.
	Port int

	// KubeConfig can point to a kubeconfig file. If empty, InCluster client will be assumed.
	KubeConfig string
}

Config for the HTTP server.

func GetConfig

func GetConfig() Config

type TestServerConfig

type TestServerConfig struct {
	// MaxActionsPerCall is the upper limit of actions to return in one CastAITestServer.GetActions call.
	MaxActionsPerCall int
	// TimeoutWaitingForActions controls how long to wait for at least 1 action to appear on server side.
	// This mimics CH behavior of not returning early if there are no pending actions and keeping the request "running".
	// Note: Currently not implemented
	TimeoutWaitingForActions time.Duration
}

TestServerConfig has settings for the mock server instance.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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