Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot pass option '-la' to linux 'ls' command with kubectl chroot

I have a privileged pod running in a demo k8s cluster and I can run the below command to list files on the hostnode in /var/tmp:

$ kubectl exec debug-pod-d2qpj chroot /host ls /var/tmp
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
cloud-init
samples
systemd-private-89...
systemd-private-89..

But I cannot add the option -la it just gives:

$ kubectl exec debug-pod-d2qpj chroot /host ls -la /var/tmp
Error: unknown shorthand flag: 'l' in -la
See 'kubectl exec --help' for usage.

I have tried various ways to quote the command/options but no luck so far.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any suggestions?

>Solution :

The syntax for kubectl exec uses -- to indicate the remaining flags shouldn’t be processed by kubectl:

kubectl exec debug-pod-d2qpj -- chroot /host ls -la /var/tmp
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading