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

Add initial version for install and run binaries #1112

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

mszostok
Copy link
Contributor

@mszostok mszostok commented Jun 28, 2023

Description

Changes proposed in this pull request:

  • Add initial version for install and run binaries

Testing

  1. Create k3d cluster

  2. Start plugin server: env PLUGIN_SERVER_HOST=http://host.k3d.internal go run test/helpers/plugin_server.go

  3. Build x plugin: PLUGIN_TARGETS="x" make build-plugins

  4. Install Botkube with such example config:

    config yaml

    communications:
      default-group:
        socketSlack:
          enabled: true
          channels:
            default:
              name: hakuna-matata
              bindings:
                sources: [ ]
                executors:
                  - bins-management
          appToken: "xapp-"
          botToken: "xoxb-"
    
    executors:
      bins-management:
        local-repo/x:
          enabled: true
          context:
            rbac:
              group:
                type: Static
                static:
                  values: [ "system:masters" ]
          config:
            templates:
              - ref: github.com/mszostok/botkube-plugins//x-templates?ref=hackathon
    
    aliases:
      argo:
        command: x run argo
        displayName: "Argo alias"
      helm:
        command: x run helm
        displayName: "Helm alias"
            
    extraEnv:
      - name: LOG_LEVEL_EXECUTOR_LOCAL-REPO_X
        value: "debug"
    
    plugins:
      repositories:
        local-repo:
          url: http://host.k3d.internal:3000/botkube.yaml
    
    settings:
      log:
        level: "debug"
      clusterName: "labs"
      upgradeNotifier: false
    
    analytics:
      disable: true
    
    configWatcher:
      enabled: false

Example Helm

  1. Install helm CLI

    @Botkube x install https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz --file helm
    

    Screenshot 2023-07-02 at 17 22 15

  2. Run Helm list

    @Botkube x run helm list -A
    

    Screenshot 2023-07-02 at 17 22 38

Example Flux

  1. Install Flux CLI

    @Botkube x install github.com/fluxcd/flux2
    
  2. Install Flux in cluster:

    @Botkube x run flux install
    
  3. Create Source:

    @Botkube x run flux create source git webapp-latest
                   --url=https://github.com/stefanprodan/podinfo
                   --branch=master
                   --interval=3m
    
  4. List sources:

    @Botkube x run flux get sources git
    

Related issue(s)

Follow-ups

I will add two more built-in templates:

  • for tutorial, e.g. :

    Tutorial for Helm

      - trigger:
          command: "quickstart helm"
        message:
          paginate:
            page: 5
          header: "Helm Quick Start tutorial"
          buttons:
            - name: "Global Help"
              description: "{{Botkube}} helm help"
              command: "{{Botkube}} helm help"
            - name: "Version"
              description: "{{Botkube}} helm version -h"
              command: "{{Botkube}} helm version -h"
            - name: "Version"
              description: "{{Botkube}} helm version"
              command: "{{Botkube}} helm version"
            - name: "Install help"
              description: "{{Botkube}} helm install -h"
              command: "{{Botkube}} helm install -h"
            - name: "Install by absolute URL"
              description: "{{Botkube}} helm install\n--repo https://charts.bitnami.com/bitnami psql postgresql\n--set clusterDomain='testing.local'"
              command: "{{Botkube}} helm install\n--repo https://charts.bitnami.com/bitnami psql postgresql\n--set clusterDomain='testing.local'"
            - name: "Install by chart reference:"
              description: "{{Botkube}} helm install https://charts.bitnami.com/bitnami/postgresql-12.1.0.tgz --create-namespace -n test --generate-name"
              command: "{{Botkube}} helm install https://charts.bitnami.com/bitnami/postgresql-12.1.0.tgz --create-namespace -n test --generate-name"
            - name: "List"
              description: "{{Botkube}} helm list -h"
              command: "{{Botkube}} helm list -h"
            - name: "List"
              description: "{{Botkube}} helm list -A"
              command: "{{Botkube}} helm list -A"
            - name: "List"
              description: "{{Botkube}} helm list -f 'p' -A"
              command: "{{Botkube}} helm list -f 'p' -A"
            - name: "Status"
              description: "{{Botkube}} helm status -h"
              command: "{{Botkube}} helm status -h"
            - name: "Status"
              description: "{{Botkube}} helm status psql"
              command: "{{Botkube}} helm status psql"
            - name: "Upgrade"
              description: "{{Botkube}} helm upgrade -h"
              command: "{{Botkube}} helm upgrade -h"
            - name: "Upgrade"
              description: "{{Botkube}} helm upgrade --repo https://charts.bitnami.com/bitnami psql postgresql --set clusterDomain='cluster.local'"
              command: "{{Botkube}} helm upgrade --repo https://charts.bitnami.com/bitnami psql postgresql --set clusterDomain='cluster.local'"
            - name: "History"
              description: "{{Botkube}} helm history -h"
              command: "{{Botkube}} helm history -h"
            - name: "History"
              description: "{{Botkube}} helm history psql"
              command: "{{Botkube}} helm history psql"

  • for wrapping output:

    Wrapper

      - trigger:
          command: "x install github.com/fluxcd/flux2"
        type: "wrapper"
        message:
          buttons:
            - name: "Quick Start"
              command: "{{BotName}} x run quickstart flux"
              style: "primary"

Breaking changes

I describe them already in our issue: #1116 (comment)

@mszostok mszostok added the enhancement New feature or request label Jun 28, 2023
@mszostok mszostok mentioned this pull request Jul 2, 2023
4 tasks
@mszostok mszostok added the breaking Contains breaking change label Jul 2, 2023
@mszostok mszostok force-pushed the add-x-plugin branch 3 times, most recently from 13d6097 to 9334fe4 Compare July 2, 2023 16:00
@mszostok mszostok requested a review from pkosiec July 2, 2023 16:56
@mszostok mszostok marked this pull request as ready for review July 2, 2023 16:56
@mszostok mszostok requested review from a team and PrasadG193 as code owners July 2, 2023 16:56
Copy link
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! Now I'm waiting for the docs 🙂

pkg/pluginx/command.go Show resolved Hide resolved
cmd/executor/x/main.go Show resolved Hide resolved
cmd/executor/x/main.go Outdated Show resolved Hide resolved
internal/executor/x/getter/load.go Outdated Show resolved Hide resolved
internal/executor/x/output/message_parser.go Outdated Show resolved Hide resolved
internal/plugin/tmp_dir.go Outdated Show resolved Hide resolved
internal/executor/x/getter/download.go Outdated Show resolved Hide resolved
cmd/executor/x/main.go Outdated Show resolved Hide resolved
cmd/executor/x/main.go Show resolved Hide resolved
@@ -0,0 +1,223 @@
package main

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW I'd follow-up with your idea about wrapping such binaries + templates in dedicated plugins as it could be hard for someone to use flux etc. 🤔 Do we have an issue for it already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can take this and discuss inside our team 👍

@mszostok mszostok merged commit 8b17fe6 into kubeshop:main Jul 5, 2023
13 checks passed
@mszostok mszostok deleted the add-x-plugin branch July 5, 2023 10:27
@mszostok mszostok mentioned this pull request Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Contains breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants