Kubed can run kubectl on remote hosts, letting you manage
Kubernetes clusters that are only reachable from a specific machine,
or use a kubectl installation that lives on a remote server.
This works by leveraging Emacs’s Tramp remote file access facility
(see (tramp)Top).
Essentially, Kubed respects the value of default-directory when
deciding where to run kubectl. When default-directory
refers to a local directory, Kubed invokes the local kubectl.
When default-directory refers to a remote directory (i.e., it is
a Tramp file name), Kubed instead invokes kubectl on the
corresponding remote host. This means that you can point Kubed at a
remote host simply by visiting a remote directory via Tramp—for
example, by opening a file on a remote server with C-x C-f and
Tramp file name syntax, such as /ssh:[email protected]:/home/user/.
Each remote host has its own independent set of kubectl
contexts and namespaces. Kubed keeps track of the default context and
namespace per host in the user option
kubed-default-context-and-namespace-alist
(see Context and Namespace). When Kubed list buffers are showing
resources fetched from a remote host, the buffer name includes
‘ from host’ to make it clear which host was used.
You may have kubectl installed at different paths on different
hosts, or you may want to use a wrapper script instead of the bare
kubectl executable on some hosts. Kubed consults the
connection-local value of option kubed-kubectl-program to
determine how to invoke kubectl, so you can configure the
kubectl executable per host. For example, to tell Kubed to
use /home/user/.local/bin/kubectl on ‘some.host’, add the
following to your Emacs initialization file:
(connection-local-set-profile-variables 'my-kubed-profile-for-somehost '((kubed-kubectl-program . "/home/user/.local/bin/kubectl"))) (connection-local-set-profiles '(:application kubed :machine "some.host") 'my-kubed-profile-for-somehost)