Skip to content

Latest commit

 

History

History
70 lines (60 loc) · 1.93 KB

File metadata and controls

70 lines (60 loc) · 1.93 KB

Logging & Debugging

Logging & Debugging
Tips and Tricks

For simulated Practice problems visit KillerCoda.
  1. create a namespace distro.Run a busybox pod name bbox with command i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done in distro namespace. Tails logs of the pod.

    Solution

    # create the namespace
    k create ns distro
    
    # create pod with the specified command
    apiVersion: v1
    kind: Pod
    metadata:
      creationTimestamp: null
      labels:
        run: bbox
      name: bbox
      namespace: distro
    spec:
      containers:
      - image: busybox
        name: bbox
        command: ["sh","-c","i=0; while true; do echo '$i: $(date)'; i=$((i+1)); sleep 1; done"]
      dnsPolicy: ClusterFirst
      restartPolicy: Always
    status: {}
    
    # tail the logs
    k logs bbox -n distro -t

  2. Create a bitto pod with busybox image. It runs a command ls \here. Check if the pod is running successfully, if not check why it's not running & then delete it.

    Solution

    # create the namespace
    k create ns nano
    
    # create pod with the specified command
    apiVersion: v1
    kind: Pod
    metadata:
      creationTimestamp: null
      labels:
        run: bitto
      name: bitto
    spec:
      containers:
      - image: busybox
        name: bitto
        command: ["sh","-c","ls /here"]
      dnsPolicy: ClusterFirst
      restartPolicy: Always
    status: {}
    
    # check details of the pod
    k describe po bitto