botkube icon indicating copy to clipboard operation
botkube copied to clipboard

Error Schedule Pod if kubectl enable

Open nuvme-devops opened this issue 3 years ago • 2 comments

Description

Pod scheduling fails if kubectl is true

executors.kubectl-read-only.kubectl.enabled=true

When the value is false, the pod is in the running state.

Log Container:

- level=info msg=Closing... component="Analytics reporter"
- time="2022-09-07T22:02:30Z" level=info msg="Shutdown requested. Finishing..." component="Metrics server"
- while creating resource name normalizer: while getting resource list from K8s cluster: unable to retrieve the complete list of server APIs: custom.metrics.k8s.io/v1beta1: the server is currently unable to handle the request

Expected behavior

  • Schedule pod BotKube.

Actual behavior

  • Pod scheduling fails.

Steps to reproduce

helm install --version v0.13.0 botkube --namespace botkube --create-namespace \
--set communications.default-group.slack.enabled=true \
--set communications.default-group.slack.channels.default.name=${SLACK_CHANNEL_NAME} \
--set communications.default-group.slack.token=${SLACK_API_BOT_TOKEN} \
--set settings.clusterName=${CLUSTER_NAME} \
--set executors.kubectl-read-only.kubectl.enabled=${ALLOW_KUBECTL} \
botkube/botkube

nuvme-devops avatar Sep 07 '22 22:09 nuvme-devops

Hi @nuvme-devops

Thanks for reporting the issue and attached logs.

When you enable the kubectl executor. We fetch the supported groups and resources from API Server. It is an external call using client-go to API server. Based on the logs, it looks like it is a problem with the K8s itself:

unable to retrieve the complete list of server APIs: custom.metrics.k8s.io/v1beta1: the server is currently unable to handle the request

Here is a great answer to a similar problem provided by Brendan Burns:

For anyone who hits this, it's caused by api-services that no longer have backends running...

In my case it was KEDA, but there are a number of different services that install aggregated API servers.

To fix it:

kubectl get apiservice

Look for ones the AVAILABLE is False

If you don't need those APIs any more, delete them:

kubectl delete apiservce <service-name>

source: https://github.com/helm/helm/issues/6361#issuecomment-538220109

In the future version of BotKube we will get rid of fetching the supported groups and resources from API Server. It will be removed once the https://github.com/kubeshop/botkube/issues/685 will be implemented. For now, you need to ensure that the ServerGroupsAndResources call can be executed properly.

Thanks!

mszostok avatar Sep 08 '22 06:09 mszostok

Hi @mszostok

Thanks for your return.

I'm checking about the APISERVICE.

Interestingly, on the same cluster v0.12.4 works fine.

nuvme-devops avatar Sep 10 '22 11:09 nuvme-devops

Fixed as a part of https://github.com/kubeshop/botkube/pull/834

mszostok avatar Jan 13 '23 11:01 mszostok