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

Add resize volume functionality to Logstash operator #7519

Merged
merged 19 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
32e7301
Move Logstash labels into its own package
robbavey Jan 31, 2024
f38bf74
Move statefulset functionality from elasticsearch to common
robbavey Jan 31, 2024
d70a2ad
Move shared volume validation features from elasticsearch to common p…
robbavey Jan 31, 2024
307ca94
Move shared volume claim expansion features from Elasticsearch packag…
robbavey Jan 31, 2024
a05cf0c
This commit adds expandable storage to logstash
robbavey Jan 31, 2024
e3fa13b
Update webhook to allow storage claims to have storage requests changed
robbavey Jan 31, 2024
836aed9
Add end to end test of Logstash volume expansion
robbavey Jan 31, 2024
b4f1600
Add Docs
robbavey Jan 31, 2024
f618631
Remove reference to ES in common podTemplate
robbavey Jan 31, 2024
f037af4
Apply suggestions from code review
robbavey Jan 31, 2024
1fa362a
Rework webhook validation to check storage requirements
robbavey Feb 1, 2024
fbed4df
Apply suggestions from code review
robbavey Feb 2, 2024
f5ac438
Code review: Rename essset import to es_set for readability
robbavey Feb 2, 2024
144644e
Use common statefulset fixtures in Elasticsearch sset package
robbavey Feb 2, 2024
86d7722
Code review: Use getIdentityLabels to populate GetPodIdentityLabels
robbavey Feb 2, 2024
23c1fdb
Remove unnecessary function
robbavey Feb 2, 2024
7822d0c
Add podTemplateValidator to Logstash statefulset reconciler
robbavey Feb 2, 2024
697ac88
Removed redundant tests
robbavey Feb 2, 2024
14957ba
Move annotationPrefix calculation outside of loop
robbavey Feb 5, 2024
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
5 changes: 3 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import (
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/kibana"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/license"
licensetrial "github.com/elastic/cloud-on-k8s/v2/pkg/controller/license/trial"
lsvalidation "github.com/elastic/cloud-on-k8s/v2/pkg/controller/logstash/validation"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/maps"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/remoteca"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/stackconfigpolicy"
Expand Down Expand Up @@ -1011,7 +1012,6 @@ func setupWebhook(
&kbv1.Kibana{},
&kbv1beta1.Kibana{},
&emsv1alpha1.ElasticMapsServer{},
&logstashv1alpha1.Logstash{},
&policyv1alpha1.StackConfigPolicy{},
}
for _, obj := range webhookObjects {
Expand All @@ -1027,9 +1027,10 @@ func setupWebhook(
}
}

// Elasticsearch and ElasticsearchAutoscaling validating webhooks are wired up differently, in order to access the k8s client
// Logstash, 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)
lsvalidation.RegisterWebhook(mgr, params.ValidateStorageClass, managedNamespaces)

// wait for the secret to be populated in the local filesystem before returning
interval := time.Second * 1
Expand Down
44 changes: 22 additions & 22 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,28 +202,6 @@ webhooks:
resources:
- kibanas
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-logstash-k8s-elastic-co-v1alpha1-logstash
failurePolicy: Ignore
matchPolicy: Exact
name: elastic-logstash-validation-v1alpha1.k8s.elastic.co
rules:
- apiGroups:
- logstash.k8s.elastic.co
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- logstashes
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -312,3 +290,25 @@ webhooks:
resources:
- elasticsearchautoscalers
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-logstash-k8s-elastic-co-v1alpha1-logstash
failurePolicy: Ignore
matchPolicy: Exact
name: elastic-logstash-validation-v1alpha1.k8s.elastic.co
rules:
- apiGroups:
- logstash.k8s.elastic.co
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- logstashes
sideEffects: None
14 changes: 11 additions & 3 deletions docs/orchestrating-elastic-stack-applications/logstash.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,18 @@ spec:
[discrete]
== Updating the volume claim settings

Changes, such as storage class or volume size, are currently forbidden in `spec.volumeClaimTemplates`.
To make these changes, you have to fully delete the {ls} resource, delete and recreate or resize the volume, and create a new {ls} resource.
If the storage class allows link:https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/[volume expansion], you can increase the storage requests size in `spec.volumeClaimTemplates`.
ECK updates the existing PersistentVolumeClaims accordingly, and recreates the StatefulSet automatically.

Before deleting or resizing a persistent queue (PQ) volume, ensure that the queue is empty.
If the volume driver supports `ExpandInUsePersistentVolumes`, the filesystem is resized online.
In this case, you do not need to restart the {ls} process or re-create the Pods.

If the volume driver does not support `ExpandInUsePersistentVolumes`, you must manually delete Pods after the resize so that they can be recreated automatically with the expanded filesystem.

Any other changes in the volumeClaimTemplates--such as changing the storage class or decreasing the volume size--are not allowed.
To make changes such as these, you must fully delete the {ls} resource, delete and recreate or resize the volume, and create a new {ls} resource.

Before you delete a persistent queue (PQ) volume, ensure that the queue is empty.
When using the PQ, we recommend setting `queue.drain: true` on the {ls} Pods to ensure that the queue is drained when Pods are shutdown.
Note that you should also increase the `terminationGracePeriodSeconds` to a large enough value to allow the queue to drain.

Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/logstash/v1alpha1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ func (logstash *Logstash) GetIdentityLabels() map[string]string {
"logstash.k8s.elastic.co/name": logstash.Name,
}
}

// GetPodIdentityLabels will return the common Elastic assigned labels for a Logstash Pod
func (logstash *Logstash) GetPodIdentityLabels() map[string]string {
robbavey marked this conversation as resolved.
Show resolved Hide resolved
return map[string]string{
commonv1.TypeLabelName: "logstash",
"logstash.k8s.elastic.co/name": logstash.Name,
"logstash.k8s.elastic.co/statefulset-name": Name(logstash.Name),
}
}
117 changes: 0 additions & 117 deletions pkg/apis/logstash/v1alpha1/validations.go

This file was deleted.

85 changes: 0 additions & 85 deletions pkg/apis/logstash/v1alpha1/webhook.go

This file was deleted.

Loading