-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Collect /var/log without fluentd sidecar #4156
Collect /var/log without fluentd sidecar #4156
Conversation
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.
Mostly LGTM. Left some nits.
config/monitoring/logging/elasticsearch/100-fluentd-configmap.yaml
Outdated
Show resolved
Hide resolved
/approve /hold You can |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: evankanderson, JRBANCEL The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Please review again.
What has changed:
|
aa4b3c7
to
0988310
Compare
/retest |
/lgtm |
4a9250f
to
338183c
Compare
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 for the test -- I'm wondering if the linking logic it should live in cmd
or pkg
.
Also, I'm wondering if a small design doc would help explain this -- doing this from another container is very clever, but I worry that future readers will be confused.
It's particularly nice that this doesn't require additional privilege for the queue-proxy, just a shared volume.
Yes, I was thinking about updating the doc and add more details about how and why it works. Right now, this is blocked because we want the default GKE fluentd configuration to capture those /var/log logs out of the box. I'll update their fluentd config and submit a PR. |
@@ -99,6 +106,17 @@ func initEnv() { | |||
servingService = os.Getenv("SERVING_SERVICE") // KService is optional | |||
userTargetPort = util.MustParseIntEnvOrFatal("USER_PORT", logger) | |||
userTargetAddress = fmt.Sprintf("127.0.0.1:%d", userTargetPort) | |||
userContainerName = util.GetRequiredEnvOrFatal("USER_CONTAINER_NAME", logger) | |||
|
|||
enableVarLogCollection, _ = strconv.ParseBool(os.Getenv("ENABLE_VAR_LOG_COLLECTION")) // Optional, default is false |
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.
Given the simplicity of this trick, what are the trade-offs that would lead us to not simply enable this by default?
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.
- Cost: why pay for logs you don't need by default?
- Privacy: I am not sure collecting everything in /var/log by default is safe, who knows what is logged there
- Backwards compatibility
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.
Can't the log collection and so forth be controlled by either the fluentd config or by deleting the daemonset?
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, one can modify the fluentd config, but:
- It is global, there was a discussion about making varlog collection a flag per revision instead of globally. This makes the implementation of such feature easy.
- It is not always possible (GKE default fluentd config cannot be modified for example). More generally, it is not necessarily the same people operating Knative and fluentd (the infra).
…ags and proper stream field
Speeds up startup by preventing k8s to look for the latest image everytime it starts a pod.
766e689
to
3f9b182
Compare
The following is the coverage report on pkg/.
|
Related to issue knative/serving#818 and change knative/serving#4156.
Can someone give this a new /lgtm before new conflicts show up? |
/lgtm |
/hold cancel |
/retest |
1 similar comment
/retest |
Fixes #818
Proposed Changes
Have fluend daemon set capture
user-container
's/var/log
logs directly instead of injecting a fluentd sidecar.Changes:
user-container
's/var/log
volume with the information needed bykubernetes_metadata_filter
. See this for more details.Result
Given some container logging to stdout/stderr and various files inside /var/log:

The resulting logs are captured and enriched by fluentd daemon set.
I also added some fluentd magic so that the logs coming from /var/log have a
stream
field populated with the path of the log file so that it matches what docker does withstream
being eitherstdout
orstderr
.Next
Add E2E test as part of #647