Question 15 - Cluster Event Logging
Question 15 | Cluster Event Logging
Use context: kubectl config use-context k8s-c2-AC
Write a command into /opt/course/15/cluster_events.sh which shows the latest events in the whole cluster, ordered by time (metadata.creationTimestamp). Use kubectl for it.
Now delete the kube-proxy Pod running on node cluster2-node1 and write the events this caused into /opt/course/15/pod_kill.log.
Finally kill the containerd container of the kube-proxy Pod on node cluster2-node1 and write the events into /opt/course/15/container_kill.log.
Do you notice differences in the events both actions caused?
# /opt/course/15/cluster_events.sh
echo 'kubectl get events -A --sort-by=.metadata.creationTimestamp' /opt/course/15/cluster_events.sh
# Deleting the pod
k -n kube-system get pod -o wide | grep proxy # find pod running on cluster2-node1
k -n kube-system delete pod kube-proxy-z64cg
# Checking the events
sh /opt/course/15/cluster_events.sh
###### Copy related events from output to /opt/course/15/pod_kill.log #####
# Now we need to kill the kube-proxy container inside the node
ssh cluster2-node1
# Let's find its id and remove it. Then we'll check if it comes back up, as the pod should recreate it
root@cluster2-node1:~# crictl ps | grep kube-proxy
1e020b43c4423 36c4ebbc9d979 About an hour ago Running kube-proxy ...
root@cluster2-node1:~# crictl rm 1e020b43c4423
1e020b43c4423
root@cluster2-node1:~# crictl ps | grep kube-proxy\
0ae4245707910 36c4ebbc9d979 17 seconds ago Running kube-proxy ...
# Going back to the default terminal
sh /opt/course/15/cluster_events.sh
###### Copy related events to /opt/course/15/container_kill.log ######
Killing a pod obviously generates more events than killing the container.