Tuesday 11 June 2024

Jump Into a Container Deployed in AKS (kubernetes)

 We may sometimes want to jump into a container deployed in kubernetes pod to investigate the conntents of a container, such as files in it or even we may want to run commands and see how they work inside a deployed container. For that purpose we need to jump into the container and obtian the command shell in that container. Let's look at how we can jump into both Linux and Windows containers.

To jump to Linux container in AKS(Kubernetes) use below command syntax

kubectl exec -it <yourpodname> -n <k8snamespace> --container <containername> -- sh


For Windows container use below command.

kubectl exec -it <yourpodname> -n <k8snamespace> --container <containername> -- powershell


 

The command without -- before the shell specification gives you deprecated warning below. Therefore, use the above mentioned syntax for kubectl exec command.

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.

Deprecated command syntax

For Linux

kubectl exec -it <yourpodname> -n <k8snamespace> --container <containername> sh


For Windows.

kubectl exec -it <yourpodname> -n <k8snamespace> --container <containername> powershell




No comments:

Popular Posts