Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@ jobs:
name: Check
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.20'

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Build
run: go build

- name: Test
run: go test -race --coverprofile=coverage.txt --covermode=atomic ./...

- name: Upload coverage to Codecov
if: success() && github.ref == 'refs/heads/main'
uses: codecov/codecov-action@v1
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2

uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: ghcr.io/abahmed/kwatch

- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:alpine AS builder
ARG RELEASE_VERSION="nothing"
LABEL maintainer="Abdelrahman Ahmed <[email protected]"
LABEL maintainer="Abdelrahman Ahmed <[email protected]>"

RUN apk update && \
apk add git build-base && \
Expand All @@ -13,7 +13,7 @@ RUN go mod download

COPY . /build/
RUN sed -i 's/dev/'"${RELEASE_VERSION}"'/g' version/version.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a --installsuffix cgo --ldflags="-s"
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o kwatch .

FROM alpine:latest
RUN apk add --update ca-certificates
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@

### Install

#### Using Helm

```shell
helm repo add kwatch https://kwatch.dev/charts
helm install [RELEASE_NAME] kwatch/kwatch --namespace kwatch --create-namespace --version 0.8.0
```

To get more details, please check [chart's configuration](https://github.com/abahmed/kwatch/blob/main/deploy/chart/README.md)

#### Using kubectl

You need to get config template to add your configs

```shell
Expand Down
6 changes: 6 additions & 0 deletions deploy/chart/.helmignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# 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
Expand Down
32 changes: 21 additions & 11 deletions deploy/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
---
apiVersion: v2
appVersion: v0.8.0
version: 0.2.0
name: kwatch
description: |4
Helm chart to deploy Kwatch on Your kubernetes cluster.
version: "0.8.0"
appVersion: "v0.8.0"
description: monitor all changes in your Kubernetes(K8s) cluster, detects crashes
in your running apps in realtime, and publishes notifications to your channels (Slack,
Discord, etc.) instantly
type: application
home: https://kwatch.dev
icon: https://kwatch.dev/img/kwatch-logo.png
sources:
- https://github.com/abahmed/kwatch
keywords:
- kwatch
- kwatch
- kubernetes
- monitoring
- crash-reporting
- event-notifier
maintainers:
- name: yaser
email: [email protected]
url: github.com/yaskinny
home: https://github.com/abahmed/kwatch
...
- email: [email protected]
name: Abdelrahman Ahmed
url: github.com/abahmed
- email: [email protected]
name: yaser
url: github.com/yaskinny

38 changes: 38 additions & 0 deletions deploy/chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# kwatch Helm Chart

monitor all changes in your Kubernetes(K8s) cluster, detects crashes in your running apps in realtime, and publishes notifications to your channels (Slack,
Discord, etc.) instantly

## Add Repository

```console
helm repo add kwatch https://kwatch.dev/charts
helm repo update
```

## Install Chart

```console
helm install [RELEASE_NAME] kwatch/kwatch --version 0.8.0
```

## Uninstall Chart

```console
helm delete --purge [RELEASE_NAME]
```

## Configuration

| Parameter | Description | Default |
|-----------|-------------|---------|
| `podAnnotations` | Pod annotations | {} |
| `securityContext.runAsNonRoot` | Container runs as a non-root user | true |
| `securityContext.runAsUser` | Container processes' UID to run the entrypoint | 101 |
| `securityContext.runAsGroup` | Container processes' GID to run the entrypoint | 101 |
| `securityContext.readOnlyRootFilesystem` | Container's root filesystem is read-only | true |
| `resources` | CPU/Memory resource requests/limits | {limits: memory: 128Mi cpu: 100m} |
| `nodeSelector` | Node labels for pod assignment | {} |
| `tolerations` | Tolerations for pod assignment | [] |
| `affinity` | affinity for pod | {} |
| `config` | [kwatch configuration](https://github.com/abahmed/kwatch#configuration) | {} |
65 changes: 57 additions & 8 deletions deploy/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,62 @@
{{/*
Kubernetes common labels
Expand the name of the chart.
*/}}
{{- define "kwatch.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "kwatch.commonLabels" -}}
app.kubernetes.io/name: kwatch
app.kubernetes.io/version: {{ .Chart.AppVersion }}
{{- 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 "kwatch.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 "kwatch.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "kwatch.labels" -}}
helm.sh/chart: {{ include "kwatch.chart" . }}
{{ include "kwatch.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "kwatch.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kwatch.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "kwatch.matchLabels" -}}
app.kubernetes.io/name: kwatch
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "kwatch.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "kwatch.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
77 changes: 3 additions & 74 deletions deploy/chart/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,79 +1,8 @@
{{- $c := .Values.kwatch.config -}}
{{- if $c.create -}}
{{- $conf := $c.configTemplate -}}
{{- $conftpl := $c.configTemplate.alert -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-kwatch
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
{{- if .Values.commonLabels }}
labels:
{{- with .Values.commonLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
data:
config: |4
maxRecentLogLines: {{ default 0 $conf.maxRecentLogLines }}
ignoreFailedGracefulShutdown: {{ default false $conf.ignoreFailedGracefulShutdown }}
disableUpdateCheck: {{ default false $conf.disableUpdateCheck }}
{{- with $conftpl.namespaces }}
namespaces: {{ toYaml . | indent 8 }}
{{- end }}
{{- if or $conftpl.slack.webhook $conftpl.telegram.token $conftpl.pagerduty.integrationKey $conftpl.discord.webhook $conftpl.teams.webhook $conftpl.rocketchat.webhook $conftpl.mattermost.webhook $conftpl.opsgenie.apiKey $conftpl.namespaces }}
alert:
{{- if $conftpl.slack.webhook }}
slack:
webhook: {{ $conftpl.slack.webhook | quote }}
title: {{ default "" $conftpl.slack.title | quote }}
text: {{ default "" $conftpl.slack.text | quote }}
{{- end }}
{{- if $conftpl.pagerduty.integrationKey }}
pagerduty:
integrationKey: {{ $conftpl.pagerduty.integrationKey | quote }}
{{- end }}
{{- if $conftpl.discord.webhook }}
discord:
webhook: {{ $conftpl.discord.webhook }}
title: {{ default "" $conftpl.discord.title | quote }}
text: {{ default "" $conftpl.discord.text | quote }}
{{- end }}
{{- if and $conftpl.telegram.token $conftpl.telegram.chatId }}
telegram:
token: {{ $conftpl.telegram.token }}
chatId: {{ $conftpl.telegram.chatId }}
{{- end }}
{{- if $conftpl.teams.webhook }}
teams:
webhook: {{ $conftpl.teams.webhook }}
title: {{ default "" $conftpl.teams.title | quote }}
text: {{ default "" $conftpl.teams.text | quote }}
{{- end }}
{{- if $conftpl.rocketchat.webhook }}
rocketchat:
webhook: {{ $conftpl.rocketchat.webhook }}
text: {{ default "" $conftpl.rocketchat.text | quote }}
{{- end }}
{{- if $conftpl.mattermost.webhook }}
mattermost:
webhook: {{ $conftpl.mattermost.webhook | quote }}
title: {{ default "" $conftpl.mattermost.title | quote }}
text: {{ default "" $conftpl.mattermost.text | quote }}
{{- end }}
{{- if $conftpl.opsgenie.apiKey }}
opsgenie:
apiKey: {{ $conftpl.opsgenie.apiKey | quote}}
title: {{ default "" $conftpl.opsgenie.title | quote }}
text: {{ default "" $conftpl.opsgenie.text | quote }}
{{- end }}
{{- end }}
...
{{- end }}
config.yaml: |
{{- toYaml .Values.config | nindent 4 }}
Loading