The system architecture of
kubed-sh looks as follows:
In a nutshell,
kubectl to launch and control binaries and scripts for you. It is multi-cluster and context aware and supports some local commands (such as
cat) as well as a number of cluster commands, for example
Learn more about:
In this document we’re using terms as follows:
<name,cluster,authinfo,namespace>that defines the execution target.
kubed-shconcept describing the current set of resources you’re operating on; it is part of a context. Note that environment is an extension of the (*nix local shell) concept of an environment into a set of clusters, located in exactly one Kubernetes namespace. For example, an environment has a list of environment variables and can be used for fine-grained execution control (scripting, project isolation).
kubed-sh you can always tell the execution target by looking at the prompt. The general format of the prompt is as follows:
Above means you’re currently in the
example.com environment, using the
minikube context with the
Here are the rules:
[context::namespace]. This is the default at startup.
$ENV) is a FQDN and you launch a long-running (background) process called
theappthen the resulting underlying service will be exposed to the outside world at
kubed-sh follows two simple rules that mimic the behaviour you’re used to from a local shell:
&, this causes the creation of a deployment and a service (name equals the name of the binary or script); this is good for any long-running app, effectively executing in the background.
&then a pod is created; this is good for one-shot batch or interactive apps.
kubed-sh supports environment variables to define and overwrite behavior such as the images used, exposed service port, runtime features like hot-reload, etc.
First and foremost
kubed-sh depends on
kubectl for all cluster operations. That is, all remote operations in the cluster essentially cause shelling out to
kubectl. You can see what
kubed-sh executes when you execute the
debug built-in command.
To provide the shell interaction we’re using the REPL package chzyer/readline, offering autocomplete, search (
CTRL+R) and other standard operations such as
CTRL+L for clearing the screen.
kubed-sh is stateless, meaning that any kind of state—such as environment membership, phases or app components—is entirely stored in Kubernetes, using labels and annotations.