-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update information about changing Fluentd persistence
- Loading branch information
1 parent
e6f56c9
commit aae5cfd
Showing
5 changed files
with
327 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,292 @@ | ||
# Fluentd persistence | ||
|
||
Starting with `v2.0.0` we're using file-based buffer for Fluentd instead of less | ||
reliable in-memory buffer. | ||
|
||
The buffer configuration can be set in the `values.yaml` file under the `fluentd` | ||
key as follows: | ||
|
||
```yaml | ||
fluentd: | ||
persistence: | ||
enabled: true | ||
``` | ||
|
||
When setting for Fluentd persistence is changed (enable or disable) it is required to recreate or delete existing Fluentd StatefulSet, | ||
as it is not possible to change it and add/remove `volumeClaimTemplate`. | ||
|
||
**Note:** The below commands are using `yq` in version `3.4.0` <= `x` < `4.0.0`. | ||
|
||
## Enabling Fluentd persistence | ||
|
||
To enable Fluentd persistence in existing collection modify `values.yaml` file under the `fluentd` | ||
key as follows: | ||
|
||
```yaml | ||
fluentd: | ||
persistence: | ||
enabled: true | ||
## If defined, storageClassName: <storageClass> | ||
## If set to "-", storageClassName: "", which disables dynamic provisioning | ||
## If undefined (the default) or set to null, no storageClassName spec is | ||
## set, choosing the default provisioner. (gp2 on AWS, standard on | ||
## GKE, Azure & OpenStack) | ||
## | ||
# storageClass: "-" | ||
# annotations: {} | ||
accessMode: ReadWriteOnce | ||
size: 10Gi | ||
``` | ||
|
||
Use one of following two strategies to prepare existing collection for enabling Fluentd persistence: | ||
|
||
- ### Enabling Fluentd persistence by recreating Fluentd StatefulSet | ||
|
||
Recreating Fluentd StatefulSet with new `volumeClaimTemplate` may cause that logs and metrics | ||
will not be available in the time of recreation. It usually shouldn't take more than several seconds. | ||
|
||
To recreate Fluentd StatefulSets with new `volumeClaimTemplate` one can run | ||
the following commands for all Fluentd StatefulSets: | ||
|
||
```bash | ||
VOLUME_CLAIM_TEMPLATE=$(cat <<-"EOF" | ||
metadata: | ||
name: buffer | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
EOF | ||
) && \ | ||
BUFFER_VOLUME=$(cat <<-"EOF" | ||
mountPath: /fluentd/buffer | ||
name: buffer | ||
EOF | ||
)&& \ | ||
kubectl --namespace <NAMESPACE-NAME> get statefulset <RELEASE-NAME>-sumologic-fluentd-logs --output yaml | \ | ||
yq w - "spec.volumeClaimTemplates[+]" --from <(echo "${VOLUME_CLAIM_TEMPLATE}") | \ | ||
yq w - "spec.template.spec.containers[0].volumeMounts[+]" --from <(echo "${BUFFER_VOLUME}") | \ | ||
kubectl apply --namespace <NAMESPACE-NAME> --force --filename - | ||
``` | ||
```bash | ||
VOLUME_CLAIM_TEMPLATE=$(cat <<-"EOF" | ||
metadata: | ||
name: buffer | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
EOF | ||
) && \ | ||
BUFFER_VOLUME=$(cat <<-"EOF" | ||
mountPath: /fluentd/buffer | ||
name: buffer | ||
EOF | ||
)&& \ | ||
kubectl --namespace <NAMESPACE-NAME> get statefulset <RELEASE-NAME>-sumologic-fluentd-metrics --output yaml | \ | ||
yq w - "spec.volumeClaimTemplates[+]" --from <(echo "${VOLUME_CLAIM_TEMPLATE}") | \ | ||
yq w - "spec.template.spec.containers[0].volumeMounts[+]" --from <(echo "${BUFFER_VOLUME}") | \ | ||
kubectl apply --namespace <NAMESPACE-NAME> --force --filename - | ||
``` | ||
```bash | ||
VOLUME_CLAIM_TEMPLATE=$(cat <<-"EOF" | ||
metadata: | ||
name: buffer | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
EOF | ||
) && \ | ||
BUFFER_VOLUME=$(cat <<-"EOF" | ||
mountPath: /fluentd/buffer | ||
name: buffer | ||
EOF | ||
)&& \ | ||
kubectl --namespace <NAMESPACE-NAME> get statefulset <RELEASE-NAME>-sumologic-fluentd-events --output yaml | \ | ||
yq w - "spec.volumeClaimTemplates[+]" --from <(echo "${VOLUME_CLAIM_TEMPLATE}") | \ | ||
yq w - "spec.template.spec.containers[0].volumeMounts[+]" --from <(echo "${BUFFER_VOLUME}") | \ | ||
kubectl apply --namespace <NAMESPACE-NAME> --force --filename - | ||
``` | ||
Remember to adjust `volumeClaimTemplate` (`VOLUME_CLAIM_TEMPLATE` variable in command above) | ||
which will be added to `volumeClaimTemplates` in StatefulSet `spec` according to your needs, | ||
for details please check `PersistentVolumeClaim` in Kubernetes API specification. | ||
**Notice** When StatefulSets managed by helm are modified by commands specified above, | ||
one might expect a warning similar to the one below: | ||
`Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply` | ||
- ### Enabling Fluentd persistence by preparing temporary instances of Fluentd and removing earlier created | ||
To create temporary instances of Fluentd StatefulSets and avoid of break in logs and metrics: | ||
```bash | ||
kubectl get statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-logs --output yaml | \ | ||
yq w - "metadata.name" tmp-<RELEASE-NAME>-sumologic-fluentd-logs | \ | ||
yq w - "metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.template.metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.selector.matchLabels[heritage]" "tmp" | \ | ||
kubectl create --filename - | ||
``` | ||
```bash | ||
kubectl get statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-metrics --output yaml | \ | ||
yq w - "metadata.name" tmp-<RELEASE-NAME>-sumologic-fluentd-metrics | \ | ||
yq w - "metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.template.metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.selector.matchLabels[heritage]" "tmp" | \ | ||
kubectl create --filename - | ||
``` | ||
```bash | ||
kubectl get statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-events --output yaml | \ | ||
yq w - "metadata.name" tmp-<RELEASE-NAME>-sumologic-fluentd-events | \ | ||
yq w - "metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.template.metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.selector.matchLabels[heritage]" "tmp" | \ | ||
kubectl create --filename - | ||
``` | ||
Delete old instances of Fluentd StatefulSets: | ||
```bash | ||
kubectl wait --for=condition=ready pod \ | ||
--namespace <NAMESPACE-NAME> \ | ||
--selector "release==<RELEASE-NAME>,heritage=tmp" && \ | ||
kubectl delete statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-events && \ | ||
kubectl delete statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-logs && \ | ||
kubectl delete statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-metrics | ||
``` | ||
**Notice:** After collection upgrade is done, in order to remove the temporary Fluentd | ||
StatefulSets run the following command: | ||
```bash | ||
kubectl wait --for=condition=ready pod \ | ||
--namespace <NAMESPACE-NAME> \ | ||
--selector "release==<RELEASE-NAME>,heritage=Helm" && \ | ||
kubectl delete statefulset \ | ||
--namespace <NAMESPACE-NAME> \ | ||
--selector "release==<RELEASE-NAME>,heritage=tmp" | ||
``` | ||
Upgrade collection with Fluentd persistence enabled, e.g. | ||
```bash | ||
helm upgrade <RELEASE-NAME> sumologic/sumologic --version=<VERSION> -f <VALUES> | ||
``` | ||
## Disabling Fluentd persistence | ||
To disable Fluentd persistence in existing collection modify `values.yaml` file under the `fluentd` | ||
key as follows: | ||
```yaml | ||
fluentd: | ||
persistence: | ||
enabled: false | ||
``` | ||
Use one of following two strategies to prepare existing collection for disabling Fluentd persistence: | ||
- ### Disabling Fluentd persistence by recreating Fluentd StatefulSet | ||
Recreating Fluentd StatefulSet without `volumeClaimTemplate` may cause that logs and metrics | ||
will not be available in the time of recreation. It usually shouldn't take more than several seconds. | ||
To recreate Fluentd StatefulSets without `volumeClaimTemplate` one can run | ||
the following commands for all Fluentd StatefulSets: | ||
```bash | ||
kubectl --namespace <NAMESPACE-NAME> get statefulset <RELEASE-NAME>-sumologic-fluentd-logs --output yaml | \ | ||
yq d - "spec.template.spec.containers[*].volumeMounts(name==buffer)" | \ | ||
yq d - "spec.volumeClaimTemplates(metadata.name==buffer)" | \ | ||
kubectl apply --namespace <NAMESPACE-NAME> --force --filename - | ||
``` | ||
```bash | ||
kubectl --namespace <NAMESPACE-NAME> get statefulset <RELEASE-NAME>-sumologic-fluentd-metrics --output yaml | \ | ||
yq d - "spec.template.spec.containers[*].volumeMounts(name==buffer)" | \ | ||
yq d - "spec.volumeClaimTemplates(metadata.name==buffer)" | \ | ||
kubectl apply --namespace <NAMESPACE-NAME> --force --filename - | ||
``` | ||
```bash | ||
kubectl --namespace <NAMESPACE-NAME> get statefulset <RELEASE-NAME>-sumologic-fluentd-events --output yaml | \ | ||
yq d - "spec.template.spec.containers[*].volumeMounts(name==buffer)" | \ | ||
yq d - "spec.volumeClaimTemplates(metadata.name==buffer)" | \ | ||
kubectl apply --namespace <NAMESPACE-NAME> --force --filename - | ||
``` | ||
**Notice** When StatefulSets managed by helm are modified by commands specified above, | ||
one might expect a warning similar to the one below: | ||
`Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply` | ||
- ### Disabling Fluentd persistence by preparing temporary instances of Fluentd and removing earlier created | ||
To create temporary instances of Fluentd StatefulSets and avoid of break in logs and metrics: | ||
```bash | ||
kubectl get statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-logs --output yaml | \ | ||
yq w - "metadata.name" tmp-<RELEASE-NAME>-sumologic-fluentd-logs | \ | ||
yq w - "metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.template.metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.selector.matchLabels[heritage]" "tmp" | \ | ||
kubectl create --filename - | ||
``` | ||
```bash | ||
kubectl get statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-metrics --output yaml | \ | ||
yq w - "metadata.name" tmp-<RELEASE-NAME>-sumologic-fluentd-metrics | \ | ||
yq w - "metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.template.metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.selector.matchLabels[heritage]" "tmp" | \ | ||
kubectl create --filename - | ||
``` | ||
```bash | ||
kubectl get statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-events --output yaml | \ | ||
yq w - "metadata.name" tmp-<RELEASE-NAME>-sumologic-fluentd-events | \ | ||
yq w - "metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.template.metadata.labels[heritage]" "tmp" | \ | ||
yq w - "spec.selector.matchLabels[heritage]" "tmp" | \ | ||
kubectl create --filename - | ||
``` | ||
Delete old instances of Fluentd StatefulSets: | ||
```bash | ||
kubectl wait --for=condition=ready pod \ | ||
--namespace <NAMESPACE-NAME> \ | ||
--selector "release==<RELEASE-NAME>,heritage=tmp" && \ | ||
kubectl delete statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-events && \ | ||
kubectl delete statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-logs && \ | ||
kubectl delete statefulset --namespace <NAMESPACE-NAME> <RELEASE-NAME>-sumologic-fluentd-metrics | ||
``` | ||
**Notice:** After collection upgrade is done, in order to remove the temporary Fluentd | ||
StatefulSets run the following command: | ||
```bash | ||
kubectl wait --for=condition=ready pod \ | ||
--namespace <NAMESPACE-NAME> \ | ||
--selector "release==<RELEASE-NAME>,heritage=Helm" && \ | ||
kubectl delete statefulset \ | ||
--namespace <NAMESPACE-NAME> \ | ||
--selector "release==<RELEASE-NAME>,heritage=tmp" | ||
``` | ||
Upgrade collection with Fluentd persistence disabled, e.g. | ||
```bash | ||
helm upgrade <RELEASE-NAME> sumologic/sumologic --version=<VERSION> -f <VALUES> | ||
``` |
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
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
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