mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-07-12 07:41:42 +00:00
Port forward to the named service ports.
When adding a service via the wizard, resolve the service's targetPort to the actual pod container port instead of using the service port directly. Problem: Service port 80 → Pod port 8000, but kportal was trying to forward to port 80 on the pod. Solution: Look up the pod's actual containerPort when the service uses a named targetPort (like http), and use that for port-forwarding.
This commit is contained in:
@@ -468,7 +468,14 @@ func (m model) handleAddWizardEnter() (tea.Model, tea.Cmd) {
|
||||
wizard.clearTextInput()
|
||||
} else if wizard.cursor >= 0 && wizard.cursor < len(wizard.detectedPorts) {
|
||||
// Selected a detected port
|
||||
wizard.remotePort = int(wizard.detectedPorts[wizard.cursor].Port)
|
||||
// For services, use TargetPort (actual pod port) if available
|
||||
// For pods, TargetPort is 0, so use Port (container port)
|
||||
selectedPort := wizard.detectedPorts[wizard.cursor]
|
||||
if selectedPort.TargetPort > 0 {
|
||||
wizard.remotePort = int(selectedPort.TargetPort)
|
||||
} else {
|
||||
wizard.remotePort = int(selectedPort.Port)
|
||||
}
|
||||
wizard.step = StepEnterLocalPort
|
||||
wizard.clearTextInput()
|
||||
wizard.inputMode = InputModeText
|
||||
|
||||
Reference in New Issue
Block a user