Skip to content

Commit bcf4cd4

Browse files
committed
feat: add sweeper chart
1 parent abb1b23 commit bcf4cd4

15 files changed

Lines changed: 674 additions & 2 deletions

File tree

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: sweeper-chart-release-pullrequest
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'sweeper-chart/**'
7+
- '.github/workflows/sweeper-chart-release-pullrequest.yaml'
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
env:
13+
MODULE: sweeper
14+
GHCR_REPO: ghcr.io/${{ github.repository }}
15+
16+
jobs:
17+
lint-and-install:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
k8s_version: [ "v1.32.8", "v1.33.4" ]
22+
23+
steps:
24+
- name: Authenticate with GitHub App
25+
id: authenticate
26+
uses: tibdex/github-app-token@v1
27+
with:
28+
app_id: ${{ secrets.APP_ID }}
29+
private_key: ${{ secrets.PRIVATE_KEY }}
30+
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Extract version
35+
run: |
36+
set -euo pipefail
37+
git fetch --tags --force
38+
39+
echo "=== TAGS IN REPO (sorted) ==="
40+
git tag -l --sort=-version:refname | cat
41+
42+
echo
43+
echo "=== Searching latest tags for module '${{ env.MODULE }}' ==="
44+
APP_VERSION="$(
45+
git tag -l '${{ env.MODULE }}/*' --sort=-version:refname \
46+
| head -n1 || true
47+
)"
48+
echo "Raw APP_VERSION tag: '${APP_VERSION}'"
49+
50+
CHART_VERSION="$(
51+
git tag -l '${{ env.MODULE }}-chart/*' --sort=-version:refname \
52+
| head -n1 || true
53+
)"
54+
echo "Raw CHART_VERSION tag: '${CHART_VERSION}'"
55+
56+
echo
57+
echo "=== Applying fallbacks if empty ==="
58+
APP_VERSION="${APP_VERSION:-${{ env.MODULE }}/0.0.1}"
59+
CHART_VERSION="${CHART_VERSION:-${{ env.MODULE }}-chart/0.0.1}"
60+
echo "After fallback → APP_VERSION='${APP_VERSION}'"
61+
echo "After fallback → CHART_VERSION='${CHART_VERSION}'"
62+
63+
echo
64+
echo "=== Stripping prefix (keep only part after last '/') ==="
65+
APP_VERSION="${APP_VERSION##*/}"
66+
CHART_VERSION="${CHART_VERSION##*/}"
67+
echo "After strip → APP_VERSION='${APP_VERSION}'"
68+
echo "After strip → CHART_VERSION='${CHART_VERSION}'"
69+
70+
{
71+
echo "APP_VERSION=$APP_VERSION"
72+
echo "CHART_VERSION=$CHART_VERSION"
73+
} >> "$GITHUB_ENV"
74+
75+
- name: Echo
76+
run: |
77+
echo "APP_VERSION=${{ env.APP_VERSION }}"
78+
echo "CHART_VERSION=${{ env.CHART_VERSION }}"
79+
80+
- name: Replace CHART_VERSION in chart/Chart.yaml
81+
run: sed -i 's/CHART_VERSION/${{ env.CHART_VERSION }}/g' ./${{ env.MODULE }}-chart/Chart.yaml
82+
83+
- name: Replace APP_VERSION in Chart.yaml
84+
run: sed -i 's/APP_VERSION/${{ env.APP_VERSION }}/g' ./${{ env.MODULE }}-chart/Chart.yaml
85+
86+
- name: Set up Helm
87+
uses: azure/setup-helm@v4.1.0
88+
89+
- name: Helm lint chart
90+
run: helm lint ./${{ env.MODULE }}-chart
91+
92+
- name: Create k8s Kind Cluster
93+
uses: helm/kind-action@v1
94+
with:
95+
node_image: kindest/node:${{ matrix.k8s_version }}
96+
97+
- name: Install eventrouter with standard configuration
98+
run: |
99+
helm repo add krateo https://charts.krateo.io
100+
helm repo update krateo
101+
helm install eventrouter krateo/eventrouter --create-namespace -n krateo-system --wait
102+
103+
- name: Install eventsse-etcd with standard configuration
104+
run: helm install eventsse-etcd krateo/etcd --create-namespace -n krateo-system --wait
105+
106+
- name: Install chart with standard configuration
107+
run: helm install ${{ env.MODULE }} ./${{ env.MODULE }}-chart --create-namespace -n krateo-system --wait --timeout=120s
108+
109+
- name: Wait for deployment to become Available
110+
run: kubectl wait deployment ${{ env.MODULE }} --for condition=Available=True --timeout=120s --namespace krateo-system
111+
112+
- name: Helm list -A
113+
if: always()
114+
run: helm list -A
115+
116+
- name: Get deployments -A
117+
if: always()
118+
run: kubectl get deployments -A
119+
120+
- name: Get events -A
121+
if: always()
122+
run: kubectl get events -A --sort-by='.lastTimestamp'

eventsse-chart/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ spec:
3131
securityContext:
3232
{{- toYaml .Values.podSecurityContext | nindent 8 }}
3333
containers:
34-
- name: {{ .Chart.Name }}
34+
- name: {{ include "eventsse.fullname" . }}
3535
envFrom:
3636
- configMapRef:
3737
name: {{ include "eventsse.fullname" . }}

eventsse-chart/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ env:
117117
etcd:
118118
service:
119119
name: eventsse-etcd
120-
port: 2379
120+
port: 2379

sweeper-chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

sweeper-chart/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: sweeper
3+
description: A Helm chart for cleanup of Krateo Server-Side Event etcd
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: CHART_VERSION
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: APP_VERSION

sweeper-chart/templates/NOTES.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.httpRoute.enabled }}
3+
{{- if .Values.httpRoute.hostnames }}
4+
export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }}
5+
{{- else }}
6+
export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}")
7+
{{- end }}
8+
{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }}
9+
echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application"
10+
11+
NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules.
12+
The rules can be set for path, method, header and query parameters.
13+
You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml'
14+
{{- end }}
15+
{{- else if .Values.ingress.enabled }}
16+
{{- range $host := .Values.ingress.hosts }}
17+
{{- range .paths }}
18+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
19+
{{- end }}
20+
{{- end }}
21+
{{- else if contains "NodePort" .Values.service.type }}
22+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "sweeper.fullname" . }})
23+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
24+
echo http://$NODE_IP:$NODE_PORT
25+
{{- else if contains "LoadBalancer" .Values.service.type }}
26+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
27+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "sweeper.fullname" . }}'
28+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "sweeper.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
29+
echo http://$SERVICE_IP:{{ .Values.service.port }}
30+
{{- else if contains "ClusterIP" .Values.service.type }}
31+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "sweeper.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
32+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
33+
echo "Visit http://127.0.0.1:8080 to use your application"
34+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
35+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "sweeper.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "sweeper.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "sweeper.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "sweeper.labels" -}}
37+
helm.sh/chart: {{ include "sweeper.chart" . }}
38+
{{ include "sweeper.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "sweeper.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "sweeper.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "sweeper.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "sweeper.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "sweeper.fullname" . }}
5+
labels:
6+
{{- include "sweeper.labels" . | nindent 4 }}
7+
data:
8+
PORT: "{{ .Values.service.port }}"
9+
{{- range $key, $value := .Values.env }}
10+
{{ $key }}: {{ $value | quote }}
11+
{{- end }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "sweeper.fullname" . }}
5+
labels:
6+
{{- include "sweeper.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "sweeper.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "sweeper.labels" . | nindent 8 }}
22+
{{- with .Values.podLabels }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
spec:
26+
{{- with .Values.imagePullSecrets }}
27+
imagePullSecrets:
28+
{{- toYaml . | nindent 8 }}
29+
{{- end }}
30+
serviceAccountName: {{ include "sweeper.serviceAccountName" . }}
31+
{{- with .Values.podSecurityContext }}
32+
securityContext:
33+
{{- toYaml . | nindent 8 }}
34+
{{- end }}
35+
containers:
36+
- name: {{ .Chart.Name }}
37+
{{- with .Values.securityContext }}
38+
securityContext:
39+
{{- toYaml . | nindent 12 }}
40+
{{- end }}
41+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
42+
imagePullPolicy: {{ .Values.image.pullPolicy }}
43+
args:
44+
- --etcd-servers={{ .Values.etcd.service.name }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.etcd.service.port }}
45+
ports:
46+
- name: http
47+
containerPort: {{ .Values.service.port }}
48+
protocol: TCP
49+
{{- with .Values.livenessProbe }}
50+
livenessProbe:
51+
{{- toYaml . | nindent 12 }}
52+
{{- end }}
53+
{{- with .Values.readinessProbe }}
54+
readinessProbe:
55+
{{- toYaml . | nindent 12 }}
56+
{{- end }}
57+
{{- with .Values.resources }}
58+
resources:
59+
{{- toYaml . | nindent 12 }}
60+
{{- end }}
61+
{{- with .Values.volumeMounts }}
62+
volumeMounts:
63+
{{- toYaml . | nindent 12 }}
64+
{{- end }}
65+
{{- with .Values.volumes }}
66+
volumes:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
{{- with .Values.nodeSelector }}
70+
nodeSelector:
71+
{{- toYaml . | nindent 8 }}
72+
{{- end }}
73+
{{- with .Values.affinity }}
74+
affinity:
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}
77+
{{- with .Values.tolerations }}
78+
tolerations:
79+
{{- toYaml . | nindent 8 }}
80+
{{- end }}

0 commit comments

Comments
 (0)