Skip to content

Commit

Permalink
Merge pull request #30 from giubacc/helm-charts
Browse files Browse the repository at this point in the history
add Helm chart
  • Loading branch information
Giuseppe Baccini committed May 9, 2023
2 parents 9ce5b01 + 8c0ae95 commit 6fb02d1
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"MD033": {
"allowed_elements": [
"details",
"summary",
"img",
"h1"
]
},
"MD024": {
"siblings_only": true
}
}
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ repos:
hooks:
- id: trailing-whitespace
- id: check-yaml
exclude: ^charts/chatterbox/templates/.*.yaml$
- id: check-added-large-files
- id: end-of-file-fixer
- id: debug-statements
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog][1],
and this project adheres to [Semantic Versioning][2].

## [0.2.0] - UNRELEASED

## [0.1.0] - 2023-02-03

- Initial version.

[1]: https://keepachangelog.com/en/1.0.0/
[2]: https://semver.org/spec/v2.0.0.html
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# chatterbox

<h1 align="left"><img alt="chatterbox-logo" src="./assets/images/cbox-logo.png"/>
</h1>

![License](https://img.shields.io/github/license/giubacc/chatterbox)
![Lint](https://github.com/giubacc/chatterbox/actions/workflows/lint.yaml/badge.svg)
![Builder Image](https://github.com/giubacc/chatterbox/actions/workflows/build-builder.yaml/badge.svg)
Expand Down
Binary file added assets/images/cbox-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions charts/chatterbox/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: v2
name: chatterbox
version: 0.2.0
kubeVersion: ">=1.14"
description: |
A tool for composing generic RESTful conversations.
type: application
keywords:
- RESTful
home: https://github.com/giubacc/chatterbox
icon: |-
https://raw.githubusercontent.com/giubacc/chatterbox/assets/images/cbox-logo.png
sources:
- https://github.com/giubacc/chatterbox
maintainers:
- name: Giuseppe Baccini
email: giuseppe.baccini@suse.com
appVersion: "latest"
deprecated: false
5 changes: 5 additions & 0 deletions charts/chatterbox/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Thank you for installing {{ .Chart.Name }} {{ printf "v%s" .Chart.Version }}

The chatterbox endpoint is available at:

{{ printf "%s.%s" (include "chatterbox.serviceName" .) .Values.backend.publicDomain | indent 4 }}
76 changes: 76 additions & 0 deletions charts/chatterbox/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chatterbox.name" -}}
{{- .Chart.Name }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "chatterbox.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{- define "chatterbox.commonSelectorLabels" -}}
app.kubernetes.io/name: {{ include "chatterbox.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "chatterbox.selectorLabels" -}}
{{ include "chatterbox.commonSelectorLabels" . }}
app.kubernetes.io/component: application
{{- end }}

{{- define "chatterbox-ui.selectorLabels" -}}
{{ include "chatterbox.commonSelectorLabels" . }}
app.kubernetes.io/component: ui
{{- end }}

{{/*
Version helpers for the image tag
*/}}
{{- define "chatterbox.image" -}}
{{- $defaulttag := printf "v%s" .Chart.Version }}
{{- $tag := default $defaulttag .Values.backend.imageTag }}
{{- $name := default "giubacc/chatterbox" .Values.backend.imageName }}
{{- $registry := default "ghcr.io" .Values.backend.imageRegistry }}
{{- printf "%s/%s:%s" $registry $name $tag }}
{{- end }}

{{- define "chatterbox-ui.image" -}}
{{- $tag := default (printf "v%s" .Chart.Version) .Values.ui.imageTag }}
{{- $name := default "giubacc/chatterbox-ui" .Values.ui.imageName }}
{{- $registry := default "ghcr.io" .Values.ui.imageRegistry }}
{{- printf "%s/%s:%s" $registry $name $tag }}
{{- end }}

{{/*
Traefik Middleware CORS name
*/}}
{{- define "chatterbox.CORSMiddlewareName" -}}
{{- $dmcn := printf "%s-%s-cors-header" .Release.Name .Release.Namespace }}
{{- $name := $dmcn }}
{{- $name }}
{{- end }}

{{/*
Backend service name
*/}}
{{- define "chatterbox.serviceName" -}}
{{- $dsn := printf "%s-%s" .Release.Name .Release.Namespace }}
{{- $name := default $dsn .Values.backend.serviceName }}
{{- $name }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/chatterbox/templates/chart-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if and (.Values.backend.ingress.enabled) (empty .Values.backend.publicDomain) }}
{{- fail "Please provide a value for `.Values.backend.publicDomain`." }}
{{- end }}
48 changes: 48 additions & 0 deletions charts/chatterbox/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "chatterbox.labels" . | indent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{ include "chatterbox.selectorLabels" . | indent 6 }}
strategy:
type: Recreate
template:
metadata:
labels:
{{ include "chatterbox.selectorLabels" . | indent 8 }}
spec:
containers:
- name: {{ .Release.Name }}
image: {{ include "chatterbox.image" . | quote }}
imagePullPolicy: {{ default "IfNotPresent" .Values.backend.imagePullPolicy }}
args:
- "-d"
- "--endpoint-port"
- "8080"
- "-v"
- "t"
{{- range $.Values.backend.customArgs }}
- {{ . | quote}}
{{- end }}
env:
{{- range $.Values.backend.customEnvs }}
{{- if (regexMatch "[^=]+=[^=]+" .) }}
{{- $tokens := split "=" . }}
- name: {{ $tokens._0 }}
value: {{ $tokens._1 | quote}}
{{- else if (regexMatch "^[^=]" .) }}
- name: {{ . }}
{{- else }}
{{- fail (print ".Values.backend.customEnvs contains an invalid entry: " .) }}
{{- end }}
{{- end }}
ports:
- containerPort: 8080
name: cbox-plain
50 changes: 50 additions & 0 deletions charts/chatterbox/templates/ingress-traefik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- if .Values.backend.ingress.enabled }}
---
# Backend Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: '{{ .Release.Name }}-no-tls'
namespace: {{ .Release.Namespace }}
labels:
{{ include "chatterbox.labels" . | indent 4 }}
annotations:
traefik.ingress.kubernetes.io/router.middlewares:
'{{ .Release.Namespace }}-{{ include "chatterbox.CORSMiddlewareName" . }}@kubernetescrd'
spec:
rules:
- host: '{{ include "chatterbox.serviceName" . }}.{{ .Values.backend.publicDomain }}'
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: '{{ include "chatterbox.serviceName" . }}'
port:
number: 80
---
# Middleware for Traefik
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: {{ include "chatterbox.CORSMiddlewareName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "chatterbox.labels" . | indent 4 }}
spec:
headers:
accessControlAllowMethods:
- "DELETE"
- "GET"
- "HEAD"
- "POST"
- "PUT"
- "OPTIONS"
accessControlAllowOriginList:
- "*"
accessControlAllowHeaders:
- "*"
accessControlExposeHeaders:
- "*"
{{- end }}
16 changes: 16 additions & 0 deletions charts/chatterbox/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
name: '{{ include "chatterbox.serviceName" . }}'
namespace: {{ .Release.Namespace }}
labels:
{{ include "chatterbox.labels" . | indent 4 }}
spec:
selector:
{{ include "chatterbox.selectorLabels" . | indent 4 }}
ports:
- name: cbox-plain
protocol: TCP
port: 80
targetPort: cbox-plain
11 changes: 11 additions & 0 deletions charts/chatterbox/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
backend:
ingress:
enabled: true
serviceName: ""
publicDomain: ""
customArgs: []
customEnvs: []
imageName:
imageTag:
imageRegistry:
imagePullPolicy:
4 changes: 2 additions & 2 deletions examples/endpoint/endp-ping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ after:
function: onScenarioAfter
args: [one, 2, three]
conversations:
- host: localhost:8080
- host: http://cbox-cbox.127.0.0.1.omg.howdoi.website/
requests:
- method: PUT
uri: document
data:
conversations:
- host: localhost:8081
- host: cbox-cbox.cbox.svc.cluster.local
requests:
- method: PUT
uri: echo
Expand Down

0 comments on commit 6fb02d1

Please sign in to comment.