wongnai / kube-slack

Kubernetes Slack Monitoring
MIT License
323 stars 59 forks source link

Posting to different channels per pod with newer Slack APIs #53

Closed woodlee closed 4 years ago

woodlee commented 5 years ago

We'd like to be able to use annotations such as the existing kube-slack/slack-channel one to control which Slack channel events for particular pods post to. However, if my understanding is correct, Slack's current (and recently changed, I think?) recommended path to set up webhooks now restricts things such that a given webhook is only allowed to post to a single channel. Reading from https://api.slack.com/custom-integrations/incoming-webhooks:

The majority of your legacy code for sending messages using incoming Webhooks should continue to work within a Slack app without much modification; the only thing you can no longer do is customize the destination channel and author identity at runtime.

So, I think I can't do what I want using this code as it is, because AFAICT the webhook URL is only globally specifiable and not configurable via a pod-level annotation. Is that correct? I'm happy to consider providing a patch to fix this but just want to ensure my understanding is correct first. Thanks for providing this library!

whs commented 5 years ago

I haven't been following Slack's recent API changes as well. Thanks for informing us.

From what I see in the incoming webhook docs

You can't use Incoming Webhooks with Workspace Apps right now; those apps can request single channel write access and then use chat.postMessage in the Web API to post messages, providing very similar functionality to Incoming Webhooks.

I suppose incoming webhook will no longer works. I think here's what need to be done to move to web API

woodlee commented 4 years ago

This appears to be working since I upgraded (was on 3.1.1 when I opened the issue).