Kubernetes で動かしているアプリケーションのログを収集するものを DaemonSet で動かすようにした。今までは温かみのある手作業でノードにセットアップしていたので、大幅に改善された。
ログは /var/log/containers/xxx.log に吐き出されるので、tail などで内容を取ればよい。
各ノードで 1 つずつ実行されてほしいので、DaemonSet で配置する。
apiVersion: apps/v1kind: DaemonSetmetadata:name: logspec:selector:matchLables:name: logtemplate:metadata:labels:name: logspec:containers:- name: logimage: xxxsecurityContext:runAsUser: 0 # /var/log/containers へのアクセスが必要なためvolumeMounts:- mountPath: /var/log/containersname: containers- mountPath: /var/log/podsname: podsvolumes:- name: containershostPath:path: /var/log/containerstype: Directory- name: podshostPath:path: /var/log/podstype: Directory