cli icon indicating copy to clipboard operation
cli copied to clipboard

Add `--kubernetes` flag to make dapr invoke cmd support kubernetes

Open imneov opened this issue 3 years ago • 28 comments

Description

Support the invoke cmd on kubernetes mode.

The process is similar:

  1. Get the Pod corresponding to the App
  2. Complete the specific communication through the SubResource("proxy") of RESTClient
  3. Direct access to App's AppPort port or access to daprd's HttpPort port

                                      +-----------------+
                                      |                 |
                     AppPort          | +-------------+ |
         +----------------------------> |    APP      | |
  +----------+                        | +-------------+ |
  | dapr cli |                        |                 |
  +----------+                        | +-------------+ |
         +----------------------------> |    Daprd    | |
                    HttpPort          | +-------------+ |
                                      |                 |
                                      |            pod  |
                                      +-----------------+

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[436] #[848]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • [x] Code compiles correctly
  • [x] Created/updated tests
  • [x] Extended the documentation

imneov avatar Dec 26 '21 03:12 imneov

Can we add test case for this?

Sorry, just saw the reply.

Thank you tanvigour for review. I wrote part of the test code. There may be problems with code style or edge cases. Please review.

Welcome to add test cases.

imneov avatar Dec 30 '21 01:12 imneov

There is a problem with using proxy to access the HttpPort, mainly because the address that daprd listens to is 127.0.0.1, and the proxy cannot access this port.

So now our project(https://github.com/tkeel-io/cli/issues/74) uses portforward for invoke. The basic process is as follows:

  1. Get the Pod corresponding to the App
  2. Build a tunnel between the local and target pod through RESTClient's SubResource("portforward")
  3. Access daprd's HttpPort port through the local tunnel port

This part of the implementation needs to modify portforward.go to implement random ports (https://github.com/dapr/cli/issues/863).

imneov avatar Dec 30 '21 02:12 imneov

@imneov Can you signoff on your commits? https://github.com/dapr/cli/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-signing-your-work

mukundansundar avatar Feb 14 '22 03:02 mukundansundar

@imneov Can you sign off all your commits ? https://github.com/dapr/cli/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-signing-your-work

mukundansundar avatar Mar 02 '22 06:03 mukundansundar

@imneov Can you fix conflicts in the PR?

mukundansundar avatar Mar 22 '22 05:03 mukundansundar

@imneov Can you fix conflicts in the PR?

Yes, I fix it.

imneov avatar Apr 06 '22 07:04 imneov

Thanks for the changes ... We will try to review this soon ...

mukundansundar avatar Apr 06 '22 15:04 mukundansundar

@imneov Can you fix the DCO check error please?

mukundansundar avatar May 05 '22 06:05 mukundansundar

@imneov Can you fix the DCO check error please?

Done!

imneov avatar May 09 '22 04:05 imneov

@imneov thanks for this PR, I would like to merge.

Please:

  1. Fix the minor linter issue that's causing the build to fail: https://github.com/dapr/cli/pull/862/files#diff-394f01f0edcfeaefbe1674ebeb954536600c800255e813c99ff5d94eba59e7a9R170
  2. Add usage instructions to README.md

yaron2 avatar Jun 01 '22 16:06 yaron2

@imneov thanks for this PR, I would like to merge.

Please:

  1. Fix the minor linter issue that's causing the build to fail: https://github.com/dapr/cli/pull/862/files#diff-394f01f0edcfeaefbe1674ebeb954536600c800255e813c99ff5d94eba59e7a9R170
  2. Add usage instructions to README.md

I was fixed the linter and try to add usage instructions.

imneov avatar Jun 02 '22 08:06 imneov

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

dapr-bot avatar Jul 16 '22 05:07 dapr-bot

@pravinpushkar Please review this PR

mukundansundar avatar Jul 20 '22 07:07 mukundansundar

@pravinpushkar Please review this PR

Looking at it now.

pravinpushkar avatar Aug 01 '22 06:08 pravinpushkar

@imneov Please fix the small lint issue. PR looks fine. We need to update this here also to be in sync - https://docs.dapr.io/reference/cli/dapr-invoke/

pravinpushkar avatar Aug 01 '22 10:08 pravinpushkar

ping @imneov

pravinpushkar avatar Aug 17 '22 05:08 pravinpushkar

@imneov Please fix the small lint issue. PR looks fine. We need to update this here also to be in sync - https://docs.dapr.io/reference/cli/dapr-invoke/

Do I need to submit a PR for docs?

imneov avatar Aug 30 '22 09:08 imneov

@imneov Please fix the small lint issue. PR looks fine. We need to update this here also to be in sync - https://docs.dapr.io/reference/cli/dapr-invoke/

@pravinpushkar Sorry I didn't find the lint error. what command do I need to run?

imneov avatar Aug 30 '22 09:08 imneov

@imneov Please fix the small lint issue. PR looks fine. We need to update this here also to be in sync - https://docs.dapr.io/reference/cli/dapr-invoke/

@pravinpushkar Sorry I didn't find the lint error. what command do I need to run?

@imneov the lint error is available in this view https://github.com/dapr/cli/pull/862/files image

(there is only one of such).

shubham1172 avatar Sep 08 '22 10:09 shubham1172

Codecov Report

Attention: Patch coverage is 69.60784% with 31 lines in your changes are missing coverage. Please review.

Project coverage is 28.60%. Comparing base (619cd9c) to head (f62550c).

:exclamation: Current head f62550c differs from pull request most recent head 5ad56cc. Consider uploading reports for the commit 5ad56cc to get more accurate results

Files Patch % Lines
pkg/kubernetes/invoke.go 69.60% 24 Missing and 7 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #862      +/-   ##
==========================================
+ Coverage   22.55%   28.60%   +6.05%     
==========================================
  Files          40       40              
  Lines        4758     4017     -741     
==========================================
+ Hits         1073     1149      +76     
+ Misses       3607     2784     -823     
- Partials       78       84       +6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 11 '22 03:09 codecov[bot]

@pravinpushkar HI~ Is there anything else I need to do?

imneov avatar Sep 27 '22 08:09 imneov

@imneov Please fix the small lint issue. PR looks fine. We need to update this here also to be in sync - https://docs.dapr.io/reference/cli/dapr-invoke/

Do I need to submit a PR for docs?

Yes, If not done already then please create a doc issue and PR and link it here. I have triggered the PR checks let's see.

pravinpushkar avatar Sep 27 '22 12:09 pravinpushkar

Support the invoke cmd on kubernetes mode.

OK , Thanks for you reply. @pravinpushkar

There is doc issue(https://github.com/dapr/docs/issues/2846) and PR(https://github.com/dapr/docs/pull/2847)

imneov avatar Sep 30 '22 02:09 imneov

@pravinpushkar Hi~ Is there any work I need to do?

imneov avatar Oct 17 '22 09:10 imneov

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

dapr-bot avatar Nov 25 '22 19:11 dapr-bot

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

dapr-bot avatar Dec 26 '22 01:12 dapr-bot

@mukundansundar - What is happening with this issue/PR?

msfussell avatar Dec 21 '23 21:12 msfussell