Skip to content

Commit eb362c9

Browse files
committed
feat: add patchbay
1 parent fd34f2b commit eb362c9

16 files changed

+518
-1
lines changed

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"flavor-adventure": "1.1.1",
33
"minight-core": "0.0.0",
4-
"midnight-core": "1.1.13"
4+
"midnight-core": "1.1.13",
5+
"patchbay": "0.0.0"
56
}

patchbay/Chart.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v2
2+
name: patchbay
3+
description: Run patchbay on Kubernetes
4+
5+
type: application
6+
7+
version: 1.0.0
8+
9+
appVersion: "latest"

patchbay/templates/_helpers.tpl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "patchbay.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 "patchbay.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 "patchbay.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "patchbay.labels" -}}
37+
helm.sh/chart: {{ include "patchbay.chart" . }}
38+
{{ include "patchbay.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 "patchbay.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "patchbay.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 "patchbay.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "patchbay.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Generate imagePullSecret
66+
*/}}
67+
{{- define "imagePullSecret" }}
68+
{{- with .Values.imageCredentials }}
69+
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" (required "imageCredentials.registry is required when imageCredentials.enabled = true" .registry) (required "imageCredentials.username is required when imageCredentials.enabled = true" .username) (required "imageCredentials.password is required when imageCredentials.enabled = true" .password) (required "imageCredentials.email is required when imageCredentials.enabled = true" .email) (printf "%s:%s" .username (required "imageCredentials.password is required when imageCredentials.enabled = true" .password) | b64enc) | b64enc }}
70+
{{- end }}
71+
{{- end }}

patchbay/templates/ingress.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "patchbay.fullname" . }}-ingress
6+
labels:
7+
{{- include "patchbay.labels" . | nindent 4 }}
8+
annotations:
9+
{{- with .Values.ingress.annotations }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- if .Values.ingress.className }}
14+
ingressClassName: {{ .Values.ingress.className }}
15+
{{- end }}
16+
{{- if .Values.ingress.tls }}
17+
tls:
18+
- hosts:
19+
- {{ .Values.domainName }}
20+
secretName: {{ .Values.ingress.secretName }}
21+
{{- end }}
22+
rules:
23+
- host: {{ .Values.domainName }}
24+
http:
25+
paths:
26+
- path: /api
27+
pathType: Prefix
28+
backend:
29+
service:
30+
name: {{ include "patchbay.fullname" . }}-patchbay-backend
31+
port:
32+
number: {{ .Values.patchbayBackend.service.port }}
33+
- path: /
34+
pathType: Prefix
35+
backend:
36+
service:
37+
name: {{ include "patchbay.fullname" . }}-patchbay-frontend
38+
port:
39+
number: {{ .Values.patchbayFrontend.service.port }}
40+
{{- end }}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "patchbay.fullname" . }}-patchbay-backend
5+
labels:
6+
{{- include "patchbay.labels" . | nindent 4 }}
7+
role: patchbay-backend
8+
spec:
9+
replicas: {{ .Values.patchbayBackend.replicaCount }}
10+
selector:
11+
matchLabels:
12+
{{- include "patchbay.selectorLabels" . | nindent 6 }}
13+
role: patchbay-backend
14+
template:
15+
metadata:
16+
annotations:
17+
checksum/config: {{ (include (print $.Template.BasePath "/patchbay-backend-env.yaml") .) | sha256sum }}
18+
checksum/secret: {{ (include (print $.Template.BasePath "/patchbay-backend-secret-env.yaml") .) | sha256sum }}
19+
{{- if .Values.forceRedeploy }}
20+
forceRedeploy: {{ randAlphaNum 10 | quote }}
21+
{{- end }}
22+
{{- with .Values.patchbayBackend.podAnnotations }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
labels:
26+
{{- include "patchbay.selectorLabels" . | nindent 8 }}
27+
role: patchbay-backend
28+
spec:
29+
{{- if or .Values.imageCredentials.enabled .Values.imagePullSecrets }}
30+
imagePullSecrets:
31+
{{- if .Values.imageCredentials.enabled }}
32+
- name: {{ include "patchbay.fullname" . }}-pull-secret
33+
{{- end }}
34+
{{- with .Values.imagePullSecrets }}
35+
{{- toYaml . | nindent 8 }}
36+
{{- end }}
37+
{{- end }}
38+
serviceAccountName: {{ include "patchbay.serviceAccountName" . }}
39+
securityContext:
40+
{{- toYaml .Values.patchbayBackend.podSecurityContext | nindent 8 }}
41+
containers:
42+
- name: {{ .Chart.Name }}-patchbay-backend
43+
securityContext:
44+
{{- toYaml .Values.patchbayBackend.securityContext | nindent 12 }}
45+
image: "{{ .Values.patchbayBackend.image.repository }}:{{ .Values.patchbayBackend.image.tag | default .Values.appVersion }}"
46+
imagePullPolicy: {{ .Values.patchbayBackend.image.pullPolicy }}
47+
envFrom:
48+
- configMapRef:
49+
name: {{ include "patchbay.fullname" . }}-env-patchbay-backend
50+
- secretRef:
51+
name: {{ include "patchbay.fullname" . }}-secret-env-patchbay-backend
52+
{{- if .Values.patchbayBackend.externalConfigMapName }}
53+
- configMapRef:
54+
name: {{ .Values.patchbayBackend.externalConfigMapName }}
55+
{{- end }}
56+
{{- if .Values.patchbayBackend.externalSecretName }}
57+
- secretRef:
58+
name: {{ .Values.patchbayBackend.externalSecretName }}
59+
{{- end }}
60+
{{- if .Values.patchbayBackend.extraEnvVars }}
61+
env:
62+
{{- include "common.tplvalues.render" (dict "value" .Values.patchbayBackend.extraEnvVars "context" $) | nindent 12 }}
63+
{{- end }}
64+
ports:
65+
- name: http
66+
containerPort: {{ .Values.patchbayBackend.service.port }}
67+
protocol: TCP
68+
resources:
69+
{{- toYaml .Values.patchbayBackend.resources | nindent 12 }}
70+
{{- with .Values.patchbayBackend.nodeSelector }}
71+
nodeSelector:
72+
{{- toYaml . | nindent 8 }}
73+
{{- end }}
74+
{{- with .Values.patchbayBackend.affinity }}
75+
affinity:
76+
{{- toYaml . | nindent 8 }}
77+
{{- end }}
78+
{{- with .Values.patchbayBackend.tolerations }}
79+
tolerations:
80+
{{- toYaml . | nindent 8 }}
81+
{{- 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 "patchbay.fullname" . }}-env-patchbay-backend
5+
labels:
6+
{{- include "patchbay.labels" . | nindent 4 }}
7+
role: patchbay-backend
8+
data:
9+
{{- range $key, $value := .Values.patchbayBackend.env }}
10+
{{ $key }}: {{ $value | quote }}
11+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "patchbay.fullname" . }}-secret-env-patchbay-backend
5+
labels:
6+
{{- include "patchbay.labels" . | nindent 4 }}
7+
role: patchbay-backend
8+
type: Opaque
9+
data:
10+
{{- range $key, $value := .Values.patchbayBackend.secretEnv }}
11+
{{ $key }}: {{ $value | b64enc | quote }}
12+
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "patchbay.fullname" . }}-patchbay-backend
5+
labels:
6+
{{- include "patchbay.labels" . | nindent 4 }}
7+
role: patchbay-backend
8+
spec:
9+
type: {{ .Values.patchbayBackend.service.type }}
10+
ports:
11+
- port: {{ .Values.patchbayBackend.service.port }}
12+
targetPort: http
13+
protocol: TCP
14+
name: http
15+
selector:
16+
{{- include "patchbay.selectorLabels" . | nindent 4 }}
17+
role: patchbay-backend
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "patchbay.fullname" . }}-patchbay-frontend
5+
labels:
6+
{{- include "patchbay.labels" . | nindent 4 }}
7+
role: patchbay-frontend
8+
spec:
9+
replicas: {{ .Values.patchbayFrontend.replicaCount }}
10+
selector:
11+
matchLabels:
12+
{{- include "patchbay.selectorLabels" . | nindent 6 }}
13+
role: patchbay-frontend
14+
template:
15+
metadata:
16+
annotations:
17+
checksum/config: {{ (include (print $.Template.BasePath "/patchbay-frontend-env.yaml") .) | sha256sum }}
18+
checksum/secret: {{ (include (print $.Template.BasePath "/patchbay-frontend-secret-env.yaml") .) | sha256sum }}
19+
{{- if .Values.forceRedeploy }}
20+
forceRedeploy: {{ randAlphaNum 10 | quote }}
21+
{{- end }}
22+
{{- with .Values.patchbayFrontend.podAnnotations }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
labels:
26+
{{- include "patchbay.selectorLabels" . | nindent 8 }}
27+
role: patchbay-frontend
28+
spec:
29+
{{- if or .Values.imageCredentials.enabled .Values.imagePullSecrets }}
30+
imagePullSecrets:
31+
{{- if .Values.imageCredentials.enabled }}
32+
- name: {{ include "patchbay.fullname" . }}-pull-secret
33+
{{- end }}
34+
{{- with .Values.imagePullSecrets }}
35+
{{- toYaml . | nindent 8 }}
36+
{{- end }}
37+
{{- end }}
38+
serviceAccountName: {{ include "patchbay.serviceAccountName" . }}
39+
securityContext:
40+
{{- toYaml .Values.patchbayFrontend.podSecurityContext | nindent 8 }}
41+
containers:
42+
- name: {{ .Chart.Name }}-patchbay-frontend
43+
securityContext:
44+
{{- toYaml .Values.patchbayFrontend.securityContext | nindent 12 }}
45+
image: "{{ .Values.patchbayFrontend.image.repository }}:{{ .Values.patchbayFrontend.image.tag | default .Values.appVersion }}"
46+
imagePullPolicy: {{ .Values.patchbayFrontend.image.pullPolicy }}
47+
envFrom:
48+
- configMapRef:
49+
name: {{ include "patchbay.fullname" . }}-env-patchbay-frontend
50+
- secretRef:
51+
name: {{ include "patchbay.fullname" . }}-secret-env-patchbay-frontend
52+
{{- if .Values.patchbayFrontend.externalConfigMapName }}
53+
- configMapRef:
54+
name: {{ .Values.patchbayFrontend.externalConfigMapName }}
55+
{{- end }}
56+
{{- if .Values.patchbayFrontend.externalSecretName }}
57+
- secretRef:
58+
name: {{ .Values.patchbayFrontend.externalSecretName }}
59+
{{- end }}
60+
{{- if .Values.patchbayFrontend.extraEnvVars }}
61+
env:
62+
{{- include "common.tplvalues.render" (dict "value" .Values.patchbayFrontend.extraEnvVars "context" $) | nindent 12 }}
63+
{{- end }}
64+
ports:
65+
- name: http
66+
containerPort: {{ .Values.patchbayFrontend.service.port }}
67+
protocol: TCP
68+
livenessProbe:
69+
httpGet:
70+
path: /
71+
port: http
72+
readinessProbe:
73+
httpGet:
74+
path: /
75+
port: http
76+
resources:
77+
{{- toYaml .Values.patchbayFrontend.resources | nindent 12 }}
78+
{{- with .Values.patchbayFrontend.nodeSelector }}
79+
nodeSelector:
80+
{{- toYaml . | nindent 8 }}
81+
{{- end }}
82+
{{- with .Values.patchbayFrontend.affinity }}
83+
affinity:
84+
{{- toYaml . | nindent 8 }}
85+
{{- end }}
86+
{{- with .Values.patchbayFrontend.tolerations }}
87+
tolerations:
88+
{{- toYaml . | nindent 8 }}
89+
{{- 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 "patchbay.fullname" . }}-env-patchbay-frontend
5+
labels:
6+
{{- include "patchbay.labels" . | nindent 4 }}
7+
role: patchbay-frontend
8+
data:
9+
{{- range $key, $value := .Values.patchbayFrontend.env }}
10+
{{ $key }}: {{ $value | quote }}
11+
{{- end }}

0 commit comments

Comments
 (0)