Pages

Monday, January 10, 2022

Kubernetes - Ephemeral Container : Copy Of Pod By Changing Image

Most of the time, developers deploy their application in small sized images which does not contain any debugging utilities. As a practice, they deploy the code in distroless images. But when that application is misbehaving, kubernetes provides us a way to change that container image to another image which contain debugging utilities.

Create a Image using the Image BusyBox as below,
[root@ec2-3-138-100-101 ec2-user]# kubectl run myapp --image=busybox --restart=Never -- sleep 1d
pod/myapp created

[root@ec2-3-138-100-101 ec2-user]# kubectl  describe pod myapp | grep Image
Image:         busybox
Image ID:      docker-pullable://busybox@sha256:5acba83a746c7608ed544

We can see that the pod is created with the busybox image. Now create another debugging pod for the above one but with ubuntu image as below,

[root@ec2-3-138-100-101 ec2-user]# kubectl debug myapp --copy-to=myapp-debug --set-image=*=ubuntu

We can check the debugging image as below,
[root@ec2-3-138-100-101 ec2-user]# kubectl describe pod myapp-debug | grep Image
Image:         ubuntu
Image ID:      docker-pullable://ubuntu@sha256:b5a61709a9a44284d882342

We can see that we can create another pod with our application pod but with different image so that we can troubleshoot the code

No comments :

Post a Comment