Over the past 12-18 months I’ve been working to transition my development environment from my local machine (a Macbook) to a remote environment. I’ll be writing more about my reasons and the environment in the future, but for the purpose of this post I’ll provide a quick overview here.
My current development enviroment consists of a remote (e.g. not on my Macbook) Kubernetes cluster configured via Rancher. I use Visual Studio Code running in the cluster via the code-server project. Most of the applications I work on are service oriented (each project consists multiple docker containers) and this setup allows me to easily develop within those containers. However, because I am using Kubernetes and Rancher in a development environment there are some things we’d want that aren’t needed in a production environment and so aren’t available out of the box.
Both Kubernetes and Rancher provide a command line tool, kubectl and the rancher CLI respectively. The Rancher CLI provides the ability to securely connect to your K8S cluster and to run commands using the remote kubectl
(e.g. rancher kubectl ...
). Both of these tools are designed for administering a production cluster and so don’t provide the ideal developer ergonomics out if the box for non-production use. For example to connect to a running pod in your cluster you need to specify both the namespace it is running in (easy enough) as well as the name of the pod (less immediately knowable - pod name take the form of ‘pod-name-66d4b9b57-z5v6r’, and they change with each deploy, so you must use kubectl to get the names of the running pods).
Ranch Hand fills this gap. In a development environment (or even very small cluster) you will generally only have one of each pod running for each service and would like to connect to or run commands in that pod quickly. The project documentation goes into more detail, but let’s look at a quick example.
Without Ranch Hand:
Obviously this is a lot to type repeatedly throughout the day and often the command can not be re-run again the next day or later in that day (makeing use your command history for example) as you may have deployed an updated pod (causeing a name change).
With Ranch Hand:
Ranch Hand will also allow you to store commands for re-use later and prompt you for any required parameters that haven’t been set as project defaults.
You can check it out here, https://github.com/peregrinator/ranch-hand.