How to mimic "--log-driver=syslog" in Kubernetes
Starting with the available documentation: in your case on logging and volumes. Taking these two sources together we arrive at something like the following:
...containers: - name: syslogtest image: ubuntu:14.04 volumeMounts: - name: logvol mountPath: /dev/log readOnly: falsevolumes: - name: logvol source: hostDir: path: /dev/log...
i dont think kubernetes need to do such --log-driver options in pod json file. As my experience, you can set such setting in docker service. i.e check
/etc/systemd/system/docker.service
and set ExecStart=/usr/bin/docker daemon --log-driver=json-file blablabla. more information could be get here: https://docs.docker.com/engine/admin/logging/overview/#configure-logging-drivers
further more, if you don't set this --log-driver, by default the json file will be created, which collected all logs of your containers in kubernetes pods, you can find those files on
your_docker_runtime_root/docker/containers/container_id/container_id-json.json
it's been discussed for quite a while here in this thread: https://github.com/kubernetes/kubernetes/issues/15478, however k8s community really recommend to have your own dedicated log agent. you can choose to run it under each host machine or use it as sidecar or more recommended as a DaemonSet.
see details here: https://kubernetes.io/docs/concepts/cluster-administration/logging/#cluster-level-logging-architectures
since k8s is leaving dockerd
and moving to containerd
, you will not even have the option to configure dockerd logging driver and log opts. so you either can wait for k8s community to add logging driver opts or use one of the above approaches.