Skip to content

Working with clusters

We use k9s to browse and kubectl to make changes. Start by inspecting a running application and finding its configuration in the cluster repository.

Browse with k9s

After selecting your cluster as described in cluster access, launch k9s:

k9s --readonly

The --readonly flag disables k9s modification commands. Kubernetes permissions still determine what you can see. See the k9s commands reference.

Key or command Action
:ctx Choose a context
:ns Choose a namespace
:pods, :deploy, :svc Browse Pods, Deployments or Services
/ Filter the current list
d Describe the selected resource, including events
l View logs for the selected Pod
Esc Return to the previous view
? Show available keys for the current view
:q Quit

Before making changes with kubectl, check the selected cluster with kubectl config current-context.

Inspect before changing

Specify the namespace before the resource so shell completion can find names within it:

kubectl get -n trackpac pods
kubectl describe -n trackpac pods <pod-name>
kubectl logs -n trackpac <pod-name> --tail=100

Use Tab completion to fill in <pod-name>, or copy it from the list.

For a restarting container, add --previous to inspect its last run. For a Pod with multiple containers, add -c <container-name>.

Find the application's directory in the repository and read its README. It tells you whether the application uses plain manifests, Helm or another deployment procedure. For a planned change to a plain manifest, review the difference first:

kubectl diff -n trackpac -f path/to/resource.yaml

diff exits with code 1 when it finds differences. It may require write permissions for its server dry run. Check any namespace in the manifest too: -n does not rewrite it.

Apply the reviewed file using the same target, following the team's review process:

kubectl apply -n trackpac -f path/to/resource.yaml
kubectl rollout status -n trackpac deployment <deployment-name>

The rollout command applies to Deployments. Follow the application's instructions for other resource types. Keep lasting changes in the repository so the next deployment preserves them.

For practical exercises, see the on-call training sessions in the trackpac cluster repository.

Recommended to reduce visual clutter. Run k9s info to find your config.yaml, then merge this setting into it:

k9s:
  ui:
    logoless: true

Keep the header visible so you can see the cluster and namespace.