Documentation
¶
Index ¶
- Constants
- func Deployment(name string) *appsv1.Deployment
- func DeploymentWithStuckPDB(deploymentName string) (*appsv1.Deployment, *policyv1.PodDisruptionBudget)
- func NewKwokNode(cfg KwokConfig, nodeName string) *corev1.Node
- func Pod(name string) *corev1.Pod
- func RunScenario(ctx context.Context, scenario TestScenario, actioner ActionExecutor, ...) error
- func WaitUntil(ctx context.Context, duration time.Duration, ...) bool
- func WoopCR(namespace, name string) *unstructured.Unstructured
- func WoopCRD() *apiextensionsv1.CustomResourceDefinition
- func WoopGVR() *schema.GroupVersionResource
- type ActionExecutor
- type KwokConfig
- type TestScenario
- func CheckNodeDeletedStuck(nodeCount int, log *slog.Logger) TestScenario
- func CheckNodeStatus(nodeCount int, log *slog.Logger) TestScenario
- func CreateResource(count int, dynamicClient dynamic.Interface, ...) TestScenario
- func DeleteNode(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario
- func DeleteResource(count int, dynamicClient dynamic.Interface, ...) TestScenario
- func DrainNode(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario
- func EvictPod(count int, log *slog.Logger) TestScenario
- func PatchNode(nodeCount int, log *slog.Logger) TestScenario
- func PatchResource(count int, dynamicClient dynamic.Interface, ...) TestScenario
- func PodEvents(count int, log *slog.Logger) TestScenario
- func StuckDrain(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario
Constants ¶
const ( DefaultKwokMarker = "kwok.x-k8s.io/node" KwokMarkerValue = "fake" )
Variables ¶
This section is empty.
Functions ¶
func Deployment ¶ added in v0.57.2
func Deployment(name string) *appsv1.Deployment
Deployment creates a deployment that can run on kwok nodes in the default namespace.
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
func WoopCR ¶ added in v0.57.2
func WoopCR(namespace, name string) *unstructured.Unstructured
WoopCR creates an instance of the CRD from WoopCRD.
func WoopCRD ¶ added in v0.57.2
func WoopCRD() *apiextensionsv1.CustomResourceDefinition
WoopCRD is a stub CRD similar to workload autoscaler's one.
func WoopGVR ¶ added in v0.57.2
func WoopGVR() *schema.GroupVersionResource
WoopGVR returns the GVR for the CRD from WoopCRD.
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 CheckNodeDeletedStuck ¶ added in v0.57.2
func CheckNodeDeletedStuck(nodeCount int, log *slog.Logger) TestScenario
CheckNodeDeletedStuck simulates a case where the node is not deleted so the checker gets stuck.
func CheckNodeStatus ¶ added in v0.57.2
func CheckNodeStatus(nodeCount int, log *slog.Logger) TestScenario
func CreateResource ¶ added in v0.57.2
func CreateResource(count int, dynamicClient dynamic.Interface, apiextensions apiextensionsclientset.Interface, log *slog.Logger) TestScenario
CreateResource will simulate creating/patching N custom resources (ala workload autoscaler flow).
func DeleteNode ¶ added in v0.57.2
func DeleteNode(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario
func DeleteResource ¶ added in v0.57.2
func DeleteResource(count int, dynamicClient dynamic.Interface, apiextensions apiextensionsclientset.Interface, log *slog.Logger) TestScenario
DeleteResource will simulate deleting N custom resources (ala workload autoscaler flow).
func DrainNode ¶ added in v0.57.2
func DrainNode(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario
DrainNode simulates draining of nodes that passes successfully (as opposed to StuckDrain).
func PatchResource ¶ added in v0.57.2
func PatchResource(count int, dynamicClient dynamic.Interface, apiextensions apiextensionsclientset.Interface, log *slog.Logger) TestScenario
PatchResource will simulate patching N custom resources (ala workload autoscaler flow).
func StuckDrain ¶
func StuckDrain(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario