Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PortForwardService to use Kubernetes Client Port Forwarding instead of kubectl binary #181

Closed
rohanKanojia opened this issue May 7, 2020 · 1 comment · Fixed by #533

Comments

@rohanKanojia
Copy link
Member

Right now PortForwardService which is used in k8s:debug goal is just executing command kubectl port-forward port.. . This works but won't work when kubectl or oc binary is not available on system.

https://github.com/eclipse/jkube/blob/9e3d67371e8c12bc8aa6288acacc83d1f796ea96/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/PortForwardService.java#L227-L240

We should refactor it to use Fabric8 Kubernetes Client instead. Here is an example, PortForwardExample:

client.pods().inNamespace("default").withName("testpod").portForward(containerPort, 8080);
@manusa manusa added the enhancement New feature or request label May 7, 2020
@manusa manusa added this to the 1.1.0 milestone May 7, 2020
@manusa manusa added this to "Backlog" in Sprint #184 May 11, 2020
@manusa manusa moved this from "Backlog" to Planned in Sprint #184 May 13, 2020
@manusa manusa added this to "Backlog" in Sprint #185 Jun 1, 2020
@manusa manusa added this to Backlog in Sprint #186 Jun 22, 2020
@manusa manusa removed this from "Backlog" in Sprint #185 Jun 22, 2020
@manusa manusa added this to Backlog in Sprint #192 Oct 27, 2020
@manusa manusa moved this from Backlog to Planned in Sprint #192 Oct 28, 2020
@manusa manusa added this to Planned in Sprint #193 Nov 18, 2020
@rohanKanojia rohanKanojia moved this from Planned to In progress in Sprint #193 Nov 27, 2020
@rohanKanojia rohanKanojia self-assigned this Nov 27, 2020
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 27, 2020
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 27, 2020
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 30, 2020
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 30, 2020
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 30, 2020
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 30, 2020
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@rohanKanojia rohanKanojia moved this from In progress to Review in Sprint #193 Dec 1, 2020
@manusa
Copy link
Member

manusa commented Dec 4, 2020

Following are conclusions of the sync review:

  • Methods in services should be private by default.
  • addPorts function should have no side-effects
  • PortForward + DebugService should be considered with an API vision and not just a MojoExecution. SIGTERM as the mechanism to stop the forward should only be considered only at the Mojo level.
  • Locking mechanism is incomplete, should be refactored (see next section)

High level view of PortForward/Debug mode:

Conditions for port forward to work:

  • Application is deployed (There is a Deployment/DeploymentConfig/*Controller) in the Cluster
  • Deployment has been modified to enable the environment JAVA_ENABLE_DEBUG=true variable (JAVA_DEBUG_SUSPEND=false)
  • A new Pod has been scheduled for the updated deployment
  • The Pod is ready and running

Before port forwarding

  • If debug is invoked with no existent deployment, a message should warn the user, port forwarding shouldn't start
  • If any of the other conditions is not matched before starting the forwarding, but deployment exists, we should take care of everything (showing messages to user) and fix it. Once all conditions are green, port forwarding should start.
  • Thread execution should be locked with a monitor that guarantees port forwarding conditions are met

During port forwarding

  • If any condition reverts/breaks (Pod/Container dies, Deployment is changed/removes, etc.) PortForwarding should stop and user should be informed.

@manusa manusa moved this from Review to In progress in Sprint #193 Dec 4, 2020
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Dec 7, 2020
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa added this to Review in Sprint #194 + #195 Dec 9, 2020
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Jan 4, 2021
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa moved this from Review to In progress in Sprint #194 + #195 Jan 8, 2021
@manusa manusa self-assigned this Jan 8, 2021
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Jan 11, 2021
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit to manusa/jkube that referenced this issue Jan 11, 2021
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit to manusa/jkube that referenced this issue Jan 12, 2021
…Client Port Forwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa moved this from In progress to Review in Sprint #194 + #195 Jan 12, 2021
Sprint #194 + #195 automation moved this from Review to Done Jan 13, 2021
manusa pushed a commit that referenced this issue Jan 13, 2021
…orwarding instead of kubectl binary

+ Moved code from DebugMojo to DebugService
+ Refactored PortForwardService to use KubernetesClient's portForward
  instead of `kubectl`/`oc`

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment