-
Notifications
You must be signed in to change notification settings - Fork 40k
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 LogDir #13010
Add LogDir #13010
Conversation
Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist") If this message is too spammy, please complain to ixdy. |
Thanks for taking the time to do a PR. Rather than re-using the How do you plan on integrating this with the fluentd logger that is onboard each node? It might be most effective to add a short (1-2 page) design document for the complete solution to this PR. You don't have to implement it all in 1 PR, but having a design document to guide the implementation will help both with the review, as well as with splitting up the work. Again, many thanks for taking this on. --brendan |
Also you need to run ./hack/update-generated-conversions.sh
./hack/update-generated-deep-copies.sh To regenerate some of the API conversion code that is generated from |
@brendandburns |
@wulonghui agree that this should be a new volume source. The design document can start out in docs/proposals -- it will move to docs/design when accepted. |
@brendandburns
The new generated code don't include
How shoud I do? |
Can you reset to HEAD all of the |
@brendandburns
Add the |
* LogDir: <kubelet_root_dir>/pods/<pod_id>/volumes/kubernetes.io~log-dir/<pod_full_name>/<volume_name> | ||
``` | ||
|
||
As we can see, `emptyDir` volume add a directory level: `pod_full_name`, the purpose is to make logging agent(e.g.fluentd) easy to add tag by `pod_full_name`. |
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.
I'd like to see how we configure fluentd or other collectors to find these logs. I'm concerned that the coupling may be too loose (it's a side-effect of the pod spec) and also end up hardcoding things like kubelet root dir (or else add more flags that have to be syncronized across configs).
I wonder if this might make more sense to promote to a full API construct - something like:
pod:
spec:
containers:
- name: foo
logDir: /var/log/foo
logPolicy:
rotate: Daily
I just threw that out, it's probably not at all the form we would want.
CC |
@brendandburns @thockin @saad-ali |
@brendandburns @thockin |
Design LGTM at a high level. Go ahead and code it up, please add an e2e test to validate that it works. Thanks again! |
I realize that there is a pain point you are trying to solve here. Namely that logs generated by containers don't end up in a persistent store. But I am not convinced that creating a new volume plugin is the solution. A volume plugin is the abstraction we use to enable new types of block storage. Log collection, log rotation, etc., I believe, are orthogonal to that and irrelevant to the volume layer. |
@saad-ali |
format none | ||
time_key time | ||
path /var/lib/kubelet/pods/*/volumes/kubernetes.io~log-dir/**/*.log | ||
pos_file /lib/pods.log.pos |
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.
I assume you mean /var/lib/... ?
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.
yes, this is a mistake.
Like @saad-ali, I was kind of surprised to see this as a volume plugin rather than as a separate subfield of container, but can see that it does make some sense. It's somewhat symmetric to the git-puller, which is basically a read-only mount that pulls data from elsewhere, whereas this is effectively a write-only mount that pushes data to elsewhere. However, it's a very reasonable argument to say that the git-puller doesn't really belong as a volume plugin either. The alternative we've considered in the past is to make this more of a first-class field in the |
@brendandburns @a-robinson @saad-ali |
@brendandburns @a-robinson @saad-ali
Cloud all of you check the design. Thanks |
Adding a LogDir field in the Container struct makes a lot more sense to me. |
@a-robinson Yes, I want to get this done. But I have been busy recently, would you take over this, and I want to help you. |
|
||
## Motivation | ||
|
||
Some applications will write log to files, so need to add `LogDir`. It can add some useful infomation to make logging agent easy to collect the logs, also we can manage the log files(like log rotation and maximum log file sizes). |
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.
Do we really need to support apps that want to write to files? Isn't the docker way to write logs to stdout? Docker has a fluentd logging driver - can that obviate this whole proposal?
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.
The docker way certainly is to write logs to stdout, but this is a frequently recurring feature request from folks whose applications weren't necessarily built to be run in a container. It's come up as an important issue for a handful of companies I've talked to, but cc @aronchick for better product perspective on the importance of this.
The docker logging drivers are orthogonal to collecting logs from files -- they just let you take the logs from stdout and do something with them other than have them written to a file.
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.
As someone who has hacked about 500 different ways trying to get apache to do this, I can see a lot of motivation here - definitely a frequent request. As part of supporting legacy apps, I'd like to pick something like this up.
Overall I think the approach is ok, I just want to understand the bounds of it and how much this encompasses. |
Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist") If this message is too spammy, please complain to ixdy. |
2 similar comments
Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist") If this message is too spammy, please complain to ixdy. |
Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist") If this message is too spammy, please complain to ixdy. |
@a-robinson / @wulonghui, I am interested in taking this PR forward. We have lot of existing services that pre-date docker and we are hoping to migrate them to hosted Kubernetes cluster. Having something like this for log-files collection would significantly ease their migration pain. Please let me know if you are ok with me working on it. Thanks! |
This PR has had no meaningful activity for multiple months. If it is still valid please rebase, push a new commit and reopen the PR. Thanks! |
Has any advance on this PR? This is a useful feature. |
Is logDir related support implemented? |
This did not get implemented. If someone wants to resurrect it, I think we On Sat, Sep 3, 2016 at 1:32 AM, radhey [email protected] wrote:
|
It would be great help as this will solve my logging feature issues. |
@itthought do you expect to work on this? we've seen a lot of requests for this feature. currently we just use sidecar, but are concerned with its performance and potential resource consumption as we'd have to run a sidecar per pod (possible resource waste as we give it 100m, 100M resource request and limit). /cc @harryge00 since you asked this before. |
This issue has been closed, but to where did the energy behind it migrate? |
I am very interested in this feature as i think it would solve all of my logging problems, |
This needs a chapion to drive it forward in the near term. On Fri, Oct 21, 2016 at 6:21 AM, Laura Herrera [email protected]
|
If anyone is interested in this or other logging in k8s topics, please join SIG-Instrumentation where we will cover this and more. If you are going to be at KubeCon in Seattle this November, please consider attending the logging face to face meeting. Details for that can be found in the SIG-Instrumentation google group. Currently its the most recent thread and its fairly low volume group so it should still be near the top. |
Hi, What is the status of the logDir feature? Will the feature be in v1.1? Thanks. |
@bamb00 Currently there's no plan to implement this feature as it is in this PR. There will be a proposal, covering logging architecture in Kubernetes, where this aspect will be explicitly explained, both if it's going to be implemented or not. Stay tuned and look for a related proposals in the community repo. |
I'm interested in this feature too. I just need a pointer on the approach to use. Below is the question I posted on SO.
|
I didn't hate this proposal, but like so many things we have on our collective plate, it needs someone to own it to completion, and nobody has stepped up yet. |
LogDir
Abstract
A proposal for implementing
LogDir
. ALogDir
can preserve and manage a pod's log files.Several existing issues and PRs were already created regarding that particular subject:
Author: WuLonghui (@wulonghui)
Motivation
Some applications will write log to files, so need to add
LogDir
. It can add some useful infomation to make logging agent easy to collect the logs, also we can manage the log files(like log rotation and maximum log file sizes).Implementation
Create
LogDir
as a policy toapi.VolumeMount
struct :If users set the LogDir policy of the VolumeMount in a container:
Kubelet will create a symbolic link to the volume path in
/var/log/containers
.Then the logging agent(e.g.Fluentd) can watch
/var/log/containers
on host to collect log files, add tag by<pod_full_name>_<contianer_name>
, which can be used for search terms in Elasticsearch or forlabels for Cloud Logging.
Integrated with Fluentd
We can use Fluentd to collect log files in
LogDir
. Fluentd should be installed on each Kubernetes node, and it will watch LogDir/var/log/containers
, the Fluentd's configuration as follows:The Fluentd will tail any files in the LogDir
/var/log/containers
, and add tagkubernetes.<node_host_name>.<pod_full_name>_<container_name>.<file_name>
. We only print the logs to stdout, also can forward to logging storage endpoint(e.g Elasticsearch).Then the Fluentd prints the logs to stdout:
Future work