Skip to content

Commit

Permalink
chore: add helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
bougou committed Aug 30, 2024
1 parent 5532bcc commit 0e007a0
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
---
# Release files to GitHub Releases

name: Tagged Release CI
name: Release binary

on:
push:
branches:
- "main"
tags:
- "v*"

jobs:
tagged-release:
name: Tagged Release

binary-release:
name: binary release
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags/v')

steps:
- uses: actions/checkout@v2
- name: Set up Go

- name: set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Build & test
- name: build & test
run: |
make dependencies
make build-all
- uses: marvinpinto/action-automatic-releases@latest
- name: release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Tagged Release CI
name: Release docker

on:
push:
Expand All @@ -9,36 +9,42 @@ on:
- "v*"

jobs:

build_and_push:
docker-release:
name: docker release
runs-on: ubuntu-latest

steps:
- uses: AutoModality/action-clean@v1

- uses: actions/checkout@v2
- name: Set up Docker Buildx

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Login

- name: docker login
uses: docker/[email protected]
with:
# registry: ${{ secrets.DOCKERHUB_ADDR }}
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Prepare short tag

- name: prepare short tag
id: prepare_short_tag
run: |
SHORT_TAG=`git describe --abbrev=5 --dirty --tags --always`
echo "::set-output name=image_short_tag::$SHORT_TAG"
echo "::notice title=Build Image Short Tag::$SHORT_TAG"
- name: Prepare tag
- name: prepare tag
id: prepare_tag
run: |
TIME_TAG=`TZ=Zero date +"%y%m%d%H%M%S"`
COMMIT_TAG=`echo $GITHUB_SHA | cut -c 1-7`
TAG="$TIME_TAG-$COMMIT_TAG"
echo "::set-output name=image_tag::$TAG"
echo "::notice title=Build Image Tag::$TAG"
- name: Build and push
- name: build and push
uses: docker/build-push-action@v2
with:
push: true
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,16 @@ $ systemctl start

```bash
# expose the host port (127.0.0.1:8090) to container port (8090)
docker run --rm -it -p 127.0.0.1:8090:8090 bougou/alertmanager-webhook-adapter:v1.1.7
docker run --rm -it -p 127.0.0.1:8090:8090 bougou/alertmanager-webhook-adapter:v1.1.8
docker run --rm -it -p 127.0.0.1:8090:8090 bougou/alertmanager-webhook-adapter:v1.1.7 --signature MyIDC --debug
docker run --rm -it -p 127.0.0.1:8090:8090 bougou/alertmanager-webhook-adapter:v1.1.8 --signature MyIDC --lang zh --debug
```

### Run in K8S

```
Apply manifests:

```bash
cd deploy/k8s
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
Expand Down
8 changes: 8 additions & 0 deletions deploy/charts/alertmanager-webhook-adapter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
appVersion: 1.1.8
description: helm chart for alertmanager webhook adapter
name: alertmanager-webhook-adapter
version: 1.0.1
type: application
maintainers:
- name: bougou
21 changes: 21 additions & 0 deletions deploy/charts/alertmanager-webhook-adapter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- define "awa.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}


{{- define "awa.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 -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "awa.fullname" . }}
namespace: {{ include "awa.namespace" . }}
spec:
replicas: 1
selector:
matchLabels:
app: alertmanager-webhook-adapter
template:
metadata:
labels:
app: alertmanager-webhook-adapter
spec:
containers:
- name: webhook
image: {{ .Values.image.name }}:{{ .Values.image.tag }}
command:
- /alertmanager-webhook-adapter
- --listen-address=:8090
- --signature={{ .Values.signature }}
- --tmpl-lang={{ .Values.lang | default "en" }}
env:
- name: TZ
value: {{ .Values.timezone }}
resources:
requests:
memory: 50Mi
cpu: 100m
limits:
memory: 250Mi
cpu: 500m
restartPolicy: Always
14 changes: 14 additions & 0 deletions deploy/charts/alertmanager-webhook-adapter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "awa.fullname" . }}
namespace: {{ include "awa.namespace" . }}
spec:
ports:
- port: 80
targetPort: 8090
protocol: TCP
selector:
app: alertmanager-webhook-adapter
sessionAffinity: None
6 changes: 6 additions & 0 deletions deploy/charts/alertmanager-webhook-adapter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
image:
name: bougou/alertmanager-webhook-adapter
tag: v1.1.8
signature: MyIDC
lang: en
timezone: Asia/Shanghai
2 changes: 1 addition & 1 deletion deploy/k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: webhook
image: bougou/alertmanager-webhook-adapter:v1.1.7
image: bougou/alertmanager-webhook-adapter:v1.1.8
command:
- /alertmanager-webhook-adapter
- --listen-address=:8090
Expand Down

0 comments on commit 0e007a0

Please sign in to comment.