Skip to content

Commit 61ee24c

Browse files
authored
feat: add helm chart (#5)
1 parent 4d1ed0f commit 61ee24c

File tree

13 files changed

+417
-5
lines changed

13 files changed

+417
-5
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
permissions: read-all
1717

1818
jobs:
19-
release:
19+
chart-releaser:
2020
name: Create Release 🥇
2121
permissions:
2222
contents: write
@@ -25,6 +25,48 @@ jobs:
2525
run:
2626
shell: bash
2727
runs-on: ubuntu-latest
28+
steps:
29+
- name: Get branch names 🌿
30+
id: branch-name
31+
uses: tj-actions/branch-names@v7
32+
with:
33+
strip_tag_prefix: v
34+
35+
- name: Checkout Repo 🛎
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
40+
- name: Set chart-releaser configuration ⚙️
41+
run: |
42+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
43+
git config --global user.name "github-actions[bot]"
44+
# Override the default chart-releaser release name.
45+
cat << EOF > chart-releaser-config.yaml
46+
release-name-template: "v{{ .Version }}"
47+
EOF
48+
yq e -i '.version = "${{ steps.branch-name.outputs.tag }}"' helm/templates/Chart.yaml
49+
yq e -i '.appVersion = "${{ steps.branch-name.outputs.tag }}"' helm/templates/Chart.yaml
50+
51+
- name: Run chart-releaser ⛵
52+
uses: helm/chart-releaser-action@v1.7.0
53+
with:
54+
charts_dir: helm
55+
config: chart-releaser-config.yaml
56+
env:
57+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
58+
59+
# goreleaser runs in a separate job because it needs a clean git state.
60+
goreleaser:
61+
needs: chart-releaser
62+
name: Run goreleaser 🐹
63+
permissions:
64+
contents: write
65+
packages: write
66+
defaults:
67+
run:
68+
shell: bash
69+
runs-on: ubuntu-latest
2870
steps:
2971
- name: Checkout Repo 🛎
3072
uses: actions/checkout@v4
@@ -54,3 +96,4 @@ jobs:
5496
env:
5597
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5698

99+

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,3 @@ linters-settings:
2727
gocyclo:
2828
# minimal code complexity to report, 30 by default
2929
min-complexity: 15
30-
maligned:
31-
# print struct with more effective memory layout or not, false by default
32-
suggest-new: true

.goreleaser.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ kos:
2828
- repositories:
2929
- "ghcr.io/insightsengineering/oasbinder"
3030
tags:
31-
- "v{{.Version}}"
31+
- "{{.Version}}"
3232
- latest
3333
bare: true
3434
preserve_import_paths: false
@@ -42,3 +42,6 @@ kos:
4242
"org.opencontainers.image.title": "{{ .ProjectName }}"
4343
"org.opencontainers.image.revision": "{{ .FullCommit }}"
4444
"org.opencontainers.image.version": "{{ .Version }}"
45+
# Append release notes to the release created by chart-releaser-action.
46+
release:
47+
mode: append

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ Alternatively, if you have a Go environment, you can simply install `oasbinder`
3434
go install github.com/insightsengineering/oasbinder@latest
3535
```
3636

37+
A helm chart is also available. You can install the `oasbinder` helm chart with:
38+
39+
```bash
40+
helm install oasbinder -f helm/templates/values.yaml oasbinder --repo https://insightsengineering.github.io/oasbinder/ --version 0.0.3 --namespace <namespace-name>
41+
```
42+
43+
Example `values.yaml` file is available in [helm/templates/values.yaml](helm/templates/values.yaml).
44+
3745
## Usage
3846

3947
`oasbinder` is a command line utility, so after installing the binary in your `PATH`, simply run the following command to view its capabilities:

helm/templates/.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/

helm/templates/Chart.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v2
2+
name: oasbinder
3+
description: A Helm chart for Kubernetes
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+
# Version is set to git tag dynamically by .github/workflows/release.yml.
16+
# version:
17+
18+
# Version is set to git tag dynamically by .github/workflows/release.yml.
19+
# appVersion:

helm/templates/templates/NOTES.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oasbinder.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oasbinder.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oasbinder.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oasbinder.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- 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 "oasbinder.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 "oasbinder.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 "oasbinder.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "oasbinder.labels" -}}
37+
helm.sh/chart: {{ include "oasbinder.chart" . }}
38+
{{ include "oasbinder.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 "oasbinder.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "oasbinder.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 "oasbinder.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "oasbinder.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "oasbinder.fullname" . }}
5+
labels:
6+
app: {{ include "oasbinder.fullname" . }}
7+
data:
8+
oasbinder.yaml: |
9+
{{- toYaml .Values.oasbinderConfig | nindent 4 }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "oasbinder.fullname" . }}
5+
labels:
6+
app: {{ include "oasbinder.fullname" . }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
app: {{ include "oasbinder.fullname" . }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
app: {{ include "oasbinder.fullname" . }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
securityContext:
28+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
29+
containers:
30+
- name: {{ .Chart.Name }}
31+
securityContext:
32+
{{- toYaml .Values.securityContext | nindent 12 }}
33+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
34+
imagePullPolicy: {{ .Values.image.pullPolicy }}
35+
ports:
36+
- name: http
37+
containerPort: {{ .Values.service.port }}
38+
protocol: TCP
39+
{{- with .Values.args }}
40+
args:
41+
{{- toYaml . | nindent 12 }}
42+
{{- end }}
43+
livenessProbe:
44+
{{- toYaml .Values.livenessProbe | nindent 12 }}
45+
readinessProbe:
46+
{{- toYaml .Values.readinessProbe | nindent 12 }}
47+
resources:
48+
{{- toYaml .Values.resources | nindent 12 }}
49+
{{- with .Values.volumeMounts }}
50+
volumeMounts:
51+
{{- toYaml . | nindent 12 }}
52+
{{- end }}
53+
{{- with .Values.volumes }}
54+
volumes:
55+
{{- toYaml . | nindent 8 }}
56+
{{- end }}

0 commit comments

Comments
 (0)