k9s icon indicating copy to clipboard operation
k9s copied to clipboard

Introduce Resource creation and duplication functionality

Open NickyMateev opened this issue 3 years ago • 9 comments

Introduce Resource creation and duplication functionality

I love k9s but one thing which always bugged me was having to create new resources - it usually meant that I had to:

  1. Open a new terminal window and ditch k9s
  2. Create a new temporary YAML file somewhere to paste the resource yaml content
  3. kubectl apply -f temp.yaml
  4. Remove temp.yaml as it's no longer needed (or actually forget to delete it, which happens often which leads to junk/unused files on my file system)
  5. Go back to k9s

This is way too much of a hassle and at best it slows down an operator's workflow and at worst it may break his focus while working intensely on some issue as the operator now has to do all this miscellaneous stuff when all he wanted to do was to apply a new Kubernetes resource.

Proposal

This PR propose the addition of two new keybindings:

  • Add New keybinding (n key) to allow new resource creation while viewing pods, deployments, services etc... This opens a blank text editor where you can paste the yaml content of a Kubernetes resource (or multiple resources separated by ---) and upon closing the text editor the content will be applied to your Kubernetes cluster.
  • Add Duplicate keybinding (d key) in the YAML view to allow creation of new Kubernetes resources by using the current resource as a starting point. This again opens your text editor but this time it pre-populates it with the yaml content of the resource you were just viewing. This allows you to create similar resources by simply using the current one as your base and changing it as you wish. For example - you may be looking at a Kubernetes service of which you may want to create a copy of but maybe change up the ports, you would simply open up the YAML view for the specific service and press the Duplicate keybinding (d key), an editor would open and you would only need to change up the resource name (so it's unique) and the ports you as you like them to change.

The above two actions are things I often need to do and I'm sure other operators also have faced similar issues of having to switch contexts between k9s and another terminal window just to do them.

Related issues

There seem to be an previous (closed) issues which inquire about functionality about easily creating new resources: https://github.com/derailed/k9s/issues/191 and https://github.com/derailed/k9s/issues/496

Closing thoughts

To me k9s is an awesome tool which saves a ton of time when operating Kubernetes clusters. The only missing peace for me was creation of new resources with ease and quickness. I believe this PR proposed a solution to this missing peace which would make k9s a complete package for anyone who wishes to operate Kubernetes clusters with maximum efficiency.

newBtn duplicateBtn editMode

NickyMateev avatar Nov 21 '20 02:11 NickyMateev