kubectl is an emacs package to control kubernetes, with TRAMP integration. It is heavily inspired, and in a
way a merger, of the following previous packages:
The reason I wrote my own package is that the above approaches are unaware of each other, and I wanted the following features:
- Pervasive support for multiple
kubectlconfigurations, and namespaces - TRAMP support (for docker containers that have a valid shell when
exec'ed into) - Individual buffers for individual lists, like
direddoes (instead of recycling one buffer).
You need to have kubectl (the kubernetes command-line tool) setup with one or more configs.
Install by cloning this repository, and inserting the following into your init.el:
(add-to-list 'load-path "~/path-to-cloned-repository/kubectl")
(require 'kubectl)Run kubectl-deployments to view the kubernetes deployments on a particular config/namespace. It will ask
which config and namespace to use. From there, you can use the following key bindings:
cto switch kubernetes context (and select a new namespace in the new context)nto switch kubernetes namespace within the same contextgto re-load the deploymentsoorRETto "open" a deployment and view all pods running under itito inspect a deployment, viewing its YAML source
After pressing RET on a deployment, a list of pods and their state is shown in a new buffer. Here you have
the following key bindings:
cto switch kubernetes context (and select a new namespace in the new context), showing the same pods there.nto switch kubernetes namespace within the same context, showing the same pods there.gto re-load the pod listlto show the logs of a pod, with or without follow mode.tto open aexecterminal with a shell to the podito inspect the pod, viewing its YAML sourcedto open a TRAMPdiredbuffer for the pod, exploring its file system (and load/save files on it)qto quit the pod list and return to the deployments buffer
After pressing l on a pod, you're presented with some options. They correspond to the same options on
kubectl log. After pressing l a second time, a new buffer is opened with the pod's logs in it. Logs are
always retrieved asynchronously, and if you choose -f, the buffer will keep updating with log messages as
they arrive.
On the log buffer, the following extra key bindings are available:
kto kill thekuberctlprocess that is loading the logs (in case there's too much, or to stop a-f)qto kill the log buffer (and process)