Skip to content

Commit

Permalink
Create helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbandi committed Sep 23, 2024
1 parent 041a603 commit 37117c2
Show file tree
Hide file tree
Showing 14 changed files with 621 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helm-charts/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions helm-charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
appVersion: "1.1.10-3"
name: rustdesk-server
description: A Rustdesk Helm chart for Kubernetes
type: application
icon: https://raw.githubusercontent.com/rustdesk/rustdesk-server/master/ui/icons/icon.png
version: 0.1.0
3 changes: 3 additions & 0 deletions helm-charts/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The RustDesk has been deployed to your cluster.

See https://rustdesk.com/docs/en/ for more detail.
62 changes: 62 additions & 0 deletions helm-charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "rustdesk-server.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "rustdesk-server.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

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

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

{{/*
Selector labels
*/}}
{{- define "rustdesk-server.selectorLabels" -}}
app.kubernetes.io/name: {{ include "rustdesk-server.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "rustdesk-server.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "rustdesk-server.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
90 changes: 90 additions & 0 deletions helm-charts/templates/hbbr-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "rustdesk-server.fullname" . }}-hbbr
labels:
{{- include "rustdesk-server.labels" . | nindent 4 }}
app.kubernetes.io/component: hbbr
{{- with .Values.hbbr.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "rustdesk-server.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: hbbr
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "rustdesk-server.labels" . | nindent 8 }}
app.kubernetes.io/component: hbbr
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "rustdesk-server.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-hbbr
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.hbbr.image.repository }}:{{ .Values.hbbr.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.hbbr.image.pullPolicy }}
command: [ "/usr/bin/hbbr" ]
args:
{{- with .Values.hbbr.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- else}}
- "-k"
- "_"
{{- end }}
ports:
- name: hbbr-port
containerPort: 21117
protocol: TCP
- name: hbbr-websocket
containerPort: 21119
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /root
readOnly: true
name: hbbr-keys
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
volumes:
- name: hbbr-keys
secret:
{{- if .Values.hbbr.secret.existingSecret }}
secretName: {{ .Values.hbbr.secret.existingSecret }}
{{- else }}
secretName: {{ include "rustdesk-server.fullname" . }}-hbbr
{{- end }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
20 changes: 20 additions & 0 deletions helm-charts/templates/hbbr-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if not .Values.hbbr.secret.existingSecret -}}
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "rustdesk-server.labels" . | nindent 4 }}
app.kubernetes.io/component: hbbr
{{- with .Values.hbbr.secret.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "rustdesk-server.fullname" . }}-hbbr
{{- with .Values.hbbr.secret.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
type: Opaque
data:
id_ed25519: {{ .Values.hbbr.secret.private | b64enc | quote }}
id_ed25519.pub: {{ .Values.hbbr.secret.public | b64enc | quote }}
{{- end -}}
46 changes: 46 additions & 0 deletions helm-charts/templates/hbbr-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "rustdesk-server.fullname" . }}-hbbr
labels:
{{- include "rustdesk-server.labels" . | nindent 4 }}
app.kubernetes.io/component: hbbr
{{- with .Values.hbbr.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs: {{ toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{ toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerClass }}
loadBalancerClass: {{ .Values.service.loadBalancerClass }}
{{- end }}
{{- if hasKey .Values.service "allocateLoadBalancerNodePorts" }}
allocateLoadBalancerNodePorts: {{ .Values.service.allocateLoadBalancerNodePorts }}
{{- end }}
{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.service.hbbrPort }}
targetPort: hbbr-port
protocol: TCP
name: hbbr-port
- port: {{ .Values.service.hbbrWebsocket }}
targetPort: hbbr-websocket
protocol: TCP
name: hbbr-websocket
selector:
{{- include "rustdesk-server.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: hbbr
18 changes: 18 additions & 0 deletions helm-charts/templates/hbbs-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.hbbs.relay -}}
apiVersion: v1
kind: ConfigMap
metadata:
labels:
{{- include "rustdesk-server.labels" . | nindent 4 }}
app.kubernetes.io/component: hbbr
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "rustdesk-server.fullname" . }}-hbbs
{{- with .Values.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
data:
RELAY: {{ .Values.hbbs.relay }}
{{- end -}}
111 changes: 111 additions & 0 deletions helm-charts/templates/hbbs-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "rustdesk-server.fullname" . }}-hbbs
labels:
{{- include "rustdesk-server.labels" . | nindent 4 }}
app.kubernetes.io/component: hbbs
{{- with .Values.hbbs.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "rustdesk-server.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: hbbs
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "rustdesk-server.labels" . | nindent 8 }}
app.kubernetes.io/component: hbbs
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "rustdesk-server.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-hbbs
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.hbbs.image.repository }}:{{ .Values.hbbs.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.hbbs.image.pullPolicy }}
command: [ "/usr/bin/hbbs" ]
args:
{{- with .Values.hbbs.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- else}}
- "-r"
- "$(RELAY)"
- "-k"
- "_"
{{- end }}
{{- if .Values.hbbs.relay }}
env:
- name: DB_URL
value: "/db/db_v2.sqlite3"
envFrom:
- configMapRef:
name: {{ include "rustdesk-server.fullname" . }}-hbbs
{{- end }}
ports:
- name: hbbs-nat-test
containerPort: 21115
protocol: TCP
- name: hbbs-port
containerPort: 21116
protocol: TCP
- name: hbbs-port-udp
containerPort: 21116
protocol: UDP
- name: hbbs-websocket
containerPort: 21118
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /root
readOnly: true
name: hbbr-keys
- mountPath: /db
name: hbbs-db
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
volumes:
- name: hbbr-keys
secret:
{{- if .Values.hbbr.secret.existingSecret }}
secretName: {{ .Values.hbbr.secret.existingSecret }}
{{- else }}
secretName: {{ include "rustdesk-server.fullname" . }}-hbbr
{{- end }}
- name: hbbs-db
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "rustdesk-server.fullname" . }}-hbbs-pvc{{- end }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading

0 comments on commit 37117c2

Please sign in to comment.