Logging & Debugging
Tips and Tricks
For simulated Practice problems visit KillerCoda.
-
create a namespace
distro
.Run abusybox
pod namebbox
with commandi=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done
indistro
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
-
Create a
bitto
pod withbusybox
image. It runs a commandls \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