Code Monkey home page Code Monkey logo

kubewatch's Introduction

This is the official Kubewatch project, originally by Bitnami, now maintained by Robusta.dev.

Feel free to open issues, raise PRs or talk with us on Slack!

kubewatch is a Kubernetes watcher that publishes notification to available collaboration hubs/notification channels. Run it in your k8s cluster, and you will get event notifications through webhooks.

See the blog post on KubeWatch 2.0 to learn more about how KubeWatch is used.

GoDoc License slack robusta

Latest image

robustadev/kubewatch:v2.8.0

Usage

$ kubewatch -h

Kubewatch: A watcher for Kubernetes

kubewatch is a Kubernetes watcher that publishes notifications
to Slack/hipchat/mattermost/flock channels. It watches the cluster
for resource changes and notifies them through webhooks.

supported webhooks:
 - slack
 - slackwebhook
 - msteams
 - hipchat
 - mattermost
 - flock
 - webhook
 - cloudevent
 - smtp

Usage:
  kubewatch [flags]
  kubewatch [command]

Available Commands:
  config      modify kubewatch configuration
  resource    manage resources to be watched
  version     print version

Flags:
  -h, --help   help for kubewatch

Use "kubewatch [command] --help" for more information about a command.

Install

Cluster Installation

Using helm:

When you have helm installed in your cluster, use the following setup:

helm repo add robusta https://robusta-charts.storage.googleapis.com && helm repo update
helm install kubewatch robusta/kubewatch --set='rbac.create=true,slack.channel=#YOUR_CHANNEL,slack.token=xoxb-YOUR_TOKEN,resourcesToWatch.pod=true,resourcesToWatch.daemonset=true'

You may also provide a values file instead:

rbac:
  create: true
  customRoles:
    - apiGroups: ["monitoring.coreos.com"]
      resources: ["prometheusrules"]
      verbs: ["get", "list", "watch"]
resourcesToWatch:
  deployment: false
  replicationcontroller: false
  replicaset: false
  daemonset: false
  services: true
  pod: true
  job: false
  node: false
  clusterrole: true
  clusterrolebinding: true
  serviceaccount: true
  persistentvolume: false
  namespace: false
  secret: false
  configmap: false
  ingress: false
  coreevent: false
  event: true
customresources:
  - group: monitoring.coreos.com
    version: v1
    resource: prometheusrules
slack:
  channel: '#YOUR_CHANNEL'
  token: 'xoxb-YOUR_TOKEN'

And use that:

$ helm upgrade --install kubewatch robusta/kubewatch --values=values-file.yml

Using kubectl:

In order to run kubewatch in a Kubernetes cluster quickly, the easiest way is for you to create a ConfigMap to hold kubewatch configuration.

An example is provided at kubewatch-configmap.yaml, do not forget to update your own slack channel and token parameters. Alternatively, you could use secrets.

Create k8s configmap:

$ kubectl create -f kubewatch-configmap.yaml

Create the Pod directly, or create your own deployment:

$ kubectl create -f kubewatch.yaml

A kubewatch container will be created along with kubectl sidecar container in order to reach the API server.

Once the Pod is running, you will start seeing Kubernetes events in your configured Slack channel. Here is a screenshot:

slack

To modify what notifications you get, update the kubewatch ConfigMap and turn on and off (true/false) resources or configure any resource of your choosing with customresources (CRDs):

resource:
  deployment: false
  replicationcontroller: false
  replicaset: false
  daemonset: false
  services: true
  pod: true
  job: false
  node: false
  clusterrole: false
  clusterrolebinding: false
  serviceaccount: false
  persistentvolume: false
  namespace: false
  secret: false
  configmap: false
  ingress: false
  coreevent: false
  event: true
customresources:
  - group: monitoring.coreos.com
    version: v1
    resource: prometheusrules

Working with RBAC

Kubernetes Engine clusters running versions 1.6 or higher introduced Role-Based Access Control (RBAC). We can create ServiceAccount for it to work with RBAC.

$ kubectl create -f kubewatch-service-account.yaml

If you do not have permission to create it, you need to become an admin first. For example, in GKE you would run:

$ kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=REPLACE_EMAIL_HERE

Edit kubewatch.yaml, and create a new field under spec with serviceAccountName: kubewatch, you can achieve this by running:

$ sed -i '/spec:/a\ \ serviceAccountName: kubewatch' kubewatch.yaml

Then just create pod as usual with:

$ kubectl create -f kubewatch.yaml

Working with CRDs

kubewatch can be configured to monitor Kubernetes Custom Resource Definitions (CRDs), allowing you to receive notifications when changes occur. To configure kubewatch to watch custom resources, you need to define the customresources section either in your values file or by using the --set flag with Helm commands.

Include the custom resource configuration in your values file:

customresources:
  - group: monitoring.coreos.com
    version: v1
    resource: prometheusrules

Then deploy or upgrade kubwatch with helm upgrade or helm install

Alternatively, you can pass this configuration directly using the --set flag:

helm install kubewatch robusta/kubewatch --set='rbac.create=true,slack.channel=#YOUR_CHANNEL,slack.token=xoxb-YOUR_TOKEN,resourcesToWatch.pod=true,resourcesToWatch.daemonset=true,customresources[0].group=monitoring.coreos.com,customresources[0].version=v1,customresources[0].resource=prometheusrules'

Custom RBAC roles

After defining custom resources, make sure that kubewatch has the necessary RBAC permissions to access the custom resources you've configured. Without the appropriate permissions, kubewatch will not be able to monitor your custom resources, and you won't receive notifications for changes.

To grant these permissions, you can define custom RBAC roles using customRoles within the rbac section of your values file or by using the --set flag with Helm commands. This allows you to specify exactly which API groups, resources, and actions kubewatch should have access to.

Here’s how you can configure the necessary permissions to monitor your resources:

rbac:
  create: true 
  customRoles:
    - apiGroups: ["monitoring.coreos.com"]
      resources: ["prometheusrules"]
      verbs: ["get", "list", "watch"]

Then deploy or upgrade kubwatch with helm upgrade or helm install

Alternatively, you can pass this configuration directly using the --set flag:

helm install kubewatch robusta/kubewatch --set='rbac.create=true,slack.channel=#YOUR_CHANNEL,slack.token=xoxb-YOUR_TOKEN,customRoles[0].apiGroups={monitoring.coreos.com},customRoles[0].resources={prometheusrules},customRoles[0].verbs={get,list,watch}'

Local Installation

Using go package installer:

# Download and install kubewatch
$ go get -u github.com/robusta-dev/kubewatch

# Configure the notification channel
$ kubewatch config add slack --channel <slack_channel> --token <slack_token>

# Add resources to be watched
$ kubewatch resource add --po --svc
INFO[0000] resource svc configured
INFO[0000] resource po configured

# start kubewatch server
$ kubewatch
INFO[0000] Starting kubewatch controller                 pkg=kubewatch-service
INFO[0000] Starting kubewatch controller                 pkg=kubewatch-pod
INFO[0000] Processing add to service: default/kubernetes  pkg=kubewatch-service
INFO[0000] Processing add to service: kube-system/tiller-deploy  pkg=kubewatch-service
INFO[0000] Processing add to pod: kube-system/tiller-deploy-69ffbf64bc-h8zxm  pkg=kubewatch-pod
INFO[0000] Kubewatch controller synced and ready         pkg=kubewatch-service
INFO[0000] Kubewatch controller synced and ready         pkg=kubewatch-pod

Using Docker:

To Run Kubewatch Container interactively, place the config file in $HOME/.kubewatch.yaml location and use the following command.

docker run --rm -it --network host -v $HOME/.kubewatch.yaml:/root/.kubewatch.yaml -v $HOME/.kube/config:/opt/bitnami/kubewatch/.kube/config --name <container-name> robustadev/kubewatch

Example:

$ docker run --rm -it --network host -v $HOME/.kubewatch.yaml:/root/.kubewatch.yaml -v $HOME/.kube/config:/opt/bitnami/kubewatch/.kube/config --name kubewatch-app robustadev/kubewatch

==> Writing config file...
INFO[0000] Starting kubewatch controller                 pkg=kubewatch-service
INFO[0000] Starting kubewatch controller                 pkg=kubewatch-pod
INFO[0000] Starting kubewatch controller                 pkg=kubewatch-deployment
INFO[0000] Starting kubewatch controller                 pkg=kubewatch-namespace
INFO[0000] Processing add to namespace: kube-node-lease  pkg=kubewatch-namespace
INFO[0000] Processing add to namespace: kube-public      pkg=kubewatch-namespace
INFO[0000] Processing add to namespace: kube-system      pkg=kubewatch-namespace
INFO[0000] Processing add to namespace: default          pkg=kubewatch-namespace
....

To Demonise Kubewatch container use

$ docker run --rm -d --network host -v $HOME/.kubewatch.yaml:/root/.kubewatch.yaml -v $HOME/.kube/config:/opt/bitnami/kubewatch/.kube/config --name kubewatch-app robustadev/kubewatch

Configure

Kubewatch supports config command for configuration. Config file will be saved at $HOME/.kubewatch.yaml

$ kubewatch config -h

config command allows admin setup his own configuration for running kubewatch

Usage:
  kubewatch config [flags]
  kubewatch config [command]

Available Commands:
  add         add webhook config to .kubewatch.yaml
  test        test handler config present in .kubewatch.yaml
  view        view .kubewatch.yaml

Flags:
  -h, --help   help for config

Use "kubewatch config [command] --help" for more information about a command.

Example:

slack:

  • Create a slack Bot

  • Edit the Bot to customize its name, icon and retrieve the API token (it starts with xoxb-).

  • Invite the Bot into your channel by typing: /invite @name_of_your_bot in the Slack message area.

  • Add Api token to kubewatch config using the following steps

    $ kubewatch config add slack --channel <slack_channel> --token <slack_token>

    You have an altenative choice to set your SLACK token, channel via environment variables:

    $ export KW_SLACK_TOKEN='XXXXXXXXXXXXXXXX'
    $ export KW_SLACK_CHANNEL='#channel_name'

slackwebhookurl:

  • Create a slack app

  • Enable Incoming Webhooks. (On "Settings" page.)

  • Create an incoming webhook URL (Add New Webhook to Workspace on "Settings" page.)

  • Pick a channel that the app will post to, and then click to Authorize your app. You will get back your webhook URL.
    The Slack Webhook URL will look like: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX

  • Add slack webhook url to kubewatch config using the following steps

    $ kubewatch config add slackwebhookurl --username <slack_username> --emoji <slack_emoji> --channel <slack_channel> --slackwebhookurl <slack_webhook_url>

    Or, you have an altenative choice to set your SLACK channel, username, emoji and webhook URL via environment variables:

    $ export KW_SLACK_CHANNEL=slack_channel
    $ export KW_SLACK_USERNAME=slack_username
    $ export KW_SLACK_EMOJI=slack_emoji
    $ export KW_SLACK_WEBHOOK_URL=slack_webhook_url
  • Example apply done in a bash script:

$ cat kubewatch-configmap-slackwebhook.yaml | sed "s|<slackchannel>|"\"$SlackChannel"\"|g;s|<slackusername>|"\"$SlackUsesrName"\"|g;s|<slackemoji>|"\"$SlackEmoji"\"|g;s|<SlackWebhookUrl>|"\"$WebhookUrl"\"|g" | kubectl create -f -
  • An example kubewatch-configmap-slackwebhook.yaml YAML File:
apiVersion: v1
kind: ConfigMap
metadata:
 name: kubewatch
data:
 .kubewatch.yaml: |
   namespace: ""
   handler:
     slackwebhook:
       enabled: true
       channel: <slackchannel>
       username: <slackusername>
       emoji: <slackemoji>
       slackwebhookurl: <SlackWebhookUrl>
   resource:
     clusterrole: false
     configmap: false
     daemonset: false
     deployment: true
     ingress: false
     job: false
     namespace: false
     node: false
     persistentvolume: false
     pod: true
     replicaset: false
     replicationcontroller: false
     secret: false
     serviceaccount: false
     services: true
     event: true
     coreevent: false
   ```

### flock:

- Create a [flock bot](https://docs.flock.com/display/flockos/Bots).

- Add flock webhook url to config using the following command.
 ```console
 $ kubewatch config add flock --url <flock_webhook_url>

You have an altenative choice to set your FLOCK URL

$ export KW_FLOCK_URL='https://api.flock.com/hooks/sendMessage/XXXXXXXX'

Testing Config

To test the handler config by send test messages use the following command.

$ kubewatch config test -h

Tests handler configs present in .kubewatch.yaml by sending test messages

Usage:
  kubewatch config test [flags]

Flags:
  -h, --help   help for test

Example:

$ kubewatch config test

Testing Handler configs from .kubewatch.yaml
2019/06/03 12:29:23 Message successfully sent to channel ABCD at 1559545162.000100

Viewing config

To view the entire config file $HOME/.kubewatch.yaml use the following command.

$ kubewatch config view
Contents of .kubewatch.yaml

handler:
  slack:
    token: xoxb-xxxxx-yyyy-zzz
    channel: kube-watch
  hipchat:
    token: ""
    room: ""
    url: ""
  mattermost:
    channel: ""
    url: ""
    username: ""
  flock:
    url: ""
  webhook:
    url: ""
  cloudevent:
    url: ""
resource:
  deployment: false
  replicationcontroller: false
  replicaset: false
  daemonset: false
  services: false
  pod: true
  job: false
  node: false
  clusterrole: false
  clusterrolebinding: false
  serviceaccount: false
  persistentvolume: false
  namespace: false
  secret: false
  configmap: false
  ingress: false
  event: true
  coreevent: false
namespace: ""

Resources

To manage the resources being watched, use the following command, changes will be saved to $HOME/.kubewatch.yaml.

$ kubewatch resource -h

manage resources to be watched

Usage:
  kubewatch resource [flags]
  kubewatch resource [command]

Available Commands:
  add         adds specific resources to be watched
  remove      remove specific resources being watched

Flags:
      
      --clusterrolebinding      watch for cluster role bindings
      --clusterrole             watch for cluster roles
      --cm                      watch for plain configmaps
      --deploy                  watch for deployments
      --ds                      watch for daemonsets
  -h, --help                    help for resource
      --ing                     watch for ingresses
      --job                     watch for jobs
      --node                    watch for Nodes
      --ns                      watch for namespaces
      --po                      watch for pods
      --pv                      watch for persistent volumes
      --rc                      watch for replication controllers
      --rs                      watch for replicasets
      --sa                      watch for service accounts
      --secret                  watch for plain secrets
      --svc                     watch for services
      --coreevent               watch for events from the kubernetes core api. (Old events api, replaced in kubernetes 1.19)

Use "kubewatch resource [command] --help" for more information about a command.

Add/Remove resource:

$ kubewatch resource add -h

adds specific resources to be watched

Usage:
  kubewatch resource add [flags]

Flags:
  -h, --help   help for add

Global Flags:
      --clusterrole             watch for cluster roles
      --clusterrolebinding      watch for cluster role bindings
      --cm                      watch for plain configmaps
      --deploy                  watch for deployments
      --ds                      watch for daemonsets
      --ing                     watch for ingresses
      --job                     watch for jobs
      --node                    watch for Nodes
      --ns                      watch for namespaces
      --po                      watch for pods
      --pv                      watch for persistent volumes
      --rc                      watch for replication controllers
      --rs                      watch for replicasets
      --sa                      watch for service accounts
      --secret                  watch for plain secrets
      --svc                     watch for services
      --coreevent               watch for events from the kubernetes core api. (Old events api, replaced in kubernetes 1.19)

Example:

# rc, po and svc will be watched
$ kubewatch resource add --rc --po --svc

# rc, po and svc will be stopped from being watched
$ kubewatch resource remove --rc --po --svc

Changing log level

In case you want to change the default log level, add an environment variable named LOG_LEVEL with value from trace/debug/info/warning/error

env:
- name: LOG_LEVEL
  value: debug

Changing log format

In case you want to change the log format to json, add an environment variable named LOG_FORMATTER with value json

env:
- name: LOG_FORMATTER
  value: json

Build

Using go

Clone the repository anywhere:

$ git clone https://github.com/bitnami-labs/kubewatch.git
$ cd kubewatch
$ go build

or

You can also use the Makefile directly:

$ make build

Prerequisites

  • You need to have Go (v1.5 or later) installed. Make sure to set $GOPATH

Using Docker

$ make docker-image
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
kubewatch           latest              919896d3cd90        3 minutes ago       27.9MB

Prerequisites

  • you need to have docker installed.

Contribution

Refer to the contribution guidelines to get started.

kubewatch's People

Contributors

aantn avatar arawak avatar arikalon1 avatar arikcomp avatar avi-robusta avatar bonifaido avatar bors[bot] avatar codenio avatar cuonglm avatar fgeorgatos avatar jbianquetti-nami avatar lshmouse avatar maxospiquante avatar missedone avatar ngtuna avatar pavangudiwada avatar peterfication avatar ppbaena avatar puppetninja avatar rknechtelbm avatar roiglinik avatar ruudk avatar sbueringer avatar sebgoa avatar sheeproid avatar thevops avatar tommy-muehle avatar tuananh avatar tylerauerbeck avatar vaamarnath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubewatch's Issues

[feature] Support watch any k8s resource

User may want to watch their own crd objects, like advanced-statefulset in openkruise. Current object types is too few.\

Actually, if user config kube-watch controller rbac correcly, we can use k8s.io/client-go/dynamic/dynamicinformer to watch any unstructured object if we know it's gvk info (resources can be found by discovery client)\

By this implementation, pkg/controller/controller.go::Start() function will be more short and clear. We can remove so many if conf.Resource.XXX branch.

Feature request: Include a cluster identifier in notifications

It would be nice to have something like a clusterIdentity parameter that I could specify in the configuration and have that clusterIdentity included in the message sent to Slack or elsewhere.

For example, if I specified clusterIdentity: "my-cluster" in the configuration, the message in Slack would look something like this:

kubewatch
A deployment in namespace `kubewatch` in the `my-cluster` cluster has been created:
kubewatch/kubewatch

This way I can use the same Slack channel for multiple clusters and still distinguish between them.

I am getting data in slack but not getting data on webhook

rbac:
create: true
resourcesToWatch:
deployment: true
replicationcontroller: true
replicaset: true
daemonset: true
services: true
pod: true
job: true
node: true
clusterrole: true
clusterrolebinding: true
serviceaccount: true
persistentvolume: true
namespace: true
secret: true
configmap: true
ingress: true
coreevent: true
event: true
slack:
channel: '#general'
token: 'xoxb-################################'
webhook:
enabled: true
url: "https://webhook.site/da1ca748-042d-408b-8805-b273821e1f0b"

Support for multiple namespace

Hi ,
Is multiple namespace supported ?
I can see option to add either on or leave empty to watch all namespaces.

I have deployed kubewatch using helm. And i want resources which are namespace based to be watched from few namespace only.

Suppress info logs

I'm getting 10-20 of those info logs every second in my cluster (I'm viewing all logs with stern). These info logs are quite spammy. I would like to suppress those logs in the robusta helm chart, e.g. by env variables.

monitoring robusta-forwarder-5fcb56d9d-4p2nn kubewatch time="2023-02-05T13:14:42Z" level=info msg="Processing update to ConfigMap: kube-system/cluster-autoscaler-status" pkg=kubewatch-ConfigMap
monitoring robusta-forwarder-5fcb56d9d-4p2nn kubewatch 2023/02/05 13:14:42 Message successfully sent to [http://robusta-runner:80/api/handle](http://robusta-runner/api/handle) at 2023-02-05 13:14:42.869867159 +0000 UTC m=+11939.538309659

Unauthorized event in log

When starting up the container I get the error below.

E0111 13:41:59.199162       1 reflector.go:123] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:96: Failed to list *v1.Event: Unauthorized

Any Idea how to resove this ?

Add Custom Payload/Tags to Messages

For organizations running multiple clusters, right now if they were to implement kubewatch, they would likely need to open unique channels for each cluster and configure each individually so that they could discern the where the message is coming from.

For example, if you have dev, test and prod clusters, each with the same namespaces, and you get an alert saying that a secret was launched in the default namespace, how could you tell which cluster had the new secret launched.

By allowing custom tags, the user could add a field like:

customTags:
  cluster: prod

which would result in a message being sent that reads as:

kubewatch
A deployment in namespace `kubewatch` in the `my-cluster` cluster has been created:
kubewatch/kubewatch

tags:
- cluster: prod

This may be considered a duplicate of #22, but this could also be used to write more custom information to the slack message.

I'd be happy to add this functionality, or alternatively the functionality outlined in the above related issue, I am making this issue to open a discussion of the best way to move forward.

Feature request: Add Amazon EventBridge as supported destination

AWS customers would benefit from adding Amazon EventBridge as a supported destination for notifications.

Amazon EventBridge is a scalable, highly-performant, and low-cost serverless event bus. It's the default event bus provider for many AWS services, including EC2, Auto Scaling, ECS, and many more. Events can be matched using a JSON-based pattern matching, and can be delivered to many supported destinations, including Amazon SNS, AWS Lambda, Amazon API Gateway, Amazon SQS, and many more.

A typical use case would be to match a Kubernetes resource event, forward the event to EventBridge, match the event and invoke an SNS topic, then deliver the notification to the topic's email subscriber(s). Alternatively, EventBridge could deliver the event to CloudWatch Logs, then a pattern matcher could notify someone after N matched events delivered within a bounded timeframe.

Duplicate Messages

Good afternoon .
Okay, I'm using the project, congratulations for the same.
I just configured it and I'm testing something I saw and it generates 3 identical messages for a change. Do you know how I can fix it?

A Pod in namespace test has been Created:
test
14h38
A Pod in namespace test has been Updated:
test
14h38
A Pod in namespace test has been Updated:
test
14h38
A Pod in namespace est has been Updated:
test

Questions regarding kube-watch version support policy

Hello 👋

Firstly, thank you for taking up this project and helping maintain it. It's very much appreciated.

Secondly, I wanted to ask a few questions regarding kubewatch:

  1. Is there a version support policy that kubewatch will be following moving forward? (For eg: Is the latest major.minor supported? Or is the latest major.minor.patch supported? Or is there an n and n-1 policy? etc).
  2. Are there any compatibility concerns with any currently supported versions of kubernetes?
  3. If someone is still using the (now deprecated) bitnami image for kubewatch, what will be your recommend method of upgrading to this one? Will it be to uninstall and then reinstall using the provided method of installation in README?

Your guidance and help will be very much appreciated!

Thank you 🙂

kubewatch event filtering out by k8s event type type (Normal, Information, Warning)

need to filter out k8s "Normal" events so they are NOT forwarded to my Slack channel. looking for a correct syntax in configmap.yaml for section "resourcesToWatch:" or "resource:".

my configmap example:
resource:
clusterrole: false
clusterrolebinding: false
configmap: false
daemonset: false
deployment: false
event: true

my helmrelease example:
resourcesToWatch:
events: true

Bitnami helm package index not found

Hi ,
The latest kubewatch helm package is not indexed in bitnami.Is there any new link for this helm install kubewatch bitnami/kubewatch --set='rbac.create=true,slack.channel=#YOUR_CHANNEL,slack.token=xoxb-YOUR_TOKEN,resourcesToWatch.pod=true,resourcesToWatch.daemonset=true'

"reason" support in kubewatch

Hi, I see in the config.json example that a "reason" configuration was planned, but it looks like it's not yet supported.
I saw in the config.go that the reason section in the Config is commented.

I understand that the goal of this section is to be able to configure which type of events to watch, or restrict which ones we want to capture. Am I right?

Is this planned to the near future?

Not receiving Slack notifications

I deployed kubewatch via the Helm chart. I have it set to watch most resources and all namespaces. I see a bunch of Processing add to Event and Processing update to Event entries in the kubewatch pod log. However, I'm not receiving any messages in the Slack channel I specified in the configuration. And there are no Slack related messages in the pod log. How can I get more information about what's going on and/or troubleshoot this problem?

Slack messages for updates don't include namespace in the message

Notice the `` in the example update message below.

kubewatch
A pod in namespace `` has been updated:
vmware-system-tmc/agentupdater-workload-1674792840-kk7b4

However, it is a bit redundant as the resource name includes the namespace.

Notice the example create and delete messages below include the namespace in the message.

kubewatch
A job in namespace vmware-system-tmc has been created:
agentupdater-workload-1674792900
kubewatch
A job in namespace vmware-system-tmc has been deleted:
vmware-system-tmc/agentupdater-workload-1674792780

Slack alerts for warning and error events

Thanks for maintaining this. I'm trying to set this up in my cluster so I can receive a Slack notification whenever a warning or error level event occurs in the cluster. For example, an image pull failure or a container exists with non-zero exit code.

I do not need reporting for every event that happens. Is there a way to do this?

Thank you.

use official sdk-go for cloudevent handling

Hi there,

thank you for providing and maintaining that great software.

As I am using kubewatch with cloudevents, I investigated some unknown Message encoding errors in combination with the reference Golang SDK and detected the “by hand” implementation in this project.

In order to be and stay more compatible with that standard, an implementation using this SDK would be great.

Kind regards
Florian

Ingress cannot be watched in k8s 1.22+

Hi,

Accessing ingresses through extensions/v1beta1 is no longer possible since 1.22. Deprecation notice

This means that the following code has to start using networking.k8s.io/v1

if conf.Resource.Ingress {

However, by doing so we are breaking ingress support for people running 1.18 and lower.

Since people should have moved on from 1.18 a long time ago, I think it's fair enough to proceed.

Let me know and I can open a pull request pretty quickly

event informations

Hi,

First, thanks for this great project. Showing what's happeing on a k8s cluster is very useful.
I started testing kubewatch, and I have two example about sent messages which is not so informative.

A Node in namespace `` has been Updated:
It would be great if we have more info about that.

A Event in namespace graylog has been Created:
graylog-mongodb-0.173e2cfeb153ed44

This is better, so I can see the event id.

kubectl get event graylog-mongodb-0.173e2cfeb153ed44 -n graylog
LAST SEEN TYPE REASON OBJECT MESSAGE
5m15s Warning Unhealthy pod/graylog-mongodb-0 Readiness probe failed: command "/opt/scripts/readinessprobe" timed out

I think it would be even better if kubewatch send the event contents. Or it is configurable and I'm missing something?

Feature request: namespaceToIgnore

I have a namespace that is very noisy, i.e. jobs and pods created, updated, and deleted every minute. This namespace is on every cluster is the same and I'd like to have one configuration that works on all clusters. I don't want to have to include every namespace but this one from every cluster in a namespaceToWatch list.

Nothing sent via generic webhook to google-chat

Hello, I'm trying to use kubewatch to send everything to a google-chat webhook.
I configured everything, and the test seems fine:

root@kubewatch-64577c4cc7-v5thc:/# kubewatch config test
INFO[0000] Custom log formatter: json                   
INFO[0000] Setting custom log formatter to: json        
Testing Handler configs from .kubewatch.yaml
{"level":"info","msg":"No webhook cert is given","time":"2024-01-26T11:42:54Z"}
{"level":"info","msg":"Message successfully sent to https://chat.googleapis.com/v1/spaces/CENSORED at 2024-01-26 11:42:54.488587515 +0000 UTC m=+0.251134753 ","time":"2024-01-26T11:42:54Z"}

But nothing is actually received in the group chat mentioned.
As a reference, something simple as this in python actually sends the message:

from httplib2 import Http
from json import dumps
import sys

def main():
    url = 'https://chat.googleapis.com/v1/spaces/CENSORED'
    bot_message = {
        'text' : sys.argv[1]}

    message_headers = { 'Content-Type': 'application/json; charset=UTF-8'}

    http_obj = Http()

    response = http_obj.request(
        uri=url,
        method='POST',
        headers=message_headers,
        body=dumps(bot_message),
    )

    print(response)

if __name__ == '__main__':
    main()

What could be the issue? Am I missing something?
Thanks.

Installation using kubectl is not wotking

Tried setting up using kubectl but alerts are not generating in kubectl, whereas in helm its working, If possible could you please resolve this or tell me how to proceed.

K8S Cluster Name

Would you accept a PR to allow a user to add the cluster name to be added to each of the events.

This is handy when you have many clusters and don't want multiple channels. If this is something you would accept I can work in the PR.

Thanks

Disabling "Event" resources does not work

Hi, the option to ignore "Event" resources doesn't seem to work.

I tried to specify in the configuration similarly to other modules:

resourcesToWatch:
  event: false

or

resourcesToWatch:
  events: false

This does not help, I see in the logs that the corresponding module starts despite the configuration:

time="2023-01-27T10:09:55Z" level=info msg="Starting kubewatch controller" pkg=kubewatch-Event

On our large cluster, this gives a lot of noise in notifications to Slack. Thank you in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.