Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/olegsu/iris

Watch on Kubernetes events, filter and send them as standard wehbook to any system
https://github.com/olegsu/iris

codefresh kubernetes kubernetes-cluster slack webhook webhooks

Last synced: 2 months ago
JSON representation

Watch on Kubernetes events, filter and send them as standard wehbook to any system

Awesome Lists containing this project

README

        

# IRIS

[![Go Report Card](https://goreportcard.com/badge/github.com/olegsu/iris)](https://goreportcard.com/report/github.com/olegsu/iris)
[![codecov](https://codecov.io/gh/olegsu/iris/branch/master/graph/badge.svg)](https://codecov.io/gh/olegsu/iris)

**_In Greek mythology, Iris is the personification of the rainbow and messenger of the gods._**

- [IRIS](#iris)
- [Run in cluster](#run-in-cluster)
- [Using Helm](#using-helm)
- [Build](#build)
- [Filters](#filters)
- [Reason](#reason)
- [Namespace](#namespace)
- [JSONPath](#jsonpath)
- [Labels](#labels)
- [Any](#any)
- [Destinations](#destinations)
- [Default](#default)
- [Codefresh](#codefresh)
- [Integrations](#integrations)

Easily configure webhooks on Kubernetes events using highly customizable filters

* This project is not stable yet and may be changed anytime without any notice.

## Run in cluster
### Using Helm
* clone or fork this repository
* create your iris.yaml file
* install chart from local directory `helm install ./iris --values ./iris.yaml`
* by default the chart will be installed into namespace `iris`, see default values to overwrite it

## Build
* clone or fork this repo
* `make install`
* `make build`
* Limitations:
* Execute out of cluster `iris run --help`
* Execute on non GCP cluster

Quick example:

In this example we will configure to listen on any Kubernetes event that been reported by the pod controller and matched to the filter will be sent to the destination.

```yaml
filters:
- name: MatchDefaultNamespace
type: namespace
namespace: default
- name: MatchPodKind
type: jsonpath
path: $.involvedObject.kind
value: Pod

destinations:
- name: prod
url: http://localhost

integrations:
- name: Report
destinations:
- prod
filters:
- MatchPodKind
- MatchDefaultNamespace
```

## Filters
Set of rules that will be applied on each [Kubernetes event](https://github.com/kubernetes/api/blob/master/core/v1/types.go#L4501).
Kubernetes event that will pass all required filters will be passed to the destination to be reported
Types of filters:
### Reason
Reason filter is a syntactic sugar for [JSONPath](#jsonpath) filter with `path: $.reason` and `value: {{reason}}`
```yaml
filters:
- name: PodScheduled
reason: "Scheduled"
```

### Namespace
Namespace filter is a syntactic sugar for [JSONPath](#jsonpath) filter with `path: $.metadata.namespace` and `value: {{reason}}`
```yaml
filters:
- name: FromDefaultNamespace
namespace: default
```

### JSONPath
With JSONPath gives the ability to match any field from [Kubernetes event](https://github.com/kubernetes/api/blob/master/core/v1/types.go#L5478).
The value from the fields can be matched to exec value using `value: {{value}}` or matched by regex using `regexp: {{regexp}}`
```yaml
filters:
# Match to Warning event type
- name: WarningLevel
type: jsonpath
path: $.type
value: Warning
# Match to any event that the name matched to regexp /tiller/
- name: MatchToRegexpTiller
type: jsonpath
path: $.metadata.name
regexp: tiller
```

### Labels
Labels filter will try to get the original resource from the event with the given filters.
The filter considers as passed if any resource were found
```yaml
filters:
- name: MatchLabels
type: labels
labels:
app: helm
```

### Any
```yaml
filters:
- name: WarningLevel
type: any
filters:
- FromDefaultNamespace
- WarningLevel
```

## Destinations
Each destination is an api endpoint where the Kubernetes event will be sent
Types of destinations:
### Default
The default destinations will attempt to send POST request with the event json in the request body
If `secret` is given, hash string will be calculated using the given key on the request body and the result will be set in the request header as `X-IRIS-HMAC: hash`
```yaml
destinations:
- name: Webhook
url: https://webhook.site
secret: SECRET
```
### Codefresh
With Iris, you can execute Codefresh pipelines.
Add destinations with Codefresh type:
* name: pipeline full name can be found easily using [Codefresh CLI](https://codefresh-io.github.io/cli/) - `codefresh get pipelines`
* branch: which branch of the repo should be cloned
* cftoken: Token to Codefresh API can be generated in [Account settings/Tokens](https://g.codefresh.io/account-conf/tokens) view
```yaml
- name: ExecuteCodefreshPipeline
type: Codefresh
pipeline: PIPELINE_NAME
cftoken: API_TOKEN
branch: master
```

## Integrations
Connecting between filters and destinations
```yaml
integrations:
- name: Report
destinations:
- {{name of destination}}
filters:
- {{name of filters to apply}}
```