Categorygithub.com/larderdev/kubewise
repositorypackage
0.7.3
Repository: https://github.com/larderdev/kubewise.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

KubeWise Mark and Name

Go workflow status

KubeWise is a notifications bot for Helm 3. It notifies your team chat whenever a Helm chart is installed, upgraded, rolled back or uninstalled in your Kubernetes cluster.

A demo of KubeWise posting Slack messages as ZooKeeper is installed, upgraded and uninstalled

Supported Applications

LogoNameSupported
Slack markSlackāœ…Get started
Google Chat markGoogle Hangouts Chatāœ…Get started
Webhooksāœ…Get started
Microsoft Teams markMicrosoft teamsā³

šŸ“£ Get notified when your chosen chat app is supported.

Getting Started

In general, the getting started process has two steps:

  1. Create a bot in your team chat application.
  2. Install KubeWise, passing it an API token for the bot.

Sensitive tokens are stored securely in Kubernetes secrets. No data is ever sent to an external API (other than your chosen team chat app obviously).

Slack

How it looks

Slack sample

Step 1: Create the bot

  1. Create a Slack Bot.
    • username: kubewise
    • name: KubeWise
    • icon: Use This
  2. Save it and grab the API token.
  3. Invite the Bot into your channel by typing /invite @kubewise in your Slack channel.
  4. Install KubeWise in your Kubernetes cluster. See below.

Step 2: Install KubeWise

kubectl create namespace kubewise
helm repo add larder https://charts.larder.dev
helm install kubewise larder/kubewise --namespace kubewise --set handler=slack --set slack.token="<api-token>" --set slack.channel="#<channel>"

That's it! From now on, Helm operations will result in a message in your chosen Slack channel.

Google Hangouts Chat

How it looks

Google Hangouts Chat sample

Step 1: Create the bot

  1. Open Hangouts Chat in your browser.
  2. Go to the room to which you want to add a bot.
  3. From the dropdown menu at the top of the page, select "Configure webhooks".
  4. Under Incoming Webhooks, click ADD WEBHOOK.
  5. Name the new webhook KubeWise and set the Avatar URL to https://raw.githubusercontent.com/larderdev/kubewise/master/assets/kubewise-mark-blue-512x512.png.
  6. Click SAVE.
  7. Copy the URL listed next to your new webhook in the Webhook Url column. You will need this later.
  8. Click outside the dialog box to close.

Step 2: Install KubeWise

kubectl create namespace kubewise
helm repo add larder https://charts.larder.dev
helm install kubewise larder/kubewise --namespace kubewise --set handler=googlechat --set googlechat.webhookUrl="<webhook-url>"

Webhooks

KubeWise can be used to send a JSON payload to an arbitrary endpoint when a Helm operation occurs.

How it looks

{
  "appName": "zookeeper",
  "appVersion": "3.5.5",
  "namespace": "zookeeper",
  "previousAppVersion": "3.2.1",
  "action": "PRE_UNINSTALL",
  "appDescription": "Keep your stuff in the zoo",
  "installNotes": "... truncated notes ..."
}

Step 1: Install KubeWise

kubectl create namespace kubewise
helm repo add larder https://charts.larder.dev
helm install kubewise larder/kubewise --namespace kubewise --set handler=webhook --set webhook.url="<webhook-url>"

The optional parameter webhook.method is also supported. It defaults to POST.

Basic authentication is supported via the webhook.authToken="<api-token>" parameter. It will add the following header to the request "Authorization":"Bearer <api-token>".

Using KubeWise from outside a cluster

It is easy to use KubeWise from outside your Kubernetes cluster. It will pick up your local kubectl configuration and use it to speak to your cluster.

You will need to compile the go binary from source. For example,

# Clone and compile the binary
git clone [email protected]:larderdev/kubewise.git
cd kubewise
go build

# Run it against a cluster
env KW_HANDLER=slack KW_SLACK_CHANNEL="#<channel>" KW_SLACK_TOKEN="<api-token>" kubewise

Multiple clusters in the same channel

It's common for teams to have multiple Kubernetes clusters running such as staging and production.

KubeWise supports sending the notifications from all of your clusters to one place. In order to tell the clusters apart, it is a good idea to use the messagePrefix feature.

helm install kubewise larder/kubewise --namespace kubewise --set messagePrefix="\`production\` " --set handler=slack --set slack.token="<api-token>" --set slack.channel="#<channel>"

This will produce the following effect:

uninstalling ZooKeeper with a message prefix

Full configuration list

ParameterEnvironment Variable EquivalentDefaultDescription
handlerKW_HANDLERslackThe service to send the notifications to. Options are slack, webhook and googlechat.
slack.channelKW_SLACK_CHANNEL#generalThe Slack channel to send notification to when using the Slack handler.
slack.tokenKW_SLACK_TOKENThe Slack API token to use. Must be provided by user.
webhook.methodKW_WEBHOOK_METHODPOSTThe webhook HTTP method to use.
webhook.urlKW_WEBHOOK_URLThe webhook URL to send the request to.
webhook.authTokenKW_WEBHOOK_AUTH_TOKENAn optional Bearer auth header to send with the request.
googlechat.webhookUrlKW_GOOGLECHAT_WEBHOOK_URLThe Google Hangouts Chat URL to use. Must be provided by user.
namespaceToWatchKW_NAMESPACE""The cluster namespace to watch for Helm operations in. Leave blank to watch all namespaces.
messagePrefixKW_MESSAGE_PREFIXA prefix for every notification sent. Often used to identify the cluster (production, staging etc).
image.repositoryus.gcr.io/larder-prod/kubewiseImage repository
image.tag<VERSION>Image tag
replicaCount1Number of KubeWise pods to deploy. More than 1 is not desirable
image.pullPolicyIfNotPresentImage pull policy
imagePullSecrets[]Image pull secrets
nameOverride""Name override
fullnameOverride""Full name override