Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions kubernetes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
KIND_CLUSTER ?= sandbox-k8s-test-e2e
KIND_K8S_VERSION ?= v1.22.4
GINKGO_ARGS ?=
E2E_TIMEOUT ?= 30m

.PHONY: install-kind
install-kind: ## Install Kind using go install if not already installed
Expand All @@ -148,15 +149,15 @@ setup-test-e2e: install-kind ## Set up a Kind cluster for e2e tests if it does n
.PHONY: test-e2e-main
test-e2e-main: setup-test-e2e manifests generate fmt vet
CONTROLLER_IMG=$(CONTROLLER_IMG) TASK_EXECUTOR_IMG=$(TASK_EXECUTOR_IMG) \
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v $(GINKGO_ARGS)
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v -timeout $(E2E_TIMEOUT) $(GINKGO_ARGS)
$(MAKE) cleanup-test-e2e

.PHONY: test-e2e
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind. Use GINKGO_ARGS to pass additional arguments.
CONTROLLER_IMG=$(CONTROLLER_IMG) TASK_EXECUTOR_IMG=$(TASK_EXECUTOR_IMG) \
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v $(GINKGO_ARGS)
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v -timeout $(E2E_TIMEOUT) $(GINKGO_ARGS)
CONTROLLER_IMG=$(CONTROLLER_IMG) TASK_EXECUTOR_IMG=$(TASK_EXECUTOR_IMG) \
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e_task/ -v -ginkgo.v $(GINKGO_ARGS)
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e_task/ -v -ginkgo.v -timeout $(E2E_TIMEOUT) $(GINKGO_ARGS)
$(MAKE) cleanup-test-e2e
$(MAKE) test-gvisor CONTROLLER_IMG=$(CONTROLLER_IMG) TASK_EXECUTOR_IMG=$(TASK_EXECUTOR_IMG)
$(MAKE) cleanup-gvisor
Expand Down
16 changes: 16 additions & 0 deletions kubernetes/apis/sandbox/v1alpha1/pool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type PoolSpec struct {
// ScaleStrategy controls the scaling behavior.
// +optional
ScaleStrategy *ScaleStrategy `json:"scaleStrategy,omitempty"`
// UpdateStrategy controls how pool pods are updated when the template changes.
// +optional
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`
}

type CapacitySpec struct {
Expand Down Expand Up @@ -66,6 +69,15 @@ type ScaleStrategy struct {
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
}

// UpdateStrategy controls how pool pods are updated when the pool template changes.
type UpdateStrategy struct {
// MaxUnavailable is the maximum number of pods that can be unavailable during an update.
// Can be an absolute number (ex: 5) or a percentage of desired pods (ex: "20%").
// Defaults to 25%.
// +optional
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
}

// PoolStatus defines the observed state of Pool.
type PoolStatus struct {
// ObservedGeneration is the most recent generation observed for this BatchSandbox. It corresponds to the
Expand All @@ -79,6 +91,8 @@ type PoolStatus struct {
Allocated int32 `json:"allocated"`
// Available is the number of nodes currently available in the pool.
Available int32 `json:"available"`
// Updated is the number of nodes that have been updated to the latest revision.
Updated int32 `json:"updated,omitempty"`
}

// +genclient
Expand All @@ -88,6 +102,8 @@ type PoolStatus struct {
// +kubebuilder:printcolumn:name="TOTAL",type="integer",JSONPath=".status.total",description="The number of all nodes in pool."
// +kubebuilder:printcolumn:name="ALLOCATED",type="integer",JSONPath=".status.allocated",description="The number of allocated nodes in pool."
// +kubebuilder:printcolumn:name="AVAILABLE",type="integer",JSONPath=".status.available",description="The number of available nodes in pool."
// +kubebuilder:printcolumn:name="UPDATED",type="integer",JSONPath=".status.updated",description="The number of nodes updated to the latest revision."
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// Pool is the Schema for the pools API.
type Pool struct {
metav1.TypeMeta `json:",inline"`
Expand Down
25 changes: 25 additions & 0 deletions kubernetes/apis/sandbox/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions kubernetes/config/crd/bases/sandbox.opensandbox.io_pools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ spec:
jsonPath: .status.available
name: AVAILABLE
type: integer
- description: The number of nodes updated to the latest revision.
jsonPath: .status.updated
name: UPDATED
type: integer
- jsonPath: .metadata.creationTimestamp
name: AGE
type: date
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -100,6 +107,20 @@ spec:
template:
description: Pod Template used to create pre-warmed nodes in the pool.
x-kubernetes-preserve-unknown-fields: true
updateStrategy:
description: UpdateStrategy controls how pool pods are updated when
the template changes.
properties:
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
MaxUnavailable is the maximum number of pods that can be unavailable during an update.
Can be an absolute number (ex: 5) or a percentage of desired pods (ex: "20%").
Defaults to 25%.
x-kubernetes-int-or-string: true
type: object
required:
- capacitySpec
type: object
Expand Down Expand Up @@ -129,6 +150,11 @@ spec:
description: Total is the total number of nodes in the pool.
format: int32
type: integer
updated:
description: Updated is the number of nodes that have been updated
to the latest revision.
format: int32
type: integer
required:
- allocated
- available
Expand Down
Loading
Loading