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 interactive builder in kubectl plugin #982

Merged
merged 5 commits into from
Feb 17, 2023

Conversation

mszostok
Copy link
Contributor

@mszostok mszostok commented Feb 15, 2023

Description

The builder is based on the existing code base but with adjustments like:

  • removed kubectl merger
  • added additional checks
  • adjusted approach for namespace dropdown
  • removed executor bindings (we don't have this info in plugin)
  • small bug fixes
  • etc.

If you have IntelliJ, just select

  • kubectl_test.go and kubectl_cmd_builder_test.go files and click "Compare Files" (cmd+d)
  • kubectl.go and kubectl_cmd_builder.go files and click "Compare Files" (cmd+d)

Changes proposed in this pull request:

Testing

  1. Build plugins: make build-plugins-single
  2. Start plugin server: env PLUGIN_SERVER_HOST=http://host.k3d.internal go run test/helpers/plugin_server.go
  3. Create cluster: k3d cluster create labs --image=rancher/k3s:v1.25.0-k3s1
  4. Export kubeconfig env: export KUBECONFIG=/Users/$USER/.kube/config # set custom path if necessary
  5. Update your configuration to enable botkube/kubectl plugin:
    plugins:
      repositories:
        botkube:
          url: http://host.k3d.internal:3000/botkube.yaml
    executors:
      plugin-based:
        botkube/kubectl:
          enabled: true
          config:
            defaultNamespace: "default"
            log:
              level: "debug"
            interactiveBuilder:
              allowed:
                namespaces:
                  - default
                  - bar
                verbs: ["api-resources", "explain", "get", "logs", "top", "exec", "apply"]
                resources: [ "deployments", "pods", "namespaces", ]
  6. Try to remove/change the interactiveBuilder config.
  7. Create a kubeconfig with lower perms, e.g. follow this guide: https://devopscube.com/kubernetes-kubeconfig-file/. Then export Kubeconfig export KUBECONFIG=/tmp/devops-cluster-admin-config and restart botkube.
Screen.Recording.2023-02-15.at.12.42.26.mov

Related issue(s)

@mszostok mszostok added the enhancement New feature or request label Feb 15, 2023
@mszostok mszostok marked this pull request as ready for review February 15, 2023 11:46
@mszostok mszostok requested review from a team and PrasadG193 as code owners February 15, 2023 11:46
@pkosiec pkosiec self-assigned this Feb 16, 2023
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.

Looks very good! Awesome work 🥳
Just a few comments with open questions / small improvement requests.
Also see the review for the docs: kubeshop/botkube-docs#213

helm/botkube/values.yaml Outdated Show resolved Hide resolved
pkg/api/executor/grpc_adapter.go Outdated Show resolved Hide resolved
internal/executor/kubectl/review/review.go Outdated Show resolved Hide resolved
internal/executor/kubectl/review/review.go Outdated Show resolved Hide resolved
internal/executor/kubectl/executor.go Outdated Show resolved Hide resolved
internal/executor/kubectl/builder/strings.go Outdated Show resolved Hide resolved
internal/executor/kubectl/builder/strings.go Show resolved Hide resolved
internal/executor/kubectl/executor.go Show resolved Hide resolved
internal/executor/kubectl/builder/config.go Outdated Show resolved Hide resolved
@mszostok mszostok force-pushed the kubectl-plugin/interactive-builder branch 3 times, most recently from e3de9bc to 71be7c2 Compare February 17, 2023 10:45
@mszostok mszostok force-pushed the kubectl-plugin/interactive-builder branch from 71be7c2 to cd80788 Compare February 17, 2023 11:04
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.

LGTM 🚀
(Disclaimer: didn't test it after resolving review commens, but the changes weren't invasive so 🤞 Let me know if I should double check it still works 😄)

@mszostok mszostok merged commit 0e23f5b into kubeshop:main Feb 17, 2023
@mszostok mszostok deleted the kubectl-plugin/interactive-builder branch February 17, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants