Avi
Avi

Reputation: 1633

Kubernetes basic pod logging

Hi I'm trying to setup basic logging to get all my pod logs at a single place. Following is the pod-spec I have created but couldn't find the trace of the logs in the location mentioned. What could be missing in the template below?

    apiVersion: v1
    kind: Pod
    metadata:
      name: counter
    spec:
      containers:
    - name: count
        image: busybox
        args: [/bin/sh, -c,
        'i=0; while true; do echo "$i: $(date)" >> /u01/kubernetes_prac/logs/log_output.txt; i=$((i+1)); sleep 1; done']
        volumeMounts:
        - name: varlog
          mountPath: /u01/kubernetes_prac/logs
      volumes:
      - name: varlog
        emptyDir: {}

Upvotes: 2

Views: 222

Answers (2)

Sergio Teixeira
Sergio Teixeira

Reputation: 36

Look into fluentd , to save ur logs somewhere(s3, elastic etc)

Upvotes: 0

Sergio Teixeira
Sergio Teixeira

Reputation: 36

try this:

volumes:
  - name: varlog
    hostPath:
      path: /tmp/logs

and check the node logs on that location

Upvotes: 2

Related Questions