{"id":19209461,"url":"https://github.com/devtron-labs/kubewatch","last_synced_at":"2025-05-12T19:09:18.056Z","repository":{"id":37742692,"uuid":"306292844","full_name":"devtron-labs/kubewatch","owner":"devtron-labs","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-13T10:05:58.000Z","size":107950,"stargazers_count":5,"open_issues_count":8,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-14T04:21:59.564Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devtron-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-10-22T09:50:37.000Z","updated_at":"2024-04-15T09:37:44.838Z","dependencies_parsed_at":"2023-02-18T07:15:56.235Z","dependency_job_id":"a86440e8-fc9f-4cc9-96fc-95dc27930adf","html_url":"https://github.com/devtron-labs/kubewatch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtron-labs%2Fkubewatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtron-labs%2Fkubewatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtron-labs%2Fkubewatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtron-labs%2Fkubewatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devtron-labs","download_url":"https://codeload.github.com/devtron-labs/kubewatch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223832874,"owners_count":17210735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T13:31:11.110Z","updated_at":"2024-11-09T13:32:40.205Z","avatar_url":"https://github.com/devtron-labs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubewatch\n\n\n\n**kubewatch** is a Kubernetes watcher that currently publishes notification to available collaboration hubs/notification channels. Run it in your k8s cluster, and you will get event notifications through webhooks.\n\n#### Environment variables\n### NatStreaming\nvariable Name       |Default Value         |Description\n--------------------|----------------------|------------------\nNATS_SERVER_HOST    |nats://localhost:4222 |\nCLUSTER_ID          |example-stan          |\nCLIENT_ID           |kubewatch             |\n\n###CI-CONFIG\nvariable Name       |Default Value         |Description\n--------------------|----------------------|------------------\nDEFAULT_NAMESPACE   |default               |\n\n# Usage\n```\n$ kubewatch -h\n\nKubewath: A watcher for Kubernetes\n\nkubewatch is a Kubernetes watcher that could publishes notification \nto Slack/hipchat/mattermost/flock channels. It watches the culster \nfor resource changes and notifies them through webhooks.\n\nsupported webhooks:\n - slack\n - hipchat\n - mattermost\n - flock\n - webhook\n\nUsage:\n  kubewatch [flags]\n  kubewatch [command]\n\nAvailable Commands:\n  config      modify kubewatch configuration\n  resource    manage resources to be watched\n  version     print version\n\nFlags:\n  -h, --help   help for kubewatch\n\nUse \"kubewatch [command] --help\" for more information about a command.\n\n```\n\n# Install\n\n### Cluster Installation\n#### Using helm:\n\nWhen you have helm installed in your cluster, use the following setup:\n\n```console\nhelm install --name kubewatch stable/kubewatch --set='rbac.create=true,slack.channel=#YOUR_CHANNEL,slack.token=xoxb-YOUR_TOKEN,resourcesToWatch.pod=true,resourcesToWatch.daemonset=true'\n```\n\nYou may also provide a values file instead:\n\n```yaml\nrbac:\n  create: true\nresourcesToWatch:\n  daemonset: true\n  deployment: false\n  pod: true\n  replicaset: false\n  replicationcontroller: false\n  services: true\n  secret: false\n  configmap: false\nslack:\n  channel: '#YOUR_CHANNEL'\n  token: 'xoxb-YOUR_TOKEN'\n```\n\nAnd use that:\n\n```console\n$ helm upgrade --install kubewatch stable/kubewatch --values=values-file.yml\n```\n\n#### Using kubectl:\n\nIn order to run kubewatch in a Kubernetes cluster quickly, the easiest way is for you to create a [ConfigMap](https://github.com/bitnami-labs/kubewatch/blob/master/kubewatch-configmap.yaml) to hold kubewatch configuration.\n\nAn example is provided at [`kubewatch-configmap.yaml`](https://github.com/bitnami-labs/kubewatch/blob/master/kubewatch-configmap.yaml), do not forget to update your own slack channel and token parameters. Alternatively, you could use secrets.\n\nCreate k8s configmap:\n\n```console\n$ kubectl create -f kubewatch-configmap.yaml\n```\n\nCreate the [Pod](https://github.com/bitnami-labs/kubewatch/blob/master/kubewatch.yaml) directly, or create your own deployment:\n\n```console\n$ kubectl create -f kubewatch.yaml\n```\n\nA `kubewatch` container will be created along with `kubectl` sidecar container in order to reach the API server.\n\nOnce the Pod is running, you will start seeing Kubernetes events in your configured Slack channel. Here is a screenshot:\n\n![slack](./docs/slack.png)\n\nTo modify what notifications you get, update the `kubewatch` ConfigMap and turn on and off (true/false) resources:\n\n```\nresource:\n      deployment: false\n      replicationcontroller: false\n      replicaset: false\n      daemonset: false\n      services: true\n      pod: true\n      secret: false\n      configmap: false\n      ingress: false\n```\n\n#### Working with RBAC\n\nKubernetes Engine clusters running versions 1.6 or higher introduced Role-Based Access Control (RBAC). We can create `ServiceAccount` for it to work with RBAC.\n\n```console\n$ kubectl create -f kubewatch-service-account.yaml\n```\n\nIf you do not have permission to create it, you need to become a admin first. For example, in GKE you would run:\n\n```\n$ kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=REPLACE_EMAIL_HERE\n```\n\nEdit `kubewatch.yaml`, and create a new field under `spec` with `serviceAccountName: kubewatch`, you can achieve this by running:\n\n```console\n$ sed -i '/spec:/a\\ \\ serviceAccountName: kubewatch' kubewatch.yaml\n```\n\nThen just create `pod` as usual with:\n\n```console\n$ kubectl create -f kubewatch.yaml\n```\n\n### Local Installation\n#### Using go package installer:\n\n```console\n# Download and install kubewatch\n$ go get -u github.com/bitnami-labs/kubewatch\n\n# Configure the notification channel \n$ kubewatch config add slack --channel \u003cslack_channel\u003e --token \u003cslack_token\u003e\n\n# Add resources to be watched\n$ kubewatch resource add --po --svc\nINFO[0000] resource svc configured                      \nINFO[0000] resource po configured \n\n# start kubewatch server\n$ kubewatch\nINFO[0000] Starting kubewatch controller                 pkg=kubewatch-service\nINFO[0000] Starting kubewatch controller                 pkg=kubewatch-pod\nINFO[0000] Processing add to service: default/kubernetes  pkg=kubewatch-service\nINFO[0000] Processing add to service: kube-system/tiller-deploy  pkg=kubewatch-service\nINFO[0000] Processing add to pod: kube-system/tiller-deploy-69ffbf64bc-h8zxm  pkg=kubewatch-pod\nINFO[0000] Kubewatch controller synced and ready         pkg=kubewatch-service\nINFO[0000] Kubewatch controller synced and ready         pkg=kubewatch-pod\n\n```\n\n# Configure\n\nKubewatch supports `config` command for configuration. Config file will be saved at `$HOME/.kubewatch.yaml`\n\n```\n$ kubewatch config -h\n\nconfig command allows admin setup his own configuration for running kubewatch\n\nUsage:\n  kubewatch config [flags]\n  kubewatch config [command]\n\nAvailable Commands:\n  add         add webhook config to .kubewatch.yaml\n  view        view .kubewatch.yaml\n\nFlags:\n  -h, --help   help for config\n\nUse \"kubewatch config [command] --help\" for more information about a command.\n```\n### Example:\n\n### slack:\n\n- Create a [slack Bot](https://my.slack.com/services/new/bot)\n\n- Edit the Bot to customize its name, icon and retrieve the API token (it starts with `xoxb-`).\n\n- Invite the Bot into your channel by typing: `/join @name_of_your_bot` in the Slack message area.\n\n- Add Api token to kubewatch config using the following steps\n\n  ```console\n  $ kubewatch config add slack --channel \u003cslack_channel\u003e --token \u003cslack_token\u003e\n  ```\n  You have an altenative choice to set your SLACK token, channel via environment variables:\n\n  ```console\n  $ export KW_SLACK_TOKEN='XXXXXXXXXXXXXXXX'\n  $ export KW_SLACK_CHANNEL='#channel_name'\n  ```\n\n### flock:\n\n- Create a [flock bot](https://docs.flock.com/display/flockos/Bots).\n\n- Add flock webhook url to config using the following command.\n  ```console\n  $ kubewatch config add flock --url \u003cflock_webhook_url\u003e\n  ```\n  You have an altenative choice to set your FLOCK URL\n\n  ```console\n  $ export KW_FLOCK_URL='https://api.flock.com/hooks/sendMessage/XXXXXXXX'\n  ```\n\n## Viewing config\nTo view the entire config file `$HOME/.kubewatch.yaml` use the following command.\n```\n$ kubewatch config view\nContents of .kubewatch.yaml\n\nhandler:\n  slack:\n    token: xoxb-xxxxx-yyyy-zzz\n    channel: kube-watch\n  hipchat:\n    token: \"\"\n    room: \"\"\n    url: \"\"\n  mattermost:\n    channel: \"\"\n    url: \"\"\n    username: \"\"\n  flock:\n    url: \"\"\n  webhook:\n    url: \"\"\nresource:\n  deployment: false\n  replicationcontroller: false\n  replicaset: false\n  daemonset: false\n  services: false\n  pod: true\n  job: false\n  persistentvolume: false\n  namespace: false\n  secret: false\n  configmap: false\n  ingress: false\nnamespace: \"\"\n\n```\n\n\n## Resources\n\nTo manage the resources being watched, use the following command, changes will be saved to `$HOME/.kubewatch.yaml`.\n\n```\n$ kubewatch resource -h\n\nmanage resources to be watched\n\nUsage:\n  kubewatch resource [flags]\n  kubewatch resource [command]\n\nAvailable Commands:\n  add         adds specific resources to be watched\n  remove      remove specific resources being watched\n\nFlags:\n      --cm       watch for plain configmap\n      --deploy   watch for deployments\n      --ds       watch for daemonsets\n  -h, --help     help for resource\n      --ing      watch for ingresses\n      --job      watch for job\n      --ns       watch for namespaces\n      --po       watch for pods\n      --pv       watch for persistent volumes\n      --rc       watch for replication controllers\n      --rs       watch for replicasets\n      --secret   watch for plain secrets\n      --svc      watch for services\n\nUse \"kubewatch resource [command] --help\" for more information about a command.\n\n```\n\n### Add/Remove resource:\n```\n$ kubewatch resource add -h\n\nadds specific resources to be watched\n\nUsage:\n  kubewatch resource add [flags]\n\nFlags:\n  -h, --help   help for add\n\nGlobal Flags:\n      --cm       watch for plain configmaps\n      --deploy   watch for deployments\n      --ds       watch for daemonsets\n      --ing      watch for ingresses\n      --job      watch for jobs\n      --ns       watch for namespaces\n      --po       watch for pods\n      --pv       watch for persistent volumes\n      --rc       watch for replication controllers\n      --rs       watch for replicasets\n      --secret   watch for plain secrets\n      --svc      watch for services\n\n```\n\n### Example:\n\n```console\n# rc, po and svc will be watched\n$ kubewatch resource add --rc --po --svc\n\n# rc, po and svc will be stoped from being watched\n$ kubewatch resource remove --rc --po --svc\n```\n\n# Build\n\n### Using go\n\nClone the repository into your $GOPATH and then build it.\n```\n$ mkdir -p $GOPATH/src/github.com/devtron-labs/\n$ cd $GOPATH/src/github.com/devtron-labs/\n$ git clone https://github.com/devtron-labs/kubewatch.git\n$ cd kubewatch\n$ go build -o kubewatch main.go\n```\n\nYou can also use the Makefile directly:\n\n```console\n$ make build\n```\n\n#### Prerequisites\n\n- You need to have [Go](http://golang.org) (v1.7 or later)  installed. Make sure to set `$GOPATH`\n\n\n### Using Docker\n\n```console\n$ make docker-image\n$ docker images\nREPOSITORY          TAG                 IMAGE ID            CREATED              SIZE\nkubewatch           latest              919896d3cd90        3 minutes ago       27.9MB\n```\n#### Prerequisites\n\n- you need to have [docker](https://docs.docker.com/) installed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtron-labs%2Fkubewatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevtron-labs%2Fkubewatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtron-labs%2Fkubewatch/lists"}