All Projects → snebel29 → kwatchman

snebel29 / kwatchman

Licence: MIT license
Watch for k8s resources changes and trigger chains of handlers

Programming Languages

go
31211 projects - #10 most used programming language
python
139335 projects - #7 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to kwatchman

Cabal Desktop
Desktop client for Cabal, the p2p/decentralized/local-first chat platform.
Stars: ✭ 632 (+2533.33%)
Mutual labels:  slack, instant-messaging
electronim
Electron based multi IM (Instant Messaging) client
Stars: ✭ 50 (+108.33%)
Mutual labels:  slack, instant-messaging
slack neuralyzer
Ruby gem for clean up messages and files on Slack.
Stars: ✭ 58 (+141.67%)
Mutual labels:  slack
Yasuf
Very simple way of controlling your Python application via Slack
Stars: ✭ 23 (-4.17%)
Mutual labels:  slack
cheat-sheet-pdf
📜 A Cheat-Sheet Collection from the WWW
Stars: ✭ 728 (+2933.33%)
Mutual labels:  slack
djangobot
Bridge between Slack and Django, via Channels
Stars: ✭ 66 (+175%)
Mutual labels:  slack
gmg
Green Mountain Grills web app.
Stars: ✭ 54 (+125%)
Mutual labels:  slack
github-issues-notice
Notify labeled issues to Slack
Stars: ✭ 20 (-16.67%)
Mutual labels:  slack
emojibot
Emojibot is a Slack bot that announces new custom emoji to a specific channel.
Stars: ✭ 17 (-29.17%)
Mutual labels:  slack
mandarin-android
🍊 Android mobile IM client
Stars: ✭ 26 (+8.33%)
Mutual labels:  instant-messaging
enhanced-slack
🌴 PoC Slack enhancer/injector
Stars: ✭ 48 (+100%)
Mutual labels:  slack
Stevenson
Stevenson is a Vapor framework designed to build integrations between Slack apps, GitHub, JIRA and CI services (CircleCI).
Stars: ✭ 57 (+137.5%)
Mutual labels:  slack
vscode-chat
Chat with your team while you collaborate over code using VS Live Share
Stars: ✭ 496 (+1966.67%)
Mutual labels:  slack
slack-web-api
Simple, convenient, and configurable HTTP client for making requests to Slack’s Web API. Deno port of @slack/web-api
Stars: ✭ 16 (-33.33%)
Mutual labels:  slack
slack-ascii
ASCII Emoticons for Slack!
Stars: ✭ 15 (-37.5%)
Mutual labels:  slack
notify
推送通知 sdk(Bark、Chanify、钉钉群机器人、Discord、邮件、飞书群机器人、Gitter、Google Chat、iGot、Logger、Mattermost、Now Push、PushBack、Push、PushDeer、PushPlus、QQ 频道机器人、Rocket Chat、Server 酱、Showdoc Push、Slack、Telegram、Webhook、企业微信群机器人、息知、Zulip)。
Stars: ✭ 335 (+1295.83%)
Mutual labels:  slack
captcha-generator
An NPM package to generate captcha images that can be used in Discord bots or various other projects
Stars: ✭ 45 (+87.5%)
Mutual labels:  slack
slackdeletron
[DEPRECATED] - V3.0 of Slack Deletron
Stars: ✭ 35 (+45.83%)
Mutual labels:  slack
react-slack-rtm
Demo Slack RTM chat built with ReactJS and Django
Stars: ✭ 17 (-29.17%)
Mutual labels:  slack
st2chatops
Packaging environment for building StackStorm chatops native packages
Stars: ✭ 26 (+8.33%)
Mutual labels:  slack

Kwatchman

CircleCI codecov License Stable

kwatchman is a tool to watch for k8s resources changes and trigger handlers, find additional information in this blog post

  • kwatchman leverages kubernetes watch and list endpoints to then pipe Add, Update and Delete events through a chain of built-in handlers
  • kwatchman remove event noise when configuring its diff handler, by filtering events that have no user changes on its manifest.
  • kwatchman provide manifest and free "payload" field to implement any handler, to do things like
    • Log events to stdout to enrich logging platform data for troubleshooting
    • Notify events to IM services such as Slack
    • Etc.

Demo

Take a look on how would look like the combination of handlers: diff -> log -> slack, whenever there is a manifest change into the cluster kwatchman will compute the difference, will print the event into the standard output to finish by sending a notification to slack.

Installation

kwatchman can work both internally and externally to the cluster, to work externally all you need as a valid kubeconfig file that kwatchman can leverage to connect although this is handy for development for production use cases you better deploy it within the cluster itself.

To install kwatchman in the cluster, you can use its helm chart

For installing tiller < 3.X using RBAC you have to create a serviceaccount to run tiller with, like here

  1. Install helm
  2. Install the chart

TL; DR

$ helm repo add snl-charts https://snebel29.github.io/snl-charts
$ helm install --name kwatchman --namespace=kwatchman snl-charts/kwatchman

Customize default value.yaml configuration, add/remove k8s resources, add your handler configuration, such as slack webhook and pass the file using --values flag to deploy your configuration along kwatchman.

$ helm install --name kwatchman --namespace=kwatchman --values=values.yaml snl-charts/kwatchman

Filtering

  • Filter resources by namespace and k8s labels, see configuration
  • Filter events, specific fields, etc. by vuilding your own handler, use ignoreEvents handler as a reference.

Configuration

kwatchman requires a configuration file in order to work, it uses viper under the hood to read the file therefore you can use any of its accepted formats such as (JSON, YAML, TOML, etc.)

The structure is pretty simple, a toml example is provided:

[[resource]]
kind = "deployment"

[[resource]]
kind = "service"

[[resource]]
kind = "statefulset"

[[resource]]
kind = "daemonset"

[[resource]]
kind = "ingress"

[[handler]]
name = "diff"

[[handler]]
name = "log"

[[handler]]
name = "ignoreEvents"
events = ["Add", "Delete"]

[[handler]]
name        = "slack"
clusterName = "myClusterName"
webhookURL  = "https://slack-webhook-url"

Resources

Define the list of kubernetes resources to watch, not all resources are available to watch although the intention is to continuosly keep adding them.

ℹ️ You can create an issue or contribute yourself to get more resources added!

⚠️ Resources should handle apiGroup deprecation and removal transparently for the user when using last stable kwatchman versions

Handlers

Handlers is what makes kwatchman powerfull and will be trigger in the specific order they are configured.

A handler takes as input all the related event information (kind of action, k8s manifest, payload, etc.) and execute some code using it, they also decide whether the next handler should run or not, and can pass new extra information through its payload []byte field.

Handlers can be created for notifiying to instant message services such as Slack or to simply log the events into your logging system, currently only a hand of handlers are available but there is plans to allow building your own through plugins and generic hanlders such as webhooks and local executor.

The diff handler

Diff handler clean manifest metadata and perform a diff comparison, the next handler is called only if a difference has been reported, it's typically the first handler to be trigger since this remove noise from events produced by status changes.

The log handler

This can be used for testing and for recording events at any point in the chain, enriching your logging platform with high level events from kubernetes that could be leveraged for root cause analysis either by humans or machines by (AIOps)

The ignoreEvents handler

Self explanatory, the events in the list will cause the chain to be stopped. There is Add, Update and Delete events only.

The Slack handler

The slack handler notifies of an event using the payload of the handler as text, combined with the diff handler report changes into your manifests.

Have you ever being bitten in production by a change that a colleague never communicated? running this handler after the diff handler you will get notifications into your slack channel about any change in your cluster.

In order to post messages with kwatchman to slack in a channel you have to

  1. Create an slack application, you can call it kwatchman
  2. Create an Incoming Webhook, the url will be use to configure kwatchman later on

Both steps are pretty much the same as if you follow slack's hello world tutorial

Compatibility matrix

Kwatchman uses go-client and a forked version of kooper and it's therefore constrained to their version compatibility, new released may be required in order to fully work with future k8s versions, please check the compatibility matrix which is provided, any reported issue will be fixed in a best effor basis.

kwatchman version k8s version
v1.0.0 +1.11

Similar projects

Development

See DEVELOPMENT.md

Coming soon

  • Diff handler reporting semantic differences in a structure way
  • Resource annotations policies, to for example don't report pod replicas changes, useful if deployment is controlled by pod autoscaler, but any policycould be implemented
  • Webhook and local executor handler, to hand the execution chain to a local script or remote endpoint
  • handler plugins, implement your own handlers, install and share them "à-volonté"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].