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

Resource extensions implementation #2230

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

pPrecel
Copy link
Contributor

@pPrecel pPrecel commented Oct 24, 2024

Description

Changes proposed in this pull request:

  • fetch extensions from cluster at the end of every cli run

Related issue(s)

@kyma-bot kyma-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cla: yes Indicates the PR's author has signed the CLA. labels Oct 24, 2024
@pPrecel
Copy link
Contributor Author

pPrecel commented Oct 24, 2024

Tests results

I tested new feature in two scenarios (with/without cluster connection) and compare it to the built cli without this fueature. Keep in mind, that results are inaccurate and not deterministic, but show the trend and the scale.

Before adding features

time ./kyma-cli alpha
________________________________________________________
Executed in   27.30 millis    fish           external
   usr time   11.74 millis   40.00 micros   11.70 millis
   sys time    8.02 millis  703.00 micros    7.32 millis

NOTE: 27 millis is equal to 0.027 seconds

New cli with cluster connection

export KUBECONFIG=<PATH_TO_KUBECONFIG>
time ./kyma-cli-new alpha
________________________________________________________
Executed in  730.25 millis    fish           external
   usr time   19.16 millis    0.09 millis   19.07 millis
   sys time   27.89 millis    1.09 millis   26.80 millis

NOTE: 730 millis is equal to 0.73 seconds

New without cluster

export KUBECONFIG="" # reset to default - no cluster
time ./kyma-cli-new alpha
________________________________________________________
Executed in   24.27 millis    fish           external
   usr time   11.82 millis   37.00 micros   11.79 millis
   sys time    8.83 millis  625.00 micros    8.21 millis

NOTE: 24 millis is equal to 0.024 seconds

Data

I've tested it with self-crafted example of the extension for the Function resources:

ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    kyma-cli/extension: resource
  name: function.extension.cli
data:
  rootCommand: |
    name: function
    description: manage functions
    descriptionLong: use this command to manage function resources on a cluster
  resource: |
    scope: namespace
    kind: Function
    group: serverless.kyma-project.io
    version: v1alpha2
    singular: function
    plural: functions
  templateCommands: |
    explain:
      description: explains Kyma Functions
      descriptionLong: use this command to explain Kyma Serverless Function CR goal
      output: |-
        Kyma Serverless Module offers a Kubernetes-based platform on which you can build,
        run, and manage serverless applications in Kubernetes. These applications are called Functions,
        and they are based on the Function custom resource (CR) objects.
        They contain simple code snippets that implement specific business logic.
        For example, you can define that you want to use a Function as a proxy that saves all incoming
        event details to an external database.

        Such a Function can be:

        - Triggered by other workloads in the cluster (in-cluster events) or business events coming from
          external sources. You can subscribe to them using a Subscription CR.
        - Exposed to an external endpoint (HTTPS). With an APIRule CR, you can define who can reach the endpoint
          and what operations they can perform on it.
        
        Read more about serverless Functions here:
        https://kyma-project.io/#/serverless-manager/user/README?id=what-is-serverless

After applying this ConfigMap it should be possible to run commands like these:

go run main.go alpha # <- here we should see new command called "function"
go run main.go alpha function # <- this should run help of new function and print another new command "explain"
go run main.go alpha function explain # <- this should print text from ConfigMap from path .data.genericCommands.explain.explainText

@kyma-bot kyma-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 24, 2024
@pPrecel pPrecel force-pushed the resource-extensions-implementation branch from 3514362 to d51056f Compare October 24, 2024 09:44
@kyma-bot kyma-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 24, 2024
@pPrecel pPrecel added kind/feature Categorizes issue or PR as related to a new feature. area/cli Related to all activities around CLI labels Oct 25, 2024
@pPrecel pPrecel marked this pull request as ready for review October 25, 2024 11:19
@pPrecel pPrecel requested a review from a team as a code owner October 25, 2024 11:19
@kyma-bot kyma-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 25, 2024
@pPrecel pPrecel force-pushed the resource-extensions-implementation branch 3 times, most recently from fd23f57 to 1925d67 Compare October 26, 2024 10:38
@pPrecel pPrecel force-pushed the resource-extensions-implementation branch from 52eb33c to cd3229b Compare October 28, 2024 09:24
@anoipm anoipm self-assigned this Oct 28, 2024
@kyma-bot kyma-bot added the lgtm Looks good to me! label Oct 28, 2024
@pPrecel pPrecel merged commit 8296278 into kyma-project:main Oct 28, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Related to all activities around CLI cla: yes Indicates the PR's author has signed the CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm Looks good to me! size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants