Documentation
¶
Index ¶
- Constants
- func DeploymentWithStuckPDB(deploymentName string) (*appsv1.Deployment, *policyv1.PodDisruptionBudget)
- func NewKwokNode(cfg KwokConfig, nodeName string) *corev1.Node
- func RunScenario(ctx context.Context, scenario TestScenario, actioner ActionExecutor, ...) error
- func WaitUntil(ctx context.Context, duration time.Duration, condition func() bool) bool
- type ActionExecutor
- type KwokConfig
- type TestScenario
Constants ¶
View Source
const ( DefaultKwokMarker = "kwok.x-k8s.io/node" KwokMarkerValue = "fake-node" )
Variables ¶
This section is empty.
Functions ¶
func DeploymentWithStuckPDB ¶
func DeploymentWithStuckPDB(deploymentName string) (*appsv1.Deployment, *policyv1.PodDisruptionBudget)
DeploymentWithStuckPDB creates a 1-replica deployment with "stuck PDB" that is never satisfiable, i.e. no pods can be evicted. Deployment cannot run in reality, it uses fake container. Deployment deploys on kwok fake nodes by default.
func NewKwokNode ¶
func NewKwokNode(cfg KwokConfig, nodeName string) *corev1.Node
NewKwokNode creates a fake node with reasonable defaults. Can be customized but the marker label/annotation must be present. Tainted by default with DefaultKwokMarker to avoid running real pods on it. Requires that a kwok-controller is running to actually simulate the node on apply.
func RunScenario ¶
func RunScenario( ctx context.Context, scenario TestScenario, actioner ActionExecutor, logger *slog.Logger, clientset kubernetes.Interface, ) error
Types ¶
type ActionExecutor ¶
type ActionExecutor interface {
// ExecuteActions is expected to execute all actions and wait for ack before returning; otherwise cleanups might run too early.
ExecuteActions(ctx context.Context, actions []castai.ClusterAction)
}
type KwokConfig ¶
type KwokConfig struct {
// Label should match what kwok is configured to use via --manage-nodes-with-label-selector
// Default is DefaultKwokMarker. Value is always KwokMarkerValue.
Label string
// Annotation should match what kwok is configured to use via --manage-nodes-with-annotation-selector
// Default is DefaultKwokMarker. Value is always KwokMarkerValue.
Annotation string
}
type TestScenario ¶
type TestScenario interface {
Name() string
// Preparation should create any necessary resources in the cluster for the test so it runs in realistic env.
Preparation(ctx context.Context, namespace string, clientset kubernetes.Interface) error
// Cleanup should delete any items created by the preparation or the test itself.
// It might be called even if Preparation or Run did not complete so it should handle those cases gracefully.
// The scenario's namespace is deleted at the end but ideally scenarios delete their resources as well,
// otherwise namespace deletion can take very long to propagate.
Cleanup(ctx context.Context, namespace string, clientset kubernetes.Interface) error
Run(ctx context.Context, namespace string, clientset kubernetes.Interface, executor ActionExecutor) error
}
func StuckDrain ¶
func StuckDrain(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario
Click to show internal directories.
Click to hide internal directories.