kubernetes: Kubelet is not creating the log symlink
/kind bug
What happened: Kubelet is not creating the log symlink for some containers at ‘/var/log/containers’
What you expected to happen:
The symlink is a requirement for fluentd, we expect to have a symlink for any running container inside a pod.
How to reproduce it (as minimally and precisely as possible):
We run test with the following script and found many cases, but we could not reproduced in a dev environment.
#!/bin/bash
docker ps -q | while read line;
do
if [ `find /var/log/containers -name *$line* | wc -l` = "0" ]
then
name=`docker inspect --format {{.Name}} $line | head -c 8 `
if [ $name != "/k8s_POD" ]
then
docker inspect --format {{.Name}} $line
fi
fi
done
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version
):
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.7", GitCommit:"8eb75a5810cba92ccad845ca360cf924f2385881", GitTreeState:"clean", BuildDate:"2017-04-27T10:00:30Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.7", GitCommit:"8eb75a5810cba92ccad845ca360cf924f2385881", GitTreeState:"clean", BuildDate:"2017-04-27T09:42:05Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
- Cloud provider or hardware configuration**:
- OS (e.g. from /etc/os-release):
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.2 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
- Kernel (e.g.
uname -a
):
uname -a
Linux master0 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Containers: 26
Running: 18
Paused: 0
Stopped: 8
Images: 20
Server Version: 1.12.6
Storage Driver: aufs
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 7
- Comments: 74 (16 by maintainers)
@joelittlejohn Here’s my solution which is based on yours. This uses a DaemonSet. It replaces symlinks in both /var/log/containers and /var/log/pods, since I was having trouble with that.
log-linker.sh
:Dockerfile
:deploy.yaml
:(This code is under the MIT License.)
Is this being worked on? I think we are hitting this issue.
still reproducible
For those watching this issue, joelittlejohn and cjyar updated their comments to license the code under MIT (you don’t get notifications for edits). Thanks guys!
@joelittlejohn @cjyar Could you guys to attach a license to that code (e.g. MIT) so that others can (safely) use it?
It’s not fancy, but here’s what I came up with.
I add the following units to the CoreOS cloud-config for my nodes:
then add this script to the write-files section of the cloud-config (note: requires
jq
):Of course for anyone that doesn’t want to create a CoreOS (or similar) cloud-config in this way, you can just take the ensure-log-symlinks.sh script content and use that.
Note: All code in this comment is licensed by me, the author, under the MIT License.
I occuer the same problem. After many tries , I found the cause is that I changed docker log driver from json to others. When i change it back, it fixed. I hope that can help u.
Hello joel,
I understand that the effort to upgrade is not simple, so if the change is merge you will need to port of upgrade. I have build a workaround for a client some time ago, still not ideal but it does fix the issue.
Ideally you can run a daemonset that evaluate the sysmlinks and recreated when this symlink is deleted by the kubelet every minute.
You will need access to the docker interface, and the directory.
This pice of code is all you need.
Regards.