Skip to content

Latest commit

 

History

History
 
 

logging

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Logging within kubernetes

This exercise creates a pod on the Kubernetes cluster which logs the timestamp. With kubectl the logs can be viewed.

Goto the git workshop logging directory:

cd /Workshop-K8S/k8s/logging/

view the content of counter-pod.yaml

cat counter-pod.yaml

The output is:

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)"; i=$((i+1)); sleep 1; done',
        ]

Create log container in default namespace

kubectl apply -f counter-pod.yaml

The output is:

pod/counter created

Look at the logs of this pod

kubectl logs counter -f