Skip to content

Commit 5125258

Browse files
authored
Merge pull request #27 from soketi/new-chart/k8soketi
soketi/k8soketi
2 parents 1175fe5 + 9fe297c commit 5125258

17 files changed

+817
-0
lines changed

charts/k8soketi/.helmignore

+23
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/

charts/k8soketi/Chart.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v2
2+
name: k8soketi
3+
description: Run soketi/k8soketi in your Kubernetes cluster using this Helm chart.
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: 1.0.0
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+
appVersion: 1.0.0

charts/k8soketi/README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
k8soketi Server Chart
2+
===================
3+
4+
Containerize & Orchestrate your k8soketi application with this simple Helm chart.
5+
6+
## 🤝 Supporting
7+
8+
**If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, sponsor our work with [Github Sponsors](https://github.com/sponsors/rennokki). 📦**
9+
10+
## 🛑 Requirements
11+
12+
- Kubernetes v1.19+
13+
14+
## 🚀 Installation
15+
16+
Install Helm chart repository:
17+
18+
```bash
19+
$ helm repo add k8soketi https://helm.soketi.app
20+
$ helm repo update
21+
```
22+
23+
Install the k8soketi chart:
24+
25+
```bash
26+
$ helm upgrade k8soketi \
27+
--install \
28+
--version=1.0.0 \
29+
soketi/k8soketi
30+
```
31+
32+
Check `values.yaml` for additional available customizations.
33+
34+
## 🐛 Testing
35+
36+
Coming soon.
37+
38+
## 🤝 Contributing
39+
40+
Please see [CONTRIBUTING](../../CONTRIBUTING.md) for details.
41+
42+
## 🔒 Security
43+
44+
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
45+
46+
## 🎉 Credits
47+
48+
- [Alex Renoki](https://github.com/rennokki)
49+
- [All Contributors](../../../../contributors)

charts/k8soketi/templates/NOTES.txt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{- if .Values.ingress.enabled }}
2+
The application is available at these URLs:
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
Get the application URL by running these commands:
10+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "soketi.fullname" . }})
11+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
12+
echo http://$NODE_IP:$NODE_PORT
13+
{{- else if contains "LoadBalancer" .Values.service.type }}
14+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
15+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "soketi.fullname" . }}'
16+
Get the application URL by running these commands:
17+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "soketi.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
18+
echo http://$SERVICE_IP:{{ .Values.service.port }}
19+
{{- else if contains "ClusterIP" .Values.service.type }}
20+
Get the application URL by running these commands:
21+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "soketi.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
22+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
23+
echo "Visit http://127.0.0.1:{{ .Values.service.port }} to use your application"
24+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME {{ .Values.service.port }}:$CONTAINER_PORT
25+
{{- end }}
26+
27+
{{- if or .Values.metrics.enabled .Values.serviceMonitor.enabled }}
28+
Metrics: The Prometheus metrics are enabled on port {{ .Values.metrics.service.port }}.
29+
{{- end }}
30+
The pods can discovery each other using WebSockets with the port {{ .Values.peerServer.service.port }}.
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "soketi.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 "soketi.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 "soketi.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "soketi.labels" -}}
37+
helm.sh/chart: {{ include "soketi.chart" . }}
38+
{{ include "soketi.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 "soketi.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "soketi.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
app: soketi
52+
{{- end }}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "soketi.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create }}
59+
{{- default (include "soketi.fullname" .) .Values.serviceAccount.name }}
60+
{{- else }}
61+
{{- default "default" .Values.serviceAccount.name }}
62+
{{- end }}
63+
{{- end }}
+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "soketi.fullname" . }}
5+
labels:
6+
{{- include "soketi.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
{{- with .Values.strategy }}
12+
strategy:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
selector:
16+
matchLabels:
17+
{{- include "soketi.selectorLabels" . | nindent 6 }}
18+
{{- if or .Values.metrics.enabled .Values.serviceMonitor.enabled }}
19+
k8s.soketi.app/serves-metrics: "yes"
20+
{{- end }}
21+
template:
22+
metadata:
23+
{{- with .Values.podAnnotations }}
24+
annotations:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
labels:
28+
{{- include "soketi.selectorLabels" . | nindent 8 }}
29+
{{- if or .Values.metrics.enabled .Values.serviceMonitor.enabled }}
30+
k8s.soketi.app/serves-metrics: "yes"
31+
{{- end }}
32+
spec:
33+
{{- with .Values.extraVolumes }}
34+
volumes:
35+
{{- toYaml . | nindent 8 }}
36+
{{- end }}
37+
38+
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
39+
40+
{{- if .Values.app.multicast.enabled }}
41+
hostNetwork: {{ .Values.app.multicast.hostNetwork }}
42+
dnsPolicy: {{ .Values.app.multicast.dnsPolicy }}
43+
{{- end }}
44+
45+
{{- with .Values.imagePullSecrets }}
46+
imagePullSecrets:
47+
{{- toYaml . | nindent 8 }}
48+
{{- end }}
49+
50+
serviceAccountName: {{ include "soketi.serviceAccountName" . }}
51+
52+
securityContext:
53+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
54+
55+
{{- with .Values.extraInitContainers }}
56+
initContainers:
57+
{{- toYaml . | nindent 8 }}
58+
{{- end }}
59+
60+
containers:
61+
{{- with .Values.extraContainers }}
62+
{{- toYaml . | nindent 8 }}
63+
{{- end }}
64+
- name: {{ .Chart.Name }}
65+
securityContext:
66+
{{- toYaml .Values.securityContext | nindent 12 }}
67+
image: "{{ .Values.app.image.repository }}:{{ .Values.app.image.tag | default .Chart.AppVersion }}"
68+
imagePullPolicy: {{ .Values.app.image.pullPolicy }}
69+
{{- with .Values.app.extraVolumeMounts }}
70+
volumeMounts:
71+
{{- toYaml . | nindent 12 }}
72+
{{- end }}
73+
ports:
74+
- name: soketi
75+
containerPort: {{ .Values.service.port }}
76+
protocol: TCP
77+
- name: metrics
78+
containerPort: {{ .Values.metrics.service.port }}
79+
protocol: TCP
80+
- name: peer
81+
containerPort: {{ .Values.peerServer.service.port }}
82+
protocol: TCP
83+
command:
84+
- node
85+
- --optimize_for_size
86+
- --optimize-for-size
87+
- /app/bin/server.js
88+
- start
89+
{{- if or .Values.metrics.enabled .Values.serviceMonitor.enabled }}
90+
- --metrics
91+
{{- end }}
92+
{{- with .Values.app.flags }}
93+
{{- toYaml . | nindent 12 }}
94+
{{- end }}
95+
env:
96+
- name: PORT
97+
value: "{{ .Values.service.port }}"
98+
- name: METRICS_SERVER_PORT
99+
value: "{{ .Values.metrics.service.port }}"
100+
- name: KUBE_POD_NAME
101+
valueFrom:
102+
fieldRef:
103+
fieldPath: metadata.name
104+
- name: KUBE_POD_NAMESPACE
105+
valueFrom:
106+
fieldRef:
107+
fieldPath: metadata.namespace
108+
- name: KUBE_POD_IP
109+
valueFrom:
110+
fieldRef:
111+
fieldPath: status.podIP
112+
- name: KUBE_SERVICES
113+
value: {{ include "soketi.fullname" . }}-peer
114+
- name: PEER_WS_PORT
115+
value: "{{ .Values.peerServer.service.port }}"
116+
- name: NODE_OPTIONS
117+
value: "--es-module-specifier-resolution=node"
118+
- name: PEER_INACTIVITY_TIMEOUT
119+
value: "10"
120+
- name: WS_GRACE_PERIOD
121+
value: "10"
122+
- name: MODE
123+
value: {{ .Values.app.mode | default "full" }}
124+
{{- with .Values.app.extraEnv }}
125+
{{- toYaml . | nindent 12 }}
126+
{{- end }}
127+
{{- with .Values.livenessProbe }}
128+
livenessProbe:
129+
{{- toYaml . | nindent 12 }}
130+
{{- end }}
131+
{{- with .Values.readinessProbe }}
132+
readinessProbe:
133+
{{- toYaml . | nindent 12 }}
134+
{{- end }}
135+
resources:
136+
{{- toYaml .Values.app.resources | nindent 12 }}
137+
{{- with .Values.nodeSelector }}
138+
nodeSelector:
139+
{{- toYaml . | nindent 8 }}
140+
{{- end }}
141+
{{- with .Values.affinity }}
142+
affinity:
143+
{{- toYaml . | nindent 8 }}
144+
{{- end }}
145+
{{- with .Values.tolerations }}
146+
tolerations:
147+
{{- toYaml . | nindent 8 }}
148+
{{- end }}

charts/k8soketi/templates/hpa.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2beta2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "soketi.fullname" . }}
6+
labels:
7+
{{- include "soketi.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "soketi.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
{{- with .Values.autoscaling.behavior }}
16+
behavior:
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
metrics:
20+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
21+
- type: Resource
22+
resource:
23+
name: cpu
24+
target:
25+
type: Utilization
26+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
27+
{{- end }}
28+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
29+
- type: Resource
30+
resource:
31+
name: memory
32+
target:
33+
type: Utilization
34+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
35+
{{- end }}
36+
{{- with .Values.autoscaling.customMetrics }}
37+
{{- toYaml . | nindent 4 }}
38+
{{- end }}
39+
{{- end }}

0 commit comments

Comments
 (0)