databricks / click

The "Command Line Interactive Controller for Kubernetes"
Apache License 2.0
1.49k stars 84 forks source link

Add one-off command #65

Open peterfication opened 6 years ago

peterfication commented 6 years ago

This command takes the image of the container of the current pod and runs the specified command in a one-off kubectl run command.

If the pod has multiple containers and none is specified, it will fail asking for the specific container.

peterfication commented 6 years ago

I might have done some things wrong, so I'm really happy to receive feedback on this!

peterfication commented 6 years ago

Implements https://github.com/databricks/click/issues/64 /cc @nicklan

peterfication commented 6 years ago

Would be useful to have the env variables of the specified pod set as well.

peterfication commented 6 years ago

The challenge with the env variables is, that there might be some variables from secrets and kubectl run does not support this, see https://github.com/kubernetes/kubernetes/pull/48684. But there is a work around described here: https://github.com/kubernetes/kubernetes/pull/48684#issuecomment-342546951

nicklan commented 6 years ago

This looks great! I'm just gonna test it out and then will leave comments and/or merge

peterfication commented 6 years ago

@nicklan thanks for pointing that out. I added a method to sanitise the pod name.

peterfication commented 5 years ago

I realised that the current implementation only allows one run command of the same image at the same time. A random sequence could be added to the K8s name so it does not fail for more run commands for the same pod/image at the same time.