Kubernetes & Norn Terminal

Norn gives Kubernetes work two connected surfaces. The standalone Norn Terminal now uses the PTY-backed terminal route to upgrade common kubectl commands into structured and live views while keeping normal shell access. .nornk8s files keep repeatable triage and restart runbooks beside the services they operate, ready to run from VS Code or the CLI.

Prerequisites

  • Install kubectl and make sure it is available on PATH.
  • Configure your kubeconfig and credentials before running a Norn Kubernetes command.
  • Norn uses your existing Kubernetes access. It does not install kubectl, manage authentication, or request extra permissions.

Open the Norn Terminal

Run Norn: Open Terminal from the VS Code Command Palette. You can also use Cmd+Alt+N on macOS or Ctrl+Alt+N on Windows and Linux. The command opens the PTY-backed Norn Terminal in the editor area so live cards have room beside the transcript; the old experimental PTY toggle is no longer needed.

Simple, supported kubectl commands bloom into rich views:

shell
# Structured snapshots in the transcript
kubectl get pods
kubectl get pods -A
kubectl logs orders-api-7d9f --tail 500
kubectl get events

# Live tiles beside the transcript
kubectl get pods -w
kubectl logs -f orders-api-7d9f
kubectl get events -w
kubectl rollout status deployment/orders-api

# Confirmed mutation with raw kubectl output
kubectl rollout restart deployment/orders-api

Norn only blooms simple, unpiped forms it understands confidently. Unknown flags, output formats, pipes, redirection, shell expansion, and other commands run through your configured shell. Interactive commands such as vim, top, and kubectl exec -it stay in the terminal's raw PTY surface.

Terminal Sessions and Meta-Commands

Use + Terminal to add compact session tabs without leaving the Norn Terminal. Each tab keeps its own transcript, working directory, exported environment variables, Kubernetes context and namespace, running commands, and live tiles while inactive. Rename a tab with :name, or close it with its small x.

text
:context prelive     # Switch this session's Kubernetes context
:ctx current         # Return to the current kubectl context
:ns orders           # Switch this session's namespace
:ns default          # Return to the context's kubectl default
:name API logs       # Rename the active terminal tab
:pin                 # Make the latest pod, log, or event result live
:pop                 # Open the selected live tile in another editor tab
:help                # Show terminal help

clear                 # Clear the transcript
cd ../service         # Change this session's working directory
export KUBECONFIG=... # Set a session environment variable

Live tiles can be focused, paused, refreshed, closed, or opened separately. Live logs follow the newest lines until you scroll up. Terminal IntelliSense suggests pods and deployments only from the active session scope, offers contexts and namespaces when switching scope, and browses folders and files after cd.

Terminal Settings

  • norn.terminal.focusMode defaults to true and closes the primary Side Bar and bottom Panel when the Norn Terminal opens.
  • norn.terminal.intelliSense.selectFirstSuggestion defaults to false, so Enter runs exactly what you typed until you select a suggestion with the arrow keys or pointer.
  • The experimental PTY command and setting were removed; Norn: Open Terminal now uses the PTY route directly.

Basic Runbook

runbooks/triage.nornk8s
# Choose a cluster from the VS Code context picker,
# or pass --context to the CLI.
namespace {{ordersNs}}

get pods
describe pod orders-api-7d9f
logs orders-api-7d9f --tail 500

sequence RestartOrders
    restart deployment/orders-api
end sequence

runbook sequence ClusterCheck
    get pods
    get pods -n kube-system
end sequence

Standalone command lines get their own CodeLens action. Commands inside a sequence run top-to-bottom as one block and stop on the first failure.

Supported Commands

  • get pods lists pods. Use -A or --all-namespaces for every namespace, -n or --namespace to override the file namespace, and -l or --selector to filter by label.
  • describe pod <name> inspects one pod.
  • logs <pod> --tail N reads pod logs. The initial tail defaults to 200 lines.
  • restart deployment/<name> maps to kubectl rollout restart and requires confirmation.
  • run <SequenceName> invokes another sequence from inside a sequence.

Use a file-level namespace directive for the default namespace. A command-level namespace flag takes precedence. A command-level --context takes precedence over the selected VS Code context or CLI --context.

Find a Current Pod by Label

Pod names often change after a deployment. Capture the first pod matching a label inside a sequence instead of hardcoding its generated name.

.nornk8s
sequence Triage
    var pod = get pods -l app=orders | first
    logs {{pod}} --tail 500
end sequence

Capture is sequence-only. It fails the sequence with a clear error when no pod matches the selector.

Live VS Code Views

Standalone read commands in a .nornk8s file open styled Kubernetes views instead of sending raw output to a terminal:

  • get pods opens a live pod dashboard. Unhealthy and warning pods sort above healthy and completed pods. Pause the watch to expose snapshot refresh.
  • describe pod opens pod conditions, containers, resources, and newest-first events. Pod details still open when event-list permission is unavailable.
  • logs opens live logs by default, highlights detected levels, collapses repeated lines, and keeps the latest 5,000 physical lines. Pause or resume the follow stream, filter entries, or switch to raw text.

Sequence and CLI execution keep finite raw kubectl output. If an automatically started watch, log follow, or background discovery is unavailable, Norn quietly falls back to the information it can show. Failures from commands you explicitly run remain visible.

Context, Namespace, and IntelliSense

Use the context: ... CodeLens or status bar item to select a cluster in VS Code. The selected context is independent from the active .nornenv environment, so environment variables such as {{ordersNs}} can still configure a namespace.

  • Typing logs or describe pod suggests pod names discovered from pod dashboards.
  • Typing restart deployment/ suggests discovered deployments.
  • Namespace directives and namespace flags suggest available namespaces.
  • When the file declares a namespace, pod and deployment suggestions stay scoped to it. Without one, suggestions can include known resources from other namespaces and insert the required namespace flag.

Discovery caches live under .norn-cache. Cluster-wide namespace or deployment discovery is best effort: restricted permissions do not block commands or show background errors, and you can always type a resource or namespace manually.

CLI Runbooks

runbook sequence marks an automatic CLI entry point. Plain sequence blocks are reusable helpers and run only when selected explicitly with --sequence or -s.

shell
# Run every runbook sequence in the file
norn runbooks/triage.nornk8s --context prelive

# Run a helper or runbook sequence by name
norn runbooks/triage.nornk8s -s Triage --context prelive

# Required when the selected path can restart a deployment
norn runbooks/triage.nornk8s -s RestartOrders --context prelive --yes

# Recursively run .norn tests and .nornk8s runbooks
norn tests/ --context prelive

Restart Safety and Current Limits

  • VS Code shows a modal confirmation before every deployment restart.
  • The CLI rejects restart commands unless --yes or -y is present.
  • The Norn Terminal is a rich webview rather than a full TTY. Interactive commands hand off to a normal VS Code terminal.
  • .nornk8s runbooks do not support interactive commands such as exec -it, manifest apply/delete, scaling, or resource-metrics dashboards.
  • JUnit and HTML reports are not supported for .nornk8s files.
  • JSON output is supported for a direct .nornk8s file, but not for directory runs that contain .nornk8s files.