* Add configuration wizard.
5.1 KiB
Interactive Add/Remove Wizards
kportal now includes interactive wizards for adding and removing port forwards directly from the running UI!
Quick Start
Run kportal normally:
./kportal
From the main view:
- Press
nto add a new port forward - Press
dto delete existing port forwards
Add Forward Wizard (n key)
The wizard guides you through 7 steps to add a new forward:
Step 1: Select Context
Choose from available Kubernetes contexts in your kubeconfig.
Step 2: Select Namespace
Pick the namespace where your resource lives.
Step 3: Select Resource Type
Three options:
- Pod (by name prefix) - Forward to a specific pod by prefix matching
- Pod (by label selector) - Forward to pods matching labels (survives restarts)
- Service - Most stable, load-balanced option
Step 4: Enter Resource
- Pod prefix: Type a prefix like
nginx-to match pods - Label selector: Enter labels like
app=nginx,env=prod - Service: Select from a list of services
The wizard shows real-time validation and matching resources!
Step 5: Remote Port
Enter the port number on the remote resource. The wizard displays detected ports from running containers.
Step 6: Local Port
Enter the local port to bind to. The wizard checks availability in real-time.
Step 7: Confirmation
Review your configuration and optionally add an alias (friendly name). Confirm to save!
Navigation Keys
↑/↓orj/k- Navigate optionsEnter- Confirm and proceed to next stepEsc- Go back one step (or cancel on first step)Ctrl+C- Hard cancel and return to main viewBackspace- Delete characters in text fields
Remove Forward Wizard (d key)
Multi-select interface for removing forwards:
- Select forwards: Use arrow keys to navigate,
Spaceto toggle selection - Confirm removal: Press
Enterand confirm your choice
Navigation Keys
↑/↓orj/k- Navigate forwardsSpace- Toggle selection of current forwarda- Select all forwardsn- Deselect all forwardsEnter- Proceed to confirmationEsc- Cancel and return to main viewCtrl+C- Hard cancel
Auto Hot-Reload
When you save a forward via the wizard:
- The wizard writes to
.kportal.yamlatomically - The file watcher detects the change (~100ms)
- The manager reloads and starts the new forward
- The UI updates automatically
No restart needed!
Error Handling
The wizards handle errors gracefully:
- Cluster unreachable: Shows error but allows manual entry
- Port conflicts: Displays which process is using the port
- Invalid selectors: Shows validation errors in real-time
- Duplicate ports: Prevents adding forwards with conflicting ports
Tips
Pod Prefix Matching
When using pod prefix, you can type just the app name:
nginxmatchesnginx-deployment-abc123postgresmatchespostgres-statefulset-0
Label Selectors
Use standard Kubernetes label syntax:
app=nginx- Single labelapp=nginx,env=prod- Multiple labels (comma-separated)- Real-time validation shows matching pods as you type!
Aliases
Use aliases for cleaner UI display:
- Instead of:
production/default/pod/nginx-deployment-abc123:80→8080 - Shows as:
my-nginx:80→8080
Quick Selection
In list views, you can use j/k (Vim-style) or arrow keys for navigation.
Example Workflow
Adding a forward for a PostgreSQL database:
- Press
nin main view - Select context:
production(arrow keys + Enter) - Select namespace:
default(arrow keys + Enter) - Select type:
Service(arrow keys + Enter) - Select service:
postgres(arrow keys + Enter) - Enter remote port:
5432(type + Enter) - Enter local port:
5432(type + Enter) - Add alias:
prod-db(optional, type + Enter) - Confirm: Select "Add to .kportal.yaml" (Enter)
Done! The forward starts automatically within seconds.
Architecture
The wizards use:
- Config Mutator: Safe, atomic YAML writes (temp file + rename)
- K8s Discovery: Lists contexts, namespaces, pods, services
- Modal Overlays: Wizards appear centered over the main view
- Async Validation: Port checks and selector validation run in background
- Hot-Reload Integration: File watcher picks up changes automatically
Troubleshooting
Wizards not appearing?
Check that kportal can connect to your Kubernetes cluster:
kubectl cluster-info
Port check showing wrong status?
The port check happens asynchronously. Wait a moment after typing for validation.
Changes not appearing?
The file watcher triggers within 100ms. If changes aren't visible, check:
.kportal.yamlwas written correctly- No validation errors in the file
- kportal process is still running
Navigation Summary
Main View:
n- New forward wizardd- Delete forward wizardSpace- Toggle forward on/off↑↓/jk- Navigate forwardsq- Quit
Wizards:
Enter- Next step / ConfirmEsc- Previous step / CancelCtrl+C- Hard cancel↑↓/jk- NavigateSpace- Toggle (in delete wizard)