Use context: kubectl config use-context k8s-c1-H

In Namespace project-tiger create a Pod named tigers-reunite of image httpd:2.4.41-alpine with labels pod=container and container=pod. Find out on which node the Pod is scheduled. Ssh into that node and find the containerd container belonging to that Pod.

Using command crictl :

Write the ID of the container and the info.runtimeType into /opt/course/17/pod-container.txt Write the logs of the container into /opt/course/17/pod-container.log


译文:

在名字空间 project-tiger 中,创建一个名为 tigers-reunite 的Pod,镜像为 httpd:2.4.41-alpine ,标签为 pod=containercontainer=pod 。找出Pod被安排在哪个节点上。Ssh进入该节点,找到属于该Pod的containerd容器。

使用 crictl 命令。

将容器的 IDinfo.runtimeType 写入 /opt/course/17/pod-container.txt 中。 将容器的日志写入 /opt/course/17/pod-container.log


解答:
kubectl config use-context k8s-c1-H

创建pod

k -n project-tiger run tigers-reunite \
  --image=httpd:2.4.41-alpine \
  --labels="pod=container,container=pod"

查看pod所在节点

k -n project-tiger get pod tigers-reunite -o wide

file

远程连接node

ssh cluster1-node2
root@cluster1-node2:~# crictl ps | grep tigers-reunite
root@cluster1-node2:~# crictl inspect b01edbe6f89ed | grep runtimeType
root@cluster1-node2:~# exit

file

写内容到文件

echo "6253a89688d7d io.containerd.runc.v2" > /opt/course/17/pod-container.txt
ssh cluster1-node2 'crictl logs 6253a89688d7d' &> /opt/course/17/pod-container.log

file


Killer.sh CKA模拟题目 汇总