Skip to content

Commit 877a0a2

Browse files
committed
deploy: add helm charts
Signed-off-by: Nixieboluo <me@sagirii.me>
1 parent 028d430 commit 877a0a2

9 files changed

Lines changed: 352 additions & 0 deletions

File tree

deploy/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: sealos-tty-bridge
3+
description: Helm chart for sealos tty bridge
4+
type: application
5+
version: 0.1.0
6+
appVersion: 0.0.1
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Custom values for sealos tty bridge Helm chart.
2+
# This file contains user-customizable overrides on top of values.yaml.
3+
#
4+
# Note: cloudDomain is automatically fetched from sealos-system/sealos-config
5+
# by the CLI and does not need to be manually configured here.
6+
7+
replicaCount: 1
8+
9+
resources:
10+
requests:
11+
cpu: 10m
12+
memory: 128Mi
13+
limits:
14+
cpu: '2'
15+
memory: 2Gi
16+
17+
config:
18+
port: 3000
19+
kubeApiServer: auto
20+
wsMaxPayloadBytes: 1048576
21+
wsHeartbeatIntervalMs: 30000
22+
wsAuthTimeoutMs: 10000
23+
wsMaxKubeconfigBytes: 262144
24+
allowedOriginSubdomains:
25+
- terminal
26+
extraAllowedOrigins: []

deploy/templates/NOTES.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
export HOST={{ include "tty-bridge.ingressHost" . }}
4+
echo "https://${HOST}"
5+
{{- else }}
6+
kubectl port-forward -n {{ .Release.Namespace }} svc/{{ include "tty-bridge.fullname" . }} 3000:{{ .Values.service.port }}
7+
{{- end }}
8+
9+
2. The rendered config.json allows browser origins from:
10+
{{- range .Values.config.allowedOriginSubdomains }}
11+
- https://{{ . }}.{{ $.Values.cloudDomain }}
12+
{{- end }}
13+
{{- range .Values.config.extraAllowedOrigins }}
14+
- {{ . }}
15+
{{- end }}

deploy/templates/_helpers.tpl

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "tty-bridge.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
*/}}
11+
{{- define "tty-bridge.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- if contains $name .Release.Name }}
17+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
23+
24+
{{/*
25+
Create chart name and version as used by the chart label.
26+
*/}}
27+
{{- define "tty-bridge.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels.
33+
*/}}
34+
{{- define "tty-bridge.labels" -}}
35+
helm.sh/chart: {{ include "tty-bridge.chart" . }}
36+
{{ include "tty-bridge.selectorLabels" . }}
37+
{{- if .Chart.AppVersion }}
38+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39+
{{- end }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels.
45+
*/}}
46+
{{- define "tty-bridge.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "tty-bridge.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
50+
51+
{{/*
52+
ConfigMap name.
53+
*/}}
54+
{{- define "tty-bridge.configMapName" -}}
55+
{{- default (printf "%s-config" (include "tty-bridge.fullname" .)) .Values.configMap.nameOverride | trunc 63 | trimSuffix "-" }}
56+
{{- end }}
57+
58+
{{/*
59+
Ingress name.
60+
*/}}
61+
{{- define "tty-bridge.ingressName" -}}
62+
{{- default (include "tty-bridge.fullname" .) .Values.ingress.nameOverride | trunc 63 | trimSuffix "-" }}
63+
{{- end }}
64+
65+
{{/*
66+
Primary ingress host.
67+
*/}}
68+
{{- define "tty-bridge.ingressHost" -}}
69+
{{- printf "%s.%s" .Values.ingress.hostPrefix .Values.cloudDomain -}}
70+
{{- end }}

deploy/templates/configmap.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- $allowedOrigins := list -}}
2+
{{- range .Values.config.allowedOriginSubdomains }}
3+
{{- $allowedOrigins = append $allowedOrigins (printf "https://%s.%s" . $.Values.cloudDomain) -}}
4+
{{- end }}
5+
{{- range .Values.config.extraAllowedOrigins }}
6+
{{- $allowedOrigins = append $allowedOrigins . -}}
7+
{{- end }}
8+
{{- $config := dict
9+
"PORT" (.Values.config.port | int)
10+
"KUBE_API_SERVER" .Values.config.kubeApiServer
11+
"WS_MAX_PAYLOAD_BYTES" (.Values.config.wsMaxPayloadBytes | int)
12+
"WS_HEARTBEAT_INTERVAL_MS" (.Values.config.wsHeartbeatIntervalMs | int)
13+
"WS_AUTH_TIMEOUT_MS" (.Values.config.wsAuthTimeoutMs | int)
14+
"WS_MAX_KUBECONFIG_BYTES" (.Values.config.wsMaxKubeconfigBytes | int)
15+
"WS_ALLOWED_ORIGINS" $allowedOrigins
16+
-}}
17+
apiVersion: v1
18+
kind: ConfigMap
19+
metadata:
20+
name: {{ include "tty-bridge.configMapName" . }}
21+
namespace: {{ .Release.Namespace }}
22+
labels:
23+
{{- include "tty-bridge.labels" . | nindent 4 }}
24+
data:
25+
config.json: |
26+
{{- $config | toPrettyJson | nindent 4 }}

deploy/templates/deployment.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "tty-bridge.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
app: {{ include "tty-bridge.name" . }}
8+
{{- include "tty-bridge.labels" . | nindent 4 }}
9+
spec:
10+
replicas: {{ .Values.replicaCount }}
11+
selector:
12+
matchLabels:
13+
app: {{ include "tty-bridge.name" . }}
14+
template:
15+
metadata:
16+
labels:
17+
app: {{ include "tty-bridge.name" . }}
18+
{{- include "tty-bridge.selectorLabels" . | nindent 8 }}
19+
{{- with .Values.podLabels }}
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
annotations:
23+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
24+
{{- with .Values.podAnnotations }}
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
spec:
28+
{{- with .Values.imagePullSecrets }}
29+
imagePullSecrets:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
securityContext:
33+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
34+
containers:
35+
- name: {{ include "tty-bridge.fullname" . }}
36+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
37+
imagePullPolicy: {{ .Values.imagePullPolicy }}
38+
securityContext:
39+
{{- toYaml .Values.securityContext | nindent 12 }}
40+
ports:
41+
- name: http
42+
containerPort: {{ .Values.config.port }}
43+
protocol: TCP
44+
resources:
45+
{{- toYaml .Values.resources | nindent 12 }}
46+
volumeMounts:
47+
- name: tty-bridge-volume
48+
mountPath: /app/config.json
49+
subPath: config.json
50+
volumes:
51+
- name: tty-bridge-volume
52+
configMap:
53+
name: {{ include "tty-bridge.configMapName" . }}
54+
{{- with .Values.nodeSelector }}
55+
nodeSelector:
56+
{{- toYaml . | nindent 8 }}
57+
{{- end }}
58+
{{- with .Values.affinity }}
59+
affinity:
60+
{{- toYaml . | nindent 8 }}
61+
{{- end }}
62+
{{- with .Values.tolerations }}
63+
tolerations:
64+
{{- toYaml . | nindent 8 }}
65+
{{- end }}

deploy/templates/ingress.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "tty-bridge.ingressName" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "tty-bridge.labels" . | nindent 4 }}
9+
{{- $annotations := dict }}
10+
{{- with .Values.ingress.annotations }}
11+
{{- $annotations = merge $annotations . }}
12+
{{- end }}
13+
{{- if and .Values.ingress.className (not (hasKey $annotations "kubernetes.io/ingress.class")) }}
14+
{{- $_ := set $annotations "kubernetes.io/ingress.class" .Values.ingress.className }}
15+
{{- end }}
16+
{{- with $annotations }}
17+
annotations:
18+
{{- toYaml . | nindent 4 }}
19+
{{- end }}
20+
spec:
21+
{{- if .Values.ingress.className }}
22+
ingressClassName: {{ .Values.ingress.className }}
23+
{{- end }}
24+
rules:
25+
- host: {{ include "tty-bridge.ingressHost" . | quote }}
26+
http:
27+
paths:
28+
- path: {{ .Values.ingress.path }}
29+
pathType: {{ .Values.ingress.pathType }}
30+
backend:
31+
service:
32+
name: {{ include "tty-bridge.fullname" . }}
33+
port:
34+
number: {{ .Values.service.port }}
35+
{{- if .Values.ingress.tls.enabled }}
36+
tls:
37+
- hosts:
38+
- {{ include "tty-bridge.ingressHost" . | quote }}
39+
secretName: {{ .Values.ingress.tls.secretName }}
40+
{{- end }}
41+
{{- end }}

deploy/templates/service.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "tty-bridge.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "tty-bridge.labels" . | nindent 4 }}
8+
spec:
9+
ports:
10+
- name: http
11+
port: {{ .Values.service.port }}
12+
targetPort: {{ .Values.service.targetPort }}
13+
protocol: TCP
14+
selector:
15+
app: {{ include "tty-bridge.name" . }}

deploy/values.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Default values for sealos tty bridge Helm chart.
2+
3+
nameOverride: tty-bridge-system
4+
fullnameOverride: tty-bridge-system
5+
6+
image:
7+
repository: ghcr.io/labring-sigs/sealos-tty-agent
8+
tag: sha-028d430
9+
10+
imagePullPolicy: Always
11+
imagePullSecrets: []
12+
13+
replicaCount: 1
14+
15+
# Auto configure from sealos-system configmap
16+
autoConfigEnabled: true
17+
18+
# ============================================================================
19+
# Auto-configured values (from sealos-system/sealos-config ConfigMap)
20+
# ============================================================================
21+
# The following values are automatically fetched from the
22+
# sealos-system/sealos-config ConfigMap by the CLI and will
23+
# override any values set here. These are provided as reference defaults.
24+
#
25+
# To override these auto-configured values, use HELM_OPTIONS or modify the
26+
# sealos-config ConfigMap directly.
27+
# ============================================================================
28+
29+
cloudDomain: 127.0.0.1.nip.io # Auto-fetched from sealos-config.cloudDomain
30+
31+
# End of auto-configured values
32+
# ============================================================================
33+
34+
configMap:
35+
nameOverride: tty-bridge-config
36+
37+
podAnnotations: {}
38+
podLabels: {}
39+
40+
podSecurityContext: {}
41+
42+
securityContext:
43+
allowPrivilegeEscalation: false
44+
capabilities:
45+
drop:
46+
- ALL
47+
runAsNonRoot: true
48+
runAsUser: 1001
49+
50+
service:
51+
port: 3000
52+
targetPort: 3000
53+
54+
resources:
55+
requests:
56+
cpu: 10m
57+
memory: 128Mi
58+
limits:
59+
cpu: '2'
60+
memory: 2Gi
61+
62+
config:
63+
port: 3000
64+
kubeApiServer: auto
65+
wsMaxPayloadBytes: 1048576
66+
wsHeartbeatIntervalMs: 30000
67+
wsAuthTimeoutMs: 10000
68+
wsMaxKubeconfigBytes: 262144
69+
allowedOriginSubdomains:
70+
- terminal
71+
extraAllowedOrigins: []
72+
73+
ingress:
74+
enabled: true
75+
nameOverride: sealos-tty-bridge
76+
className: nginx
77+
annotations: {}
78+
# Host will be auto-configured from cloudDomain
79+
hostPrefix: tty-bridge
80+
path: /
81+
pathType: Prefix
82+
tls:
83+
enabled: true
84+
secretName: wildcard-cert
85+
86+
nodeSelector: {}
87+
affinity: {}
88+
tolerations: []

0 commit comments

Comments
 (0)