botkube
botkube copied to clipboard
External `kubectl` executor
Overview
Currently, the kubectl executors is built-in. After https://github.com/kubeshop/botkube/issues/650 we need to create an external kubectl plugin.
Lessons learned
Based on the current implementation, we can see such problems:
-
User facing problems:
- Always need to put all flags at the end of the command
- For example the default example from
kubectl wait -hdoesn't work in BotKubewait --for=condition=Ready pod/foo
- For example the default example from
- Only one version of
kubectlis supported - When a valid
kubectlverb is specified, we gotcommand not supported. It would be nice to get more verbose information. For example:the server doesn't have a resource type "certs"you are not authorized to work with "pods"unknown command "ges" for "kubectl"Did you mean this? set get
- If all
kubectlexecutors are disabled, you always getcommand nod supportedinstead of sth likethe kubectl is not configured to work in this channel - minor: needs to learn a new syntax for
commandsandnamespaces.
- Always need to put all flags at the end of the command
-
Developer facing problems:
- It's hard to ensure a proper security
- We need to do the job of API Sever on our end, which is error-prone
- Recently for
-Awe returned all resources even if not authorized.
- Recently for
- We need to do the job of API Sever on our end, which is error-prone
- We need to reimplement the
kubectlparsing command- it's problematic and hard to follow the latest releases
- we had an issue with slash syntax:
get po/podname-123 - we still have an issue when flags are specified before the resource name
- It's hard to ensure a proper security
Ideas
-
[breaking change] Explicitly say the
@Botkube kubectl get poinstead of@Botkube get po- It's more typing, but we can support aliases, e.g. for
kubectl->kc->ketc.
- It's more typing, but we can support aliases, e.g. for
-
Security:
- It would be good to utilize a general approach https://github.com/kubeshop/botkube/issues/675
- If not possible, then, based on the
commands.verbsandcommands.resourcecreate a dedicated:- Role in all
namespaces.include(take care ofnamespaces.exclude) - ClusterRole if
namespace.include: ["*"]and emptynamespace.exclude
- Role in all
- [breaking change] Or simply use the native K8s
rbacwhere the user can attach a given SA to a givenkubectlexecutor. Instead of defining all thisverbsandcommands.
-
Execute
kubectlcommand with a user instead of doing the validation logic in BotKube.