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

Autocreate data folder in Kubernetes deployments #7437

Merged
merged 6 commits into from
Jul 13, 2018

Conversation

exekias
Copy link
Contributor

@exekias exekias commented Jun 27, 2018

We need to persist beats data folder, so Pod restarts can still access
to the previous data.

This is particularly important in the case of Filebeat, as it needs the
registry file to avoid sending all logs again.

We need to persist beats data folder, so Pod restarts can still access
to the previous data.

This is particularly important in the case of Filebeat, as it needs the
registry file to avoid sending all logs again.
@exekias exekias added enhancement review needs_backport PR is waiting to be backported to other branches. containers Related to containers use case v6.3.1 labels Jun 27, 2018
- name: data
emptyDir: {}
hostPath:
path: /var/lib/filebeat-data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First reading this I thought it should be filebeat/data as that is kind of a standard directory we use for our data files. How does k8s now about this directory? Is it configured somewhere or is this based on convention?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mapping a folder from the container to the host. Kubernetes doesn't know anything about it, we request it to be created here, and mount it in the container, so data folder is persisted to the host.

I wanted to avoid using the default folder, in case someone is messing around by deploying Filebeat both in the host and as a container, which could end up in 2 Filebeat instances sharing the data folder.

@ruflin
Copy link
Contributor

ruflin commented Jun 28, 2018

It seems the travis tests suggest that the yaml is now invalid? https://travis-ci.org/elastic/beats/jobs/397307177 Related?

@exekias
Copy link
Contributor Author

exekias commented Jun 28, 2018

It is related indeed, it seems the path autocreate (DirectoryOrCreate) feature was introduced in k8s 1.8, so older versions would not work with this change. This is why the original emptydir + comment was there.

We should think about this twice, as it would break manifests compatibility with old versions, but is also a much better default for new deploys.

@exekias exekias added the discuss Issue needs further discussion. label Jun 28, 2018
@exekias
Copy link
Contributor Author

exekias commented Jun 28, 2018

So our options are:

  • Document the need to manually create the /var/lib/filebeat-data folder + update manifests for older Kubernetes versions.
  • Keep things as they are, but stress more the need to move from emptyDir to hostPath in our docs, as the comment in the manifest is missed by most users.

@ruflin
Copy link
Contributor

ruflin commented Jun 28, 2018

  • Could we have 2 versions of the manifests?
  • Do we have any numbers on what the most common versions of k8s are? Are users in general likely to update their k8s version frequently or are they stuck with certain versions because of breaking changes?

@moadqassem
Copy link

@exekias Just a small question, don't you need to update the filebeat config map too?

@exekias
Copy link
Contributor Author

exekias commented Jul 2, 2018

What kind of update? this change should be transparent to Filebeat, as we only change the mount point

@moadqassem
Copy link

@exekias filebeat.registry_file: /var/lib/filebeat-data

@exekias
Copy link
Contributor Author

exekias commented Jul 2, 2018

No, as this is mounted to the default path inside the container: https://github.com/exekias/beats/blob/43340ee3b983638bd7972623db5d6a056bf6cd05/deploy/kubernetes/filebeat-kubernetes.yaml#L101

@exekias exekias removed needs_backport PR is waiting to be backported to other branches. v6.3.1 labels Jul 11, 2018
@exekias exekias force-pushed the kubernetes-autocreate-data-folder branch from 573424a to 10208b6 Compare July 11, 2018 17:16
@exekias
Copy link
Contributor Author

exekias commented Jul 11, 2018

I've updated tests to remove k8s 1.7 and earlier, and add the last 1.11 release. I also updated docs with manual settings to use the manifest in deprecated versions.

This should be ready to go

@exekias
Copy link
Contributor Author

exekias commented Jul 11, 2018

I think we should not backport this to 6.3, so it will go to 6.4 once merged

@exekias exekias force-pushed the kubernetes-autocreate-data-folder branch 2 times, most recently from 7915b26 to 117b3d6 Compare July 11, 2018 23:53
@exekias exekias force-pushed the kubernetes-autocreate-data-folder branch from 117b3d6 to 833e317 Compare July 12, 2018 00:03
@ruflin
Copy link
Contributor

ruflin commented Jul 12, 2018

I think the travis failures are related?

@exekias
Copy link
Contributor Author

exekias commented Jul 12, 2018

It seems new minikube is failing to deploy a local k8s, will have a look

@exekias exekias added the in progress Pull request is currently in progress. label Jul 12, 2018
@exekias exekias removed the in progress Pull request is currently in progress. label Jul 12, 2018
@exekias
Copy link
Contributor Author

exekias commented Jul 12, 2018

Until kubernetes/minikube#2704 is fixed we are stuck to this version of minikube, I rolled back my changes to ensure tests pass.

@@ -14,6 +14,7 @@ env:
- GOX_FLAGS="-arch amd64"
- DOCKER_COMPOSE_VERSION=1.11.1
- GO_VERSION="$(cat .go-version)"
# Newer versions of minikube fail on travis, see: https://github.com/kubernetes/minikube/issues/2704
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to get this tests on Jenkins where we could test newer versions because we control the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Related to containers use case discuss Issue needs further discussion. enhancement review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants