Skip to content
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

Autoscaling Elasticsearch: Introduce a dedicated custom resource #5978

Merged
merged 36 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8471a45
Introduce Elasticsearch autoscaling CRD
barkbay Aug 22, 2022
ba87dca
Introduce AutoscalingResource interface
barkbay Aug 26, 2022
86131dc
Update validation
barkbay Aug 27, 2022
dfa6e67
Update status when inactive
barkbay Aug 27, 2022
0aa1d25
Elasticsearch cluster should be HA
barkbay Aug 27, 2022
3a8c3e1
Update K8S ClusterRoles
barkbay Aug 27, 2022
03eed36
Merge remote-tracking branch 'origin/main' into autoscaling/crd
barkbay Aug 29, 2022
2f9193d
Error management
barkbay Aug 29, 2022
4ef5a39
Add unit tests for status
barkbay Aug 29, 2022
4e11f5d
Set both limits and request to use the desired nodes API
barkbay Aug 29, 2022
f81aac3
Add e2e RBACs
barkbay Aug 29, 2022
b52962c
Add autoscaling CRD in OperatorHub manifest
barkbay Aug 29, 2022
81ede3f
Update godoc
barkbay Aug 29, 2022
144c8dc
Update existing e2e test
barkbay Aug 30, 2022
5969845
Clean up generated resources and API documentation
barkbay Aug 30, 2022
24e8f4c
Add (webhook) validation
barkbay Aug 30, 2022
60ee43f
Merge remote-tracking branch 'origin/main' into autoscaling/crd
barkbay Sep 1, 2022
bb8fa38
Update API docs
barkbay Sep 1, 2022
fb4f91a
Add E2E test
barkbay Sep 1, 2022
2a2256c
Add unit tests for new controller
barkbay Sep 1, 2022
8e2582f
Add unit test to check that user does not use both the annotation and…
barkbay Sep 5, 2022
5de49aa
typos
barkbay Sep 5, 2022
79ef072
Add a comment about deciders section in the recipe
barkbay Sep 6, 2022
9fd3e6b
Update from review
barkbay Sep 11, 2022
c83a0bb
Update from review
barkbay Sep 11, 2022
8831df3
Generate CRDs
barkbay Sep 12, 2022
bb13cf3
Fix typos and update comments
barkbay Sep 21, 2022
0f1cb2f
Merge remote-tracking branch 'origin/main' into autoscaling/crd
barkbay Sep 21, 2022
36083b6
Regenerate CRDs and update condition message
barkbay Sep 21, 2022
285485c
Update some comments
barkbay Sep 21, 2022
b5b5db9
Update telemetry
barkbay Sep 21, 2022
fe77306
Refactor truncate
barkbay Sep 21, 2022
dd6a0be
make generate-api-docs
barkbay Sep 21, 2022
3ad5bc5
Move EnterpriseFeaturesEnabled check
barkbay Sep 21, 2022
79e5f8c
Update from review
barkbay Sep 21, 2022
35f6fba
Typo and imports
barkbay Sep 22, 2022
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ go-generate:
generate-crds-v1: go-generate controller-gen
# Generate webhook manifest
# Webhook definitions exist in both pkg/apis and pkg/controller/elasticsearch/validation
$(CONTROLLER_GEN) webhook object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/... paths=./pkg/controller/elasticsearch/validation/...
$(CONTROLLER_GEN) webhook object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/... paths=./pkg/controller/elasticsearch/validation/... paths=./pkg/controller/autoscaling/elasticsearch/validation/...
barkbay marked this conversation as resolved.
Show resolved Hide resolved
# Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) crd:crdVersions=v1,generateEmbeddedObjectMeta=true paths="./pkg/apis/..." output:crd:artifacts:config=config/crds/v1/bases
# apply patches to work around some CRD generation issues, and merge them into a single file
Expand Down
4 changes: 3 additions & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import (
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/association"
associationctl "github.com/elastic/cloud-on-k8s/v2/pkg/controller/association/controller"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/autoscaling"
esavalidation "github.com/elastic/cloud-on-k8s/v2/pkg/controller/autoscaling/elasticsearch/validation"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/beat"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/certificates"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/container"
Expand Down Expand Up @@ -935,8 +936,9 @@ func setupWebhook(
}
}

// esv1 validating webhook is wired up differently, in order to access the k8s client
// Elasticsearch and ElasticsearchAutoscaling validating webhooks are wired up differently, in order to access the k8s client
esvalidation.RegisterWebhook(mgr, params.ValidateStorageClass, exposedNodeLabels, checker, managedNamespaces)
esavalidation.RegisterWebhook(mgr, params.ValidateStorageClass, checker, managedNamespaces)

// wait for the secret to be populated in the local filesystem before returning
interval := time.Second * 1
Expand Down
350 changes: 350 additions & 0 deletions config/crds/v1/all-crds.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config/crds/v1/bases/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resources:
- apm.k8s.elastic.co_apmservers.yaml
- elasticsearch.k8s.elastic.co_elasticsearches.yaml
- autoscaling.k8s.elastic.co_elasticsearchautoscalers.yaml
- kibana.k8s.elastic.co_kibanas.yaml
- enterprisesearch.k8s.elastic.co_enterprisesearches.yaml
- beat.k8s.elastic.co_beats.yaml
Expand Down
13 changes: 13 additions & 0 deletions config/e2e/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ rules:
- update
- patch
- delete
- apiGroups:
- autoscaling.k8s.elastic.co
resources:
- elasticsearchautoscalers
- elasticsearchautoscalers/status
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- kibana.k8s.elastic.co
resources:
Expand Down
93 changes: 58 additions & 35 deletions config/recipes/autoscaling/elasticsearch.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,69 @@
---
apiVersion: autoscaling.k8s.elastic.co/v1alpha1
kind: ElasticsearchAutoscaler
metadata:
name: autoscaling-sample
spec:
elasticsearchRef:
name: elasticsearch-sample
policies:
- name: di
roles: ["data", "ingest" , "transform"]
## Autoscaling deciders (https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-deciders.html) come with
## default settings. Uncomment the lines below to adjust the deciders settings.
#deciders:
## 'proactive_storage' is only provided as an example, each role comes with specific individual autoscaling deciders.
# proactive_storage:
# forecast_window: 5m
resources:
nodeCount:
min: 3
max: 8
cpu:
min: 2
max: 8
memory:
min: 2Gi
max: 16Gi
storage:
min: 64Gi
max: 512Gi
- name: ml
roles:
- ml
resources:
nodeCount:
min: 1
max: 9
cpu:
min: 1
max: 4
memory:
min: 2Gi
max: 8Gi
storage:
min: 1Gi
max: 1Gi

---
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: autoscaling-sample
annotations:
elasticsearch.alpha.elastic.co/autoscaling-spec: |
{
"policies": [{
"name": "di",
"roles": ["data", "ingest" , "transform"],
"deciders": {
"proactive_storage": {
"forecast_window": "5m"
}
},
"resources": {
"nodeCount": { "min": 3, "max": 8 },
"cpu": { "min": 2, "max": 8 },
"memory": { "min": "2Gi", "max": "16Gi" },
"storage": { "min": "64Gi", "max": "512Gi" }
}
},
{
"name": "ml",
"roles": ["ml"],
"deciders": {
"ml": {
"down_scale_delay": "10m"
}
},
"resources": {
"nodeCount": { "min": 1, "max": 9 },
"cpu": { "min": 1, "max": 4 },
"memory": { "min": "2Gi", "max": "8Gi" }
}
}]
}
name: elasticsearch-sample
spec:
version: 8.4.0
nodeSets:
- name: master
count: 1
count: 3
podTemplate:
spec:
containers:
- name: elasticsearch
# Specify both limits and requests to benefit from the desired nodes API / Elasticsearch resources aware management.
resources:
limits:
memory: 4Gi
cpu: 2
config:
node:
roles: [ "master" ]
Expand Down
22 changes: 22 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,25 @@ webhooks:
resources:
- elasticsearches
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-autoscaling-k8s-elastic-co-v1alpha1-elasticsearchautoscaler
failurePolicy: Ignore
matchPolicy: Exact
name: elastic-esa-validation-v1alpha1.k8s.elastic.co
rules:
- apiGroups:
- autoscaling.k8s.elastic.co
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- elasticsearchautoscalers
sideEffects: None
Loading