5 - Observability Flashcards

1
Q

Create an nginx pod with a liveness probe that just runs the command ‘ls’. Save its YAML in pod.yaml. Run it, check its probe status, delete it.

A

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
resources: {}
livenessProbe: # our probe
exec: # add this line
command: # command definition
- ls # ls command
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Modify the pod.yaml file so that liveness probe starts kicking in after 5 seconds whereas the interval between probes would be 5 seconds. Run it, check the probe, delete it.

A

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
resources: {}
livenessProbe:
initialDelaySeconds: 5 # add this line
periodSeconds: 5 # add this line as well
exec:
command:
- ls
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Create an nginx pod (that includes port 80) with an HTTP readinessProbe on path ‘/’ on port 80. Again, run it, check the readinessProbe, delete it.

A

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
resources: {}
ports:
- containerPort: 80 # Note: Readiness probes runs on the container during its whole lifecycle. Since nginx exposes 80, containerPort: 80 is not required for readiness to work.
readinessProbe: # declare the readiness probe
httpGet: # add this line
path: / #
port: 80 #
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Lots of pods are running in qa,alan,test,production namespaces. All of these pods are configured with liveness probe. Please list all pods whose liveness probe are failed in the format of <namespace>/<pod> per line.</pod></namespace>

A

kubectl get events -o json | jq -r ‘.items[] | select(.message | contains(“failed liveness probe”)).involvedObject | .namespace + “/” + .name’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Create a busybox pod that runs i=0; while true; do echo “$i: $(date)”; i=$((i+1)); sleep 1; done. Check its logs

A

kubectl run busybox –image=busybox –restart=Never – /bin/sh -c ‘i=0; while true; do echo “$i: $(date)”; i=$((i+1)); sleep 1; done’
kubectl logs busybox -f # follow the logs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Create a busybox pod that runs ‘ls /notexist’. Determine if there’s an error (of course there is), see it. In the end, delete the pod

A

kubectl run busybox –restart=Never –image=busybox – /bin/sh -c ‘ls /notexist’
# show that there’s an error
kubectl logs busybox
kubectl describe po busybox
kubectl delete po busybox

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Create a busybox pod that runs ‘notexist’. Determine if there’s an error (of course there is), see it. In the end, delete the pod forcefully with a 0 grace period

A

kubectl run busybox –restart=Never –image=busybox – notexist
kubectl logs busybox # will bring nothing! container never started
kubectl describe po busybox # in the events section, you’ll see the error
# also…
kubectl get events | grep -i error # you’ll see the error here as well
kubectl delete po busybox –force –grace-period=0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Get CPU/memory utilization for nodes (metrics-server must be running)

A

kubectl top nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly