Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mimic "--log-driver=syslog" in Kubernetes

With docker, I can pass log-driver=syslog command line option to forward container logs to syslog. How do I pass these docker arguments via Kubernetes yaml/json descriptor?

like image 615
Anil G Avatar asked Nov 18 '15 03:11

Anil G


2 Answers

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: false
volumes:
  - name: logvol
    source:
      hostDir:
        path: /dev/log
...
like image 86
Michael Hausenblas Avatar answered Oct 10 '22 12:10

Michael Hausenblas


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
like image 23
Zhi Yuan Avatar answered Oct 10 '22 13:10

Zhi Yuan