luksa / kubectl-plugins

My own plugins for kubectl
336 stars 75 forks source link

Send complex command #10

Open evlahos opened 10 months ago

evlahos commented 10 months ago

Hi, very nice work, but I have an issue sending command e.g. ls -l:

"...... node ls -l Error: must specify one of -f and -k

error: unknown command "ls -" See 'kubectl create -h' for help and examples"

Any idea? BR Vaggelis

luksa commented 10 months ago

You probably need to add a -- in front of the command, just like with kubectl exec and others. Not sure which plugin you're invoking, but the command should be:

kubectl someplugin -- some-command --with-options
evlahos commented 10 months ago

Hi Luksa I'm trying the ssh plugin and I want to send "ls -l" When I send only "ls": e.g. ...ssh node nodeName ls, it works as expected. but for "ls -l" I have the above error: e.g. ...ssh node nodeName ls -l I have also tried: 1. .....ssh node worker-pool1-99xlmfat-n200-vpod1-dsc8989-ipv4 --ls Warning: would violate PodSecurity "restricted:latest": host namespaces (hostNetwork=true, hostPID=true, hostIPC=true), privileged (container "ssh-node" must not set securityContext.privileged=true), allowPrivilegeEscalation != false (container "ssh-node" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "ssh-node" must set securityContext.capabilities.drop=["ALL"]), restricted volume types (volume "host" uses restricted volume type "hostPath"), runAsNonRoot != true (pod or container "ssh-node" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "ssh-node" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost") Created pod/ssh-node-7cxf8 Waiting for container to start... error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "a712e90eb12b64a3d8f1e6bcbde0a3dfa57347c26230212dc147060b2978c934": OCI runtime exec failed: exec failed: unable to start container process: exec: "--ls": executable file not found in $PATH: unknown pod "ssh-node-7cxf8" deleted

2. ....ssh node worker-pool1-99xlmfat-n200-vpod1-dsc8989-ipv4 -- ls Error: must specify one of -f and -k

error: unknown command "ls -f -" See 'kubectl create -h' for help and examples

BR Vaggelis

yalginayyaltirik commented 6 months ago

Did the bug fixed? I want to execute the following but it does not work

kubectl ssh node gke-cluster-1-default-pool-5a105e18-9wlf && sudo iptables -t nat -I PREROUTING 1 -s 10.68.1.22 -d 10.3.5.227 -j DNAT --to-destination 10.124.1.25 && sudo iptables -t nat -I POSTROUTING 1 -s 10.68.1.22 -d 10.68.1.24 -j MASQUERADE

Desired update is not performed, but if I execute it into the machine it works.

rootxrishabh commented 3 months ago

@luksa great work on the plugin!

Facing a similar kind of issue here - rootxrishabh@Rishabhs-MacBook-Air ~ % k ssh node ip-10-1-103-85.us-west-2.compute.internal "cat /etc/containerd/config.toml" Created pod/ssh-node-554xm Waiting for container to start... error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "b6086be96f40deb859bf99a4784f5fe896b577a8837114b1f31178ffef637402": OCI runtime exec failed: exec failed: unable to start container process: exec: "cat /etc/containerd/config.toml": stat cat /etc/containerd/config.toml: no such file or directory: unknown pod "ssh-node-554xm" deleted

msela9 commented 1 week ago

Suggested fix: https://github.com/luksa/kubectl-plugins/pull/12