Open pulkitanz opened 1 year ago
There is more documentation and an example here. Does that help you clarify how to integrate Slack?
In addition, "context deadline exceeded" usually means a time-out of some sort. Which may be due to the controller being unable to reach out to Slack.
This link is even more specific: https://fluxcd.io/flux/components/notification/providers/#slack-example
We could put an earlier additional reference to this link up here:
It might be too early to call out the reference to every Provider
type, but we are giving some favoritism to Slack as the first most prominent example.
Hi!
I did not find any issues with Slack integration. The documentation is clear enough. The only culprit was how to prepare the proper slack token and how to put it into the secret. Then everything worked for me. BTW, I am using the full address of slack hook, not the token itself. Something like this:
apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Alert
metadata:
name: slack-p0
namespace: flux-system
spec:
eventSeverity: error
eventSources:
- kind: GitRepository
name: '*'
- kind: Kustomization
name: '*'
- kind: HelmRelease
name: '*'
providerRef:
name: slack-p0
summary: "UAT cluster"
apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Provider
metadata:
name: slack-p0
namespace: flux-system
spec:
channel: sys-fluxcd-errors
secretRef:
name: slack-url-p0-uat
type: slack
kind: Secret
apiVersion: v1
metadata:
name: slack-url-p0-uat
namespace: flux-system
data:
address: >-
aHR......dndP
type: Opaque
the address looked like https://hooks.slack.com/services/XXXXXXXXXXX/XXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX
So it is obvious that two or more options how to prepare the integration with Slack exists.
I am using encrypted SOPS secret and defining the secret in this way giving me error "invalid URI for request". Here is my configuration
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: slack-bot-dev
namespace: flux-system
spec:
type: slack
secretRef:
name: webhook-url
---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: slack-bot-dev
namespace: flux-system
spec:
summary: "flux notification"
eventMetadata:
env: "dev"
cluster: "aks-cluster"
region: "West Europe"
providerRef:
name: slack-bot-dev
eventSeverity: info
eventSources:
- kind: Kustomization
name: '*'
- kind: HelmRelease
name: '*'
Sops encrypted secret
apiVersion: v1
kind: Secret
metadata:
name: webhook-url
namespace: flux-system
stringData:
address: ENC[AES256_GCM,data:VzeQbZEpTsB+ocrLE96tU+BtgtnkB894Qz5k79ffRewUYIFPgnz1c9APytr38AnO6y08qg1Gw6iZ23zwoX+eTejydvIEJRFfrlNY8LzAmd7WTysPR3kgk2qI=,tag:Q4k4q2kdORMoHqNJ4V7k8w==,type:str]
sops original secret
apiVersion: v1
kind: Secret
metadata:
name: webhook-url
namespace: flux-system
stringData:
address: "https://hooks.slack.com/services/XXXXXX/XXXXXXX/XXXXXXXXXXXXX"
@nishasati6oct Hi! Nice to meet you here. It is very pity to hear that you have the issue. Also could you please use markdown format, otherwise it is very difficult to read and understand your snippets. Thanks in advance.
@nishasati6oct Hi! Nice to meet you here. It is very pity to hear that you have the issue. Also could you please use markdown format, otherwise it is very difficult to read and understand your snippets. Thanks in advance.
Updated my comment in markdown format :) My SOPS issue is resolved now. But I have another query regarding the notification of HR. My HR's are present in their application namespace (not in flux-system). Here is my config for alert (Note: Using wildcard entry for namespace?.
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: slack-bot-dev
namespace: flux-system
spec:
summary: "flux notification"
eventMetadata:
env: "dev"
cluster: "aks-cluster"
region: "West Europe"
providerRef:
name: slack-bot-dev
eventSeverity: info
eventSources:
- kind: HelmRelease
namespace: '*-dev'
name: '*'
But in slack notification, I am not getting any HR notification. Please let me know if any changes needed here in alert configuration. Thanks for your help. :)
@nishasati6oct Hi! It looks like that you need to put the Alert
object inside of the same namespace like HR itself. I think it should help.
This doesn't work namespace: '*-dev'
we don't support wildcards for namespaces.
There's no slack integration docs when configuring alerts so it's very hard to debug when configuring slack notifications.
By docs, I mean do we have to configure webhook, what permissions does the slack-bot require and how the secret should be configured. There's little to no information here: https://fluxcd.io/flux/monitoring/alerts/#define-a-provider
I am facing this error and I have no idea what's wrong with my slack configuration:
{"level":"error","ts":"xxx","logger":"event-server","msg":"failed to send notification","eventInvolvedObject":{"kind":"Kustomization","namespace":"flux-system"}, "alert":{"name":"slack-monitoring","namespace":"flux-system"},"error":"postMessage failed: failed to execute request: context deadline exceeded"}
Any leads would help!