Skip to content

Commit bc76eed

Browse files
authored
chore(deploy):add helm charts (#439)
* chore(deploy):add helm charts * chore(deploy):update charts readme * chore(deploy):update charts readme * chore(deploy):typo defaule -> default * chore(playground):deplete kubecompose generate file * chore(deployment):add zh-cn readme and set default readme to zh-cn * chore(deployment):set existing mysql and guacd replicas * chore(deployment):update readme * chore(deployment):update readme add thanks * fix:remove dep and update reademe
1 parent db42934 commit bc76eed

26 files changed

+882
-323
lines changed

deploy/charts/Chart.lock

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dependencies:
2+
- name: common
3+
repository: oci://registry-1.docker.io/bitnamicharts
4+
version: 2.14.1
5+
- name: nfs-subdir-external-provisioner
6+
repository: https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner
7+
version: 4.0.18
8+
- name: mysql
9+
repository: oci://registry-1.docker.io/bitnamicharts
10+
version: 9.16.1
11+
digest: sha256:a4237a0269eaef0f8f6e58f8da6913f2f9c865b51ac7380971656221151a571e
12+
generated: "2024-01-14T21:47:18.234376962+08:00"

deploy/charts/Chart.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: v2
2+
name: next-terminal
3+
description: Next-terminal 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+
# 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: 0.1.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+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"
25+
26+
dependencies:
27+
- name: common
28+
repository: oci://registry-1.docker.io/bitnamicharts
29+
tags:
30+
- bitnami-common
31+
version: 2.14.1
32+
- name: nfs-subdir-external-provisioner
33+
alias: nfs
34+
condition: nfs.enabled
35+
repository: https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner
36+
tags:
37+
- nfs-subdir
38+
version: 4.0.18
39+
- name: mysql
40+
alias: mysql
41+
condition: mysql.enabled
42+
repository: oci://registry-1.docker.io/bitnamicharts
43+
version: 9.16.1
44+
tags:
45+
- mysql

deploy/charts/README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Next-Terminal helm charts
2+
3+
## 版本要求
4+
5+
- Helm 3.8.0+
6+
- Kubernetes 1.23+
7+
- Existing NFS Share
8+
---
9+
[ENGLISH](https://github.com/dushixiang/next-terminal/blob/add-helm-charts/deploy/charts/README_en.md)
10+
11+
[source](https://github.com/NeverTeaser/next-terminal-charts)
12+
13+
## 默认安装组件
14+
- [nfs-subdir-external-provisioner](https://artifacthub.io/packages/helm/nfs-subdir-external-provisioner/nfs-subdir-external-provisioner/4.0.18)
15+
- [mysql](https://artifacthub.io/packages/helm/bitnami/mysql/9.17.0)
16+
17+
18+
## 安装
19+
```
20+
helm repo add next-terminal https://1mtrue.com/next-terminal-charts/
21+
helm install my-next-terminal next-terminal/next-terminal --version 0.1.0
22+
```
23+
## nfs
24+
25+
当前版本(1.3.9) next-terminal 需要guacd 和web 后端之间共享目录,所以使用了nfs pvc 来实现pod 间文件共享, 你也可以使用已有的支持ReadWriteMany 的PVC 来替换,需要修改`value.yaml` 里的下列内容
26+
```
27+
nfs:
28+
enabled: false
29+
existingClaim:
30+
```
31+
32+
33+
如果启用NFS,请修改 `value.yaml` 的地址和目录
34+
``` yaml
35+
nfs:
36+
nfs:
37+
server: 192.168.88.82
38+
path: "/root/nfs-data"
39+
40+
```
41+
## mysql
42+
43+
next-terminal on Kubernetes 不建议使用(也不支持)使用SQLite作为后端数据库, 我们更推荐使用MySQL来作为后端存储数据库
44+
安全起见,安装时请修改`value.yaml` 中的认证信息
45+
```
46+
mysql:
47+
auth:
48+
rootPassword: next-terminal
49+
username: next-terminal
50+
password: next-terminal
51+
database: next-terminal
52+
```
53+
如果想用一个已有MySQL 作为后端存储,可以修改`value.yaml` 里的这些配置来使用已有的MySQL
54+
```
55+
mysql:
56+
enabled: false
57+
existing:
58+
auth:
59+
username: existing-next-terminal
60+
password: existing-next-terminal
61+
database: existing-next-terminal
62+
host: "existing.test.mysql"
63+
ports: 3306
64+
```
65+
66+
## 本地安装
67+
68+
```
69+
helm install my-release -f value.yaml ./
70+
```
71+
## 配置
72+
73+
更多配置参见 value.yaml
74+
75+
## 已知问题
76+
77+
- next-terminal 后端自身有一些local cache 所以多实例的情况下会出现数据错乱,暂时只支持一个副本。
78+
- 当前版本不提供Ingress 如果需要提供稳定的对外服务, 请自行配置Ingress
79+
80+
## 感谢
81+
82+
- [bitnami-common](https://github.com/bitnami/charts)
83+
- [nfs-subdir-external-provisioner](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/master)
84+
85+
<!-- | Parameter | Description | Default |
86+
| ------------------------------------ | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
87+
| `replicaCount` | Number of provisioner instances to deployed | `1` | -->

deploy/charts/README_en.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Next-Terminal helm charts
2+
3+
## Prerequisites
4+
5+
- Helm 3.8.0+
6+
- Kubernetes 1.23+
7+
- Existing NFS Share
8+
9+
10+
## nfs
11+
12+
next-terminal need share file between guacd and web backend server, so we use nfs. default enable you can disable in `value.yaml` and set existingClaim name.
13+
```
14+
nfs:
15+
enabled: false
16+
existingClaim:
17+
```
18+
19+
20+
or you can set "configured" nfs server in `value.yaml`
21+
```
22+
nfs:
23+
nfs:
24+
server: 192.168.88.82
25+
path: "/root/nfs-data"
26+
27+
```
28+
## mysql
29+
30+
mysql default enabled ,change you password for security
31+
32+
```
33+
mysql:
34+
auth:
35+
rootPassword: next-terminal
36+
username: next-terminal
37+
password: next-terminal
38+
database: next-terminal
39+
```
40+
41+
if you have existing mysql server, modify value.yaml
42+
```
43+
mysql:
44+
enabled: false
45+
existing:
46+
auth:
47+
username: existing-next-terminal
48+
password: existing-next-terminal
49+
database: existing-next-terminal
50+
host: "existing.test.mysql"
51+
ports: 3306
52+
```

deploy/charts/templates/_helpers.tpl

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{{/*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{- define "next-terminal.fullname" -}}
7+
{{- $name := default .Chart.Name .Values.nameOverride -}}
8+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
9+
{{- end -}}
10+
11+
12+
13+
{{- define "next-terminal.mysql.fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-mysql-headless" .Release.Name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}
17+
18+
{{- /*
19+
define the next-terminal release namespace
20+
*/ -}}
21+
{{- define "release_namespace" -}}
22+
{{- if .Values.namespaceOverride -}}
23+
{{- .Values.namespaceOverride -}}
24+
{{- else -}}
25+
{{- .Release.Namespace -}}
26+
{{- end -}}
27+
{{- end -}}
28+
29+
{{/* vim: set filetype=mustache: */}}
30+
{{/*
31+
Expand the name of the chart.
32+
*/}}
33+
{{- define "next-terminal.name" -}}
34+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
35+
{{- end -}}
36+
37+
38+
{{- /*
39+
next-terminal.labels generates the standard Helm labels.
40+
*/ -}}
41+
{{- define "next-terminal.labels" -}}
42+
app.kubernetes.io/name: {{ template "next-terminal.name" . }}
43+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
44+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45+
app.kubernetes.io/instance: {{ .Release.Name }}
46+
app.kubernetes.io/version: {{ .Chart.AppVersion }}
47+
{{- end -}}
48+
49+
50+
{{- define "next-terminal.imagePullSecrets" -}}
51+
{{- include "common.images.renderPullSecrets" (dict "images" (list .Values.image) "context" $) -}}
52+
{{- end -}}
53+
54+
55+
{{- define "next-terminal.guacd.fullname" -}}
56+
{{- printf "%s-%s" (include "common.names.fullname" .) "guacd" | trunc 63 | trimSuffix "-" -}}
57+
{{- end -}}
58+
59+
60+
{{- define "next-terminal.web.fullname" -}}
61+
{{- printf "%s-%s" (include "common.names.fullname" .) "web" | trunc 63 | trimSuffix "-" -}}
62+
{{- end -}}
63+
64+
65+
66+
{{- define "next-terminal.web.sshd.secretName" -}}
67+
{{- if .Values.web.sshd.existingSecret -}}
68+
{{- .Values.web.sshd.existingSecret -}}
69+
{{- else }}
70+
{{- include "next-terminal.web.fullname" . -}}
71+
{{- end -}}
72+
{{- end -}}
73+
74+
75+
76+
{{- define "next-terminal.pvc" -}}
77+
{{- .Values.nfs.existingClaim | default (include "common.names.fullname" .) -}}
78+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{ if .Values.guacd.enabled }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ .Release.Name }}-guacd
6+
namespace: {{ include "release_namespace" . }}
7+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.guacd.commonLabels "context" $ ) | nindent 4 }}
8+
{{- if .Values.commonAnnotations }}
9+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.guacd.commonAnnotations "context" $ ) | nindent 4 }}
10+
{{- end }}
11+
12+
spec:
13+
replicas: {{ .value.guacd.replicas }}
14+
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.guacd.podLabels .Values.guacd.commonLabels ) "context" . ) }}
15+
selector:
16+
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
17+
template:
18+
metadata:
19+
annotations:
20+
{{- if .Values.podAnnotations }}
21+
{{- include "common.tplvalues.render" (dict "value" .Values.guacd.podAnnotations "context" $) | nindent 8 }}
22+
{{- end }}
23+
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
24+
app.kubernetes.io/component: guacd
25+
app.kubernetes.io/part-of: next-terminal
26+
spec:
27+
{{- include "next-terminal.imagePullSecrets" . | nindent 6 }}
28+
{{- if .Values.affinity }}
29+
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.guacd.affinity "context" $) | nindent 8 }}
30+
{{- else }}
31+
affinity:
32+
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.guacd.podAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
33+
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.guacd.podAntiAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
34+
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.guacd.nodeAffinityPreset.type "key" .Values.guacd.nodeAffinityPreset.key "values" .Values.guacd.nodeAffinityPreset.values) | nindent 10 }}
35+
{{- end }}
36+
{{- if .Values.guacd.nodeSelector }}
37+
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.guacd.nodeSelector "context" $) | nindent 8 }}
38+
{{- end }}
39+
{{- if .Values.guacd.tolerations }}
40+
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.guacd.tolerations "context" $) | nindent 8 }}
41+
{{- end }}
42+
{{- if .Values.guacd.priorityClassName }}
43+
priorityClassName: {{ .Values.guacd.priorityClassName | quote }}
44+
{{- end }}
45+
{{- if .Values.guacd.podSecurityContext.enabled }}
46+
securityContext: {{- omit .Values.guacd.podSecurityContext "enabled" | toYaml | nindent 8 }}
47+
{{- end }}
48+
containers:
49+
- name: guacd
50+
image: {{ include "common.images.image" (dict "imageRoot" .Values.guacd.image "global" .Values.global) }}
51+
imagePullPolicy: {{ .Values.guacd.image.pullPolicy | quote }}
52+
{{- if .Values.guacd.resources }}
53+
resources: {{- toYaml .Values.guacd.resources | nindent 12 }}
54+
{{- end }}
55+
{{ if .Values.guacd.command }}
56+
command: {{- include "common.tplvalues.render" (dict "value" .Values.guacd.command "context" $) | nindent 12 }}
57+
{{- end }}
58+
env:
59+
- name: GUACD_LOG_LEVEL
60+
value: {{ if .Values.guacd.debug }}debug{{ else }}info{{ end }}
61+
ports:
62+
- containerPort: {{ .Values.guacd.servicePort }}
63+
name: guacd
64+
livenessProbe:
65+
tcpSocket:
66+
port: {{ .Values.guacd.servicePort }}
67+
initialDelaySeconds: 15
68+
periodSeconds: 20
69+
readinessProbe:
70+
tcpSocket:
71+
port: {{ .Values.guacd.servicePort }}
72+
initialDelaySeconds: 5
73+
periodSeconds: 10
74+
{{- if .Values.nfs.enabled }}
75+
volumeMounts:
76+
- name: guacd-data
77+
mountPath: {{ .Values.web.dataPath }}
78+
{{- end }}
79+
{{- if .Values.nfs.enabled }}
80+
restartPolicy: {{ .Values.guacd.restartPolicy | quote }}
81+
volumes:
82+
- name: guacd-data
83+
persistentVolumeClaim:
84+
claimName: {{ include "next-terminal.pvc" . }}
85+
{{- end }}
86+
{{ end }}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if and .Values.nfs.enabled }}
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
name: {{ include "common.names.fullname" . }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
7+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
8+
{{- if or .Values.nfs.annotations .Values.commonAnnotations }}
9+
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.nfs.annotations .Values.commonAnnotations ) "context" . ) }}
10+
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
accessModes:
14+
- {{ .Values.nfs.storageClass.accessModes }}
15+
resources:
16+
requests:
17+
storage: {{ .Values.nfs.size | quote }}
18+
storageClassName: {{ .Values.nfs.storageClass.name }}
19+
{{- end -}}

0 commit comments

Comments
 (0)