-
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
Long-term story for /var/log support #818
Comments
The host path based on current configuration is: |
re-posting from slack for context Right now pod information cannot be obtained using the pod uid (see kubernetes/kubernetes#20572) The kubernetes API requires the namespace and pod name. One workaround is to have the namespace name included in the volume. You still need the pod name if you don't want to fetch all the pods. We can get the container name by explicitly putting it in the volume path (not the subpath). Two approaches:
The first solution would have the side effect of not needing to hit the k8s api to get the pod metadata (need to verify). Both these solutions don't have the container's id. As it's not supported in the downward API. @mdemirhan @yanweiguo @bsnchan I'm curious if the container id is used for any dashboards at the moment. We could open a k8s issue to get the container id as an exposed attribute that's available via the downward API. |
We don't use the container id in any dashboards currently. The container id in the plugin is used for cache. In second solution, I think we can generate container id with the value of pod id or pod name + namespace in fluent IMO, the second solution would be less complicated. |
An alternative method is to use a sidecar to tail files under The difficultly is that the file paths are arbitrary. We need a way to detect that a new file is created then start tailing it and stop tailing when it is deleted. There may be some lib supporting this. |
Now that the VolumeSubpathEnvExpansion feature is available as an Alpha feature, I think adding namespace and pod name in the subpath is the preferred option. Please comment on this and I can create a PR. |
Knative is a bit conservative and we don't adopt K8s alpha features. The
main reason is that providers of a hosted K8s don't typically turn on alpha
features for production clusters.
Hence why I'm waiting for VolumeSubpathEnvExpansion to become a beta feature
…On Wed, 13 Feb 2019 at 23:23 Cong Liu ***@***.***> wrote:
Now that the VolumeSubpathEnvExpansion
<https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath-with-expanded-environment-variables>
feature is available as an Alpha feature, I think adding namespace and pod
name in the subpath is the preferred option.
Please comment on this and I can create a PR.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#818 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABIgrEdwokxlj2QBe2lCaUCWn0BDlHFks5vNOS1gaJpZM4T1mwb>
.
|
fwiw, I do agree with the original comment that a fluentd sidecar is resource heavy. Sidecars are great, but I am really concerned they will affect the scalability and performance. So +1 on using a daemonset. |
@dprotaso @yanweiguo @bsnchan Should I remove your names from the assignees field and let someone else pick this work up? |
What version of Kubernetes introduces the feature we need as Beta? |
We need VolumeSubpathEnvExpansion feature. Still alpha in 1.14. |
Yeah I’ve been waiting for it to be beta
…On Fri, Apr 26, 2019 at 17:06 Yanwei Guo ***@***.***> wrote:
What version of Kubernetes introduces the feature we need as Beta?
We need VolumeSubpathEnvExpansion
<https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath-with-expanded-environment-variables>
feature. Still alpha in 1.14.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#818 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAERAQRTZZ7Y3RNPCA4X73PSNVETANCNFSM4E6WNQNQ>
.
|
1.14 alpha is way too far out. @mdemirhan suggested that we just volume mount We could also potentially mount |
/assign @JRBANCEL Talked to @mdemirhan about JR picking this up in 0.7. |
An advantage of the lightweight sidecar doing tail and writing to stdout is that these logs will also be available in kubectl logs. |
As discussed offline, this is not possible. The same goal can be achieved by mounting the host I don't think it is a great approach anyway:
To recap: Solution 1 - Tailing SidecarMounting
Solution 2 - Fluentd reads from volume directly
subPathExpr support is not required, fluentd relies on Ruby's Dir.glob for path expansion so To avoid collisions (i.e. non-Knative pods with a volume named |
@mattmoor, @yanweiguo, @mdemirhan please provide feedback. Going with solution 2, here is the plan:
|
From what I recall the fluentd daemonset needs pod name and namespace in this path regex in order to tag these logs with the appropriate pod metadata (annotations/labels etc). Is that still the case? |
Great question.
This seems pretty convoluted though. |
The k8s feature we're waiting for is providing the ability to inject pod name to volume path. |
Here is a solution to the tagging problem. We define 3 volumes:
An init container (or sidecar job to minimize startup time, ordering doesn't matter here) mounts
The host now has the following link: We add There is no copy, no sidecar, no fluentd plugin fork. Thoughts? |
SGTM |
Related to issue knative/serving#818 and change knative/serving#4156.
Expected Behavior
Collect logs from /var/log using the same DaemonSet which collects stderr/stdout logs.
Actual Behavior
/var/log is collect by a sidecar container per pod, which is resource heavy.
Additional Info
From @dprotaso: given that container volumes have a deterministic layout on the host
/var/lib/kubelet/pods/<pod uid>/volumes/<volume type>/<volume name>
We could get rid of the fluentd sidecar by modifying/forking the fluentd k8s metadata filter plugin. Then we could have fluentd source logs from
/var/lib/kubelet/pods/*/volumes/emptyDir/ela-varlog-volume/**/*.*
(volume name being created/controlled by the revision controller).The text was updated successfully, but these errors were encountered: