-
Notifications
You must be signed in to change notification settings - Fork 74
feat(hpa): Add horizontal pod autoscaling for DragonFly instances #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smunukutla-mycarrier
wants to merge
13
commits into
dragonflydb:main
Choose a base branch
from
smunukutla-mycarrier:smunukutla-autoscale-dragonflydb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
35ca48d
add horizontal autoscaler
smunukutla-mycarrier 0c04c77
Merge branch 'dragonflydb:main' into smunukutla-autoscale-dragonflydb
smunukutla-mycarrier 4a5874e
WIP: added e2e tests for hpa and fixed replica control issue
smunukutla-mycarrier 591104e
fix hpa deletion issue
smunukutla-mycarrier 9f14841
remove unnecessary tests
smunukutla-mycarrier fde45ad
fix bug with transition between autoscaler to just using replica, add…
smunukutla-mycarrier dd177ea
cleanup makefile
smunukutla-mycarrier 4f745a4
Merge branch 'main' into smunukutla-autoscale-dragonflydb
smunukutla-mycarrier 5958933
Merge branch 'main' into smunukutla-autoscale-dragonflydb
smunukutla-mycarrier 7459a3b
fix: set crd:MaxDescLen to 0 to avoid annotation max length issue
smunukutla-mycarrier 9ed5a35
Merge branch 'main' into smunukutla-autoscale-dragonflydb
smunukutla-mycarrier a3f278f
fix merge issue
smunukutla-mycarrier 84d61d7
updated manifests - removed descriptions to avoid max length issue
smunukutla-mycarrier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ help: ## Display this help. | |
|
||
.PHONY: manifests | ||
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:maxDescLen=0 webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
.PHONY: generate | ||
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
|
@@ -61,6 +61,11 @@ test: manifests generate fmt vet envtest ## Run tests. | |
GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/[email protected] | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) -vv -r -p -coverprofile cover.out | ||
|
||
.PHONY: test-single | ||
test-single: manifests generate fmt vet envtest ## Run a single test by name. Usage: make test-single TEST="test name" | ||
GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/[email protected] | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) -vv --focus="$(TEST)" ./e2e | ||
|
||
##@ Build | ||
|
||
.PHONY: build | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ limitations under the License. | |
package v1alpha1 | ||
|
||
import ( | ||
autoscalingv2 "k8s.io/api/autoscaling/v2" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
@@ -75,22 +76,30 @@ type DragonflySpec struct { | |
// (Optional) Additional containers to add to dragonflycluster. Replace container on name collision. | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=array | ||
AdditionalContainers []corev1.Container `json:"additionalContainers,omitempty"` | ||
|
||
// (Optional) Additional volumes to add to dragonflycluster. Replace volume on name collision. | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=array | ||
AdditionalVolumes []corev1.Volume `json:"additionalVolumes,omitempty"` | ||
|
||
// (Optional) Dragonfly container resource limits. Any container limits | ||
// can be specified. | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
Resources *corev1.ResourceRequirements `json:"resources,omitempty"` | ||
|
||
// (Optional) Dragonfly pod affinity | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
Affinity *corev1.Affinity `json:"affinity,omitempty"` | ||
|
||
// (Optional) Dragonfly pod node selector | ||
|
@@ -106,11 +115,15 @@ type DragonflySpec struct { | |
// (Optional) Dragonfly pod tolerations | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=array | ||
Tolerations []corev1.Toleration `json:"tolerations,omitempty"` | ||
|
||
// (Optional) Dragonfly pod topologySpreadConstraints | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=array | ||
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` | ||
|
||
// (Optional) Dragonfly Authentication mechanism | ||
|
@@ -121,11 +134,15 @@ type DragonflySpec struct { | |
// (Optional) Dragonfly container security context | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"` | ||
|
||
// (Optional) Dragonfly pod security context | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` | ||
|
||
// (Optional) Dragonfly pod service account name | ||
|
@@ -168,9 +185,17 @@ type DragonflySpec struct { | |
// (Optional) Dragonfly pod init containers | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=array | ||
InitContainers []corev1.Container `json:"initContainers,omitempty"` | ||
|
||
// (Optional) Dragonfly direct child resources additional annotations and labels | ||
|
||
// (Optional) Dragonfly autoscaler configuration | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
Autoscaler *AutoscalerSpec `json:"autoscaler,omitempty"` | ||
|
||
// (Optional) Dragonfly direct child resources additional annotations and labels | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
OwnedObjectsMetadata *OwnedObjectsMetadata `json:"ownedObjectsMetadata,omitempty"` | ||
|
@@ -212,6 +237,8 @@ type Tiering struct { | |
// (Optional) Dragonfly PVC spec for cache tiering configuration | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
PersistentVolumeClaimSpec *corev1.PersistentVolumeClaimSpec `json:"persistentVolumeClaimSpec,omitempty"` | ||
} | ||
|
||
|
@@ -236,6 +263,8 @@ type Snapshot struct { | |
// (Optional) Dragonfly PVC spec | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
PersistentVolumeClaimSpec *corev1.PersistentVolumeClaimSpec `json:"persistentVolumeClaimSpec,omitempty"` | ||
} | ||
|
||
|
@@ -250,6 +279,51 @@ type Authentication struct { | |
ClientCaCertSecret *corev1.SecretKeySelector `json:"clientCaCertSecret,omitempty"` | ||
} | ||
|
||
// AutoscalerSpec defines the autoscaling configuration for Dragonfly | ||
type AutoscalerSpec struct { | ||
// Whether autoscaling is enabled | ||
// +kubebuilder:validation:Required | ||
Enabled bool `json:"enabled"` | ||
|
||
// Minimum number of replicas | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Required | ||
MinReplicas int32 `json:"minReplicas"` | ||
|
||
// Maximum number of replicas | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Required | ||
MaxReplicas int32 `json:"maxReplicas"` | ||
|
||
// Scaling behavior policies | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"` | ||
|
||
// Metrics to be used for autoscaling | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=array | ||
Metrics []autoscalingv2.MetricSpec `json:"metrics,omitempty"` | ||
|
||
// Target CPU utilization percentage | ||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Maximum=100 | ||
TargetCPUUtilizationPercentage *int32 `json:"targetCPUUtilizationPercentage,omitempty"` | ||
|
||
// Target memory utilization percentage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this makes sense ? how would adding replica reduce memory usage ? as data is replicated to all. |
||
// +optional | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:validation:Minimum=1 | ||
// +kubebuilder:validation:Maximum=100 | ||
TargetMemoryUtilizationPercentage *int32 `json:"targetMemoryUtilizationPercentage,omitempty"` | ||
} | ||
|
||
// DragonflyStatus defines the observed state of Dragonfly | ||
type DragonflyStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that adding replicas can only increase your read throughput