<p>I have a cluster that has numerous services running as pods from which I want to pull logs with fluentd. <strong>All</strong> services show logs when doing <code>kubectl logs service</code>. However, some logs don't show up in those folders:</p>
<ul>
<li>/var/log</li>
<li>/var/log/containers</li>
<li>/var/log/pods</li>
</ul>
<p>although the other containers are there. The containers that ARE there are created as a Cronjob, or as a Helm chart, like a MongoDB installation.</p>
<p>The containers that aren't logging are created by me with a Deployment file like so:</p>
<pre><code>kind: Deployment
metadata:
    namespace: {{.Values.global.namespace | quote}}
    name: {{.Values.serviceName}}-deployment
spec:
    replicas: {{.Values.replicaCount}}
    selector:
        matchLabels:
            app: {{.Values.serviceName}}
    template:
        metadata:
            labels:
                app: {{.Values.serviceName}}
            annotations:
                releaseTime: {{ dateInZone &quot;2006-01-02 15:04:05Z&quot; (now) &quot;UTC&quot;| quote }}
        spec:
            containers:
                  - name: {{.Values.serviceName}}
                    # local: use skaffold, dev: use passed tag, test: use released version
                    image: {{ .Values.image }}
                        {{- if (eq .Values.global.env &quot;dev&quot;) }}:{{ .Values.imageConfig.tag}}{{ end }}
                    imagePullPolicy: {{ .Values.global.imagePullPolicy }}
                    envFrom:
                        - configMapRef:
                            name: {{.Values.serviceName}}-config
                    {{- if .Values.resources }}
                    resources:
                        {{- if .Values.resources.requests }}
                        requests:
                            memory: {{.Values.resources.requests.memory}}
                            cpu: {{.Values.resources.requests.cpu}}
                        {{- end }}
                        {{- if .Values.resources.limits }}
                        limits:
                            memory: {{.Values.resources.limits.memory}}
                            cpu: {{.Values.resources.limits.cpu}}
                        {{- end }}
                    {{- end }}
            imagePullSecrets:
                - name: {{ .Values.global.imagePullSecret }}  
            restartPolicy: {{ .Values.global.restartPolicy }}
{{- end }}
</code></pre>
<p>and a Dockerfile CMD like so:
<code>CMD [&quot;node&quot;, &quot;./bin/www&quot;]</code></p>
<p>One assumption might be that the CMD doesn't pipe to STDOUT, but why would the logs show up in <code>kubectl logs</code> then?</p>

<p>This is how I would proceed to find out where a container is logging:</p>
<ol>
<li><p>Identify the node on which the Pod is running with:</p>
<pre><code>kubectl get pod pod-name -owide
</code></pre>
</li>
<li><p>SSH on that node, you can check which logging driver is being used by the node with:</p>
<pre><code>docker info | grep -i logging
</code></pre>
<p>if the output is <code>json-file</code>, then the logs are being written to file as expected. If there is something different, then it may depends on what the driver do (there are many drivers, they could write to <code>journald</code> for example, or other options)</p>
</li>
<li><p>If the logging driver writes to file, you can check the current output for a specific Pod by knowing the container id of that Pod, to do so, on a control-plane node:</p>
<pre><code>kubectl get pod pod-name -ojsonpath='{.status.containerStatuses[0].containerID}'
</code></pre>
<p>(if there are more containers in the same pod, the index to use may vary, depending on which container you want to inspect)</p>
</li>
<li><p>With the id extracted, which will be something like <code>docker://f834508490bd2b248a2bbc1efc4c395d0b8086aac4b6ff03b3cc8fd16d10ce2c</code>, you can inspect the container with docker, on the node on which the container is running. Just remove the <code>docker://</code> part from the id, SSH again on the node you identified before, then do a:</p>
<pre><code>docker inspect container-id | grep -i logpath
</code></pre>
</li>
</ol>
<p>Which should output where the container is actively writing its logs to file.</p>
<hr />
<p>In my case, the particular container I tried this procedure on, is currently logging into:</p>
<pre><code>/var/lib/docker/containers/289271086d977dc4e2e0b80cc28a7a6aca32c888b7ea5e1b5f24b28f7601ff63/289271086d977dc4e2e0b80cc28a7a6aca32c888b7ea5e1b5f24b28f7601ff63-json.log
</code></pre>
