-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v2 | ||
name: kubirds-webhook-reactor | ||
description: Parametrable Webhook Reactor for Kubirds | ||
type: application | ||
version: 0.1.0 | ||
appVersion: "1.16.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Webhook message | ||
|
||
This Docker image sends a json [gotempl](https://github.com/link-society/gotempl) message to a webhook | ||
|
||
It can be used in several services as | ||
|
||
- [teams](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook) | ||
- [slack](https://api.slack.com/messaging/webhooks) | ||
- [telegram](https://core.telegram.org/bots/api#setwebhook) | ||
- [discord](https://discord.com/developers/docs/resources/webhook) | ||
- [facebook](https://developers.facebook.com/docs/graph-api/webhooks/) | ||
- [whatsapp](https://developers.facebook.com/docs/whatsapp/api/webhooks/) | ||
- [instagram](https://developers.facebook.com/docs/instagram-api/guides/webhooks/) | ||
- [github](https://docs.github.com/en/developers/webhooks-and-events/webhooks/creating-webhooks) | ||
- [gitlab](https://docs.gitlab.com/ee/user/project/integrations/webhooks.html) | ||
- [jira](https://developer.atlassian.com/server/jira/platform/webhooks/) | ||
- [trading view](https://www.tradingview.com/support/solutions/43000529348-about-webhooks/) | ||
|
||
## Helm values | ||
|
||
| Variable | Default | Description | | ||
| --- | --- | --- | | ||
| `webhook` | | webhook URL | | ||
| `message` | | json [gotempl](https://github.com/link-society/) to send | | ||
| `method` | `POST`| HTTP method | | ||
| `headers` | `Content-Type: application/json` | [gotempl](https://github.com/link-society/) HTTP headers to send | | ||
| `cookies` | `''` | [gotempl](https://github.com/link-society/) HTTP cookies to send | | ||
| `curlConfig` | `''` | [gotempl](https://github.com/link-society/) cURL config to use | | ||
| `curlArgs` | `''` | [gotempl](https://github.com/link-society/) cURL args to use | | ||
| `triggers` | `{ success, failure }` | [Kubirds reactor triggers](https://kubirds.com/docs/concepts/reactor/schema/#triggers) | | ||
| `emptySelectorBehavior` | `MatchAll` | [Kubirds reactor emptySelectorBehavior](https://kubirds.com/docs/concepts/reactor/schema/#emptyselectorbehavior) | | ||
|
||
## Example of Helm chart installation | ||
|
||
This example notifies a Teams channel about any up/down Kubirds unit | ||
|
||
```bash | ||
$ helm install healthcheck-teams \ | ||
helm.link-society/incubator/kubirds-webhook-reactor \ | ||
--set message='{ "text": "{{ .Env.UNIT_NAME }} is {{ if eq .Env.UNIT_STATE 0 }}up{{ else }}down{{ end }}" }' \ | ||
--set webhook='https://mykey.webhook.office.com' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "kubirds-webhook-reactor.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "kubirds-webhook-reactor.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "kubirds-webhook-reactor.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "kubirds-webhook-reactor.labels" -}} | ||
helm.sh/chart: {{ include "kubirds-webhook-reactor.chart" . }} | ||
{{ include "kubirds-webhook-reactor.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "kubirds-webhook-reactor.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "kubirds-webhook-reactor.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Webhook check | ||
*/}} | ||
{{ if not .Values.webhook }} | ||
{{ fail "Webhook can not be empty" }} | ||
{{ end }} | ||
|
||
{{/* | ||
Message check | ||
*/}} | ||
{{ if not .Values.message }} | ||
{{ fail "Message can not be empty" }} | ||
{{ end }} |
10 changes: 10 additions & 0 deletions
10
incubator/kubirds-webhook-reactor/templates/configMap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "kubirds-webhook-reactor.fullname" . }} | ||
labels: | ||
{{- include "kubirds-webhook-reactor.labels" . | nindent 4 }} | ||
data: | ||
request-body.json: | | ||
{{- .Values.message | toJson | nindent 4 -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
apiVersion: kubirds.com/v1 | ||
kind: Reactor | ||
metadata: | ||
name: {{ include "kubirds-webhook-reactor.fullname" . }} | ||
labels: | ||
{{- include "kubirds-webhook-reactor.labels" . | nindent 4 }} | ||
{{ if .Values.labels }} | ||
{{ .Values.labels | toYaml | nindent 4 }} | ||
{{ end }} | ||
spec: | ||
unitSelector: | ||
{{- .Values.unitSelector | toYaml | nindent 4 }} | ||
triggers: | ||
{{- .Values.triggers | toYaml | nindent 4 }} | ||
emptySelectorBehavior: {{ .Values.emptySelectorBehavior }} | ||
image: | ||
name: {{ .Values.image.name }} | ||
pullPolicy: {{ .Values.image.pullPolicy }} | ||
command: {{ .Values.image.command }} | ||
env: | ||
- name: REQUEST_METHOD | ||
value: {{ .Values.method | quote }} | ||
- name: REQUEST_HEADERS | ||
value: {{ .Values.headers | quote }} | ||
- name: REQUEST_BODY | ||
value: '@/config/request-body.json' | ||
- name: REQUEST_URL | ||
value: {{ .Values.webhook | quote }} | ||
- name: REQUEST_COOKIES | ||
value: {{ .Values.cookies }} | ||
- name: REQUEST_ARGS | ||
value: {{ .Values.curlArgs }} | ||
- name: REQUEST_CONFIG | ||
value: {{ .Values.curlConfig }} | ||
volumes: | ||
- name: message | ||
mountPath: /config | ||
configMap: | ||
name: {{ include "kubirds-webhook-reactor.fullname" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
|
||
# User Configuration | ||
|
||
labels: {} | ||
|
||
nameOverride: '' | ||
fullnameOverride: '' | ||
|
||
# Internal Configuration (can be overidden) | ||
|
||
image: | ||
name: ghcr.io/link-society/curl-gotempl:latest | ||
pullPolicy: IfNotPresent | ||
command: curl-gotempl | ||
|
||
method: POST | ||
headers: 'Content-Type: application/json' | ||
webhook: | ||
|
||
curlConfig: '' | ||
curlArgs: '' | ||
cookies: '' | ||
|
||
message: | ||
|
||
unitSelector: {} | ||
|
||
triggers: | ||
success: true | ||
failure: true | ||
fixed: false | ||
regression: false | ||
|
||
emptySelectorBehavior: MatchAll # MatchNone otherwise |