Skip to content

Kubernetes ​

Kubernetes logo

Kloud Workspace comes ready to work with Kubernetes clusters:

  • kubectl, with the kubectl oh-my-zsh plugin enabled by default.
  • k9s, the terminal UI, preconfigured in the workspace theme.
  • kube-linter, for static checks of manifests and charts.
  • helm and kind, covered on their own pages.
  • The Kubernetes VS Code extension.
  • The current context and namespace in the terminal prompt.

See Tools Overview for the versions.

Connect to a Cluster ​

Mount your kubeconfig read-only and point KUBECONFIG at it:

sh
docker run \
  -e KUBECONFIG=/run/kubeconfig \
  -v ~/.kube/config:/run/kubeconfig:ro \
  ghcr.io/kloudkit/workspace:v0.6.2

The workspace runs as the kloud user (UID 1000), so the file must be readable by that UID. Then, in the terminal:

sh
kubectl get nodes

⚠️ WARNING

Avoid mounting the file at ~/.kube/config. Docker then creates ~/.kube owned by root, and kubectl cannot write its cache there.

The ~/.kube Directory ​

When a new container starts, the workspace creates ~/.kube with mode 700, owned by kloud, unless the directory already exists.

/home/kloud is not persistent, so anything written to ~/.kube, such as contexts you add with kubectl config, is lost when the container is recreated.

Keep Contexts Across Recreates ​

To keep a kubeconfig you edit inside the workspace, point KUBECONFIG at a file in the persisted ~/.ws volume. kubectl creates the file, with mode 600, the first time it writes:

sh
docker run \
  -e KUBECONFIG=/home/kloud/.ws/kube/config \
  -v ws:/home/kloud/.ws \
  ghcr.io/kloudkit/workspace:v0.6.2

k9s ​

Run k9s to browse the cluster in the terminal. Its configuration at ~/.config/k9s/config.yaml turns off the logo and selects the Catppuccin Frappé skin.

Lint Manifests with kube-linter ​

Check manifests before you apply them:

sh
kube-linter lint ./manifests

Prompt ​

The terminal prompt shows the current context, with the namespace in parentheses. To hide it, set:

  • WS_TERMINAL_PROMPT_HIDE_KUBERNETES_CONTEXT: Hides current Kubernetes context in the prompt.

OpenShift and Talos ​

Two features add the CLIs for those platforms:

  • oc: the OpenShift CLI.
  • talos: the Talos CLI, talosctl.
sh
# Manual installation
ws-cli feature install oc

# Or at boot time
docker run \
  -e WS_FEATURES_ADDITIONAL_FEATURES="oc talos" \
  ghcr.io/kloudkit/workspace:v0.6.2

Released under the MIT License