-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(api): Replace fluentd deployment with statefulset #370
Merged
deadlycoconuts
merged 12 commits into
caraml-dev:main
from
deadlycoconuts:change_fluentd_deployment_to_stateful_set
Apr 3, 2024
Merged
feat(api): Replace fluentd deployment with statefulset #370
deadlycoconuts
merged 12 commits into
caraml-dev:main
from
deadlycoconuts:change_fluentd_deployment_to_stateful_set
Apr 3, 2024
Conversation
This file contains 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
46901e4
to
24bf66a
Compare
a5acd4b
to
222b95f
Compare
deadlycoconuts
commented
Mar 27, 2024
deadlycoconuts
commented
Mar 27, 2024
leonlnj
reviewed
Apr 2, 2024
leonlnj
reviewed
Apr 2, 2024
leonlnj
reviewed
Apr 2, 2024
…number of replicas
ce7c839
to
e7bb62d
Compare
leonlnj
reviewed
Apr 2, 2024
leonlnj
approved these changes
Apr 2, 2024
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.
thanks, lgtm!
ariefrahmansyah
approved these changes
Apr 3, 2024
Thanks for the reviews everyone! Merging this now! 🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
In order to make the Fluentd deployment used by a Turing router deployment (to flush logs to BigQuery) more robust to cluster autoscaling events, which may remove the node on which the one and only Fluentd pod is scheduled and cause the Turing routers to return errors, we need to increase the number of replicas of the Fluentd deployment from 1 to 2.
However, doing so involves replacing how Turing deploys the Fluentd deployment - from a Kubernetes Deployment resource to a StatefulSet. This is needed because deployments do not allow its pod replicas to specify volume/volume mount names that are different. This is crucial because the PVC that the current Fluentd pod uses is of the ReadWriteOnce type, which means that Fluentd replicas need to be scheduled on the same node in order to read/write on the same PVC. Other access mode exist - such as ReadOnlyMany and ReadWriteMany. However, ReadOnlyMany wouldn't allow Fluentd to write anything to the PVC, completely voiding the original purpose of even attaching a PVC to Fluentd, while ReadWriteMany isn't available in all managed Kubernetes services.
By replacing the Deployment with a StatefulSet, we are able to specify a generic name for any of the PVCs that will be spun up in tandem with the number of pods the StatefulSet controls. This allows us to increase the number of Fluentd pods to 2, which allows for better uptime of the Fluentd service, especially when we introduce other configurations such as PodDisruptionBudgets.
As we are increasing the number of Fluentd pods, we are also halving the amount of CPU and memory resources requested for each pod to keep the total amount of resources consumed the same as before.
Additional Changes
This PR also includes a tiny change to the pod disruption budget selector key used for Knative services (Turing routers, enrichers and ensemblers) from
app
toserving.knative.dev/service
. This is done because the label value corresponding to theapp
key on these Knative service-managed pods have an additional suffix (e.g.-0
) that indicates the revision number of the deployment.While this isn't a problem in most instances, any manual edits made to the Knative service manifest would undoubtedly cause the revision number to be bumped (e.g. from
0
to1
), making the existing pod disruption budget resources created useless. This isn't the case however, for the label value corresponding to theserving.knative.dev/service
key, which does not have the additional revision number suffix.Main Modifications
api/turing/cluster/controller.go
- Refactoring of the steps to deploy Fluentd as a stateful set instead of a deploymentapi/turing/cluster/kubernetes_service.go
- Refactoring of the Fluentd deployment spec to a statefulset specapi/turing/cluster/servicebuilder/fluentd.go
- Halving of Fluentd CPU and memory resources for each podapi/turing/cluster/servicebuilder/service_builder.go
- Addition of steps to configure PDBs differently for Fluentdapi/turing/service/router_deployment_service.go
- Removal of steps needed to manually create/delete PVCs