From 1dcf1c98a7dfb6d415f7affd6433a9d4ad4707d4 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 04:14:28 +0400 Subject: [PATCH 01/16] feat: add kubernetes chart Signed-off-by: Bruno Bernard --- .github/workflows/build-kubernetes-chart.yaml | 28 ++++ charts/textbee/.helmignore | 23 +++ charts/textbee/Chart.yaml | 8 + charts/textbee/templates/NOTES.txt | 44 ++++++ charts/textbee/templates/_helpers.tpl | 52 +++++++ charts/textbee/templates/deployment.yaml | 131 ++++++++++++++++ charts/textbee/templates/hpa.yaml | 32 ++++ charts/textbee/templates/ingress.yaml | 88 +++++++++++ charts/textbee/templates/service.yaml | 41 +++++ charts/textbee/values.yaml | 142 ++++++++++++++++++ 10 files changed, 589 insertions(+) create mode 100644 .github/workflows/build-kubernetes-chart.yaml create mode 100644 charts/textbee/.helmignore create mode 100644 charts/textbee/Chart.yaml create mode 100644 charts/textbee/templates/NOTES.txt create mode 100644 charts/textbee/templates/_helpers.tpl create mode 100644 charts/textbee/templates/deployment.yaml create mode 100644 charts/textbee/templates/hpa.yaml create mode 100644 charts/textbee/templates/ingress.yaml create mode 100644 charts/textbee/templates/service.yaml create mode 100644 charts/textbee/values.yaml diff --git a/.github/workflows/build-kubernetes-chart.yaml b/.github/workflows/build-kubernetes-chart.yaml new file mode 100644 index 0000000..2b517f7 --- /dev/null +++ b/.github/workflows/build-kubernetes-chart.yaml @@ -0,0 +1,28 @@ +name: Release Charts + +on: + push: + +permissions: write-all + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + id: cr + uses: helm/chart-releaser-action@v1.5.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + with: + charts_dir: ./charts \ No newline at end of file diff --git a/charts/textbee/.helmignore b/charts/textbee/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/textbee/.helmignore @@ -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/ diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml new file mode 100644 index 0000000..b15e05a --- /dev/null +++ b/charts/textbee/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: textbee +description: A Helm chart to deploy TextBee. +type: application + +version: 0.1.0 + +appVersion: "v2.6.2" diff --git a/charts/textbee/templates/NOTES.txt b/charts/textbee/templates/NOTES.txt new file mode 100644 index 0000000..f996bf6 --- /dev/null +++ b/charts/textbee/templates/NOTES.txt @@ -0,0 +1,44 @@ +Text Bee is ready ! + +Don't forget to create a secret + +apiVersion: v1 +kind: Secret +metadata: + name: textbee-api-secrets +type: Opaque +stringData: + MONGO_URI: mongodb://adminUser:adminPassword@textbee-db:27017/textbee?authSource=admin + JWT_SECRET: supersecret + JWT_EXPIRATION: 60d + FIREBASE_PROJECT_ID: + FIREBASE_PRIVATE_KEY_ID: + FIREBASE_PRIVATE_KEY: + FIREBASE_CLIENT_EMAIL: + FIREBASE_CLIENT_ID: + FIREBASE_CLIENT_C509_CERT_URL: + MAIL_HOST: + MAIL_PORT: + MAIL_USER: + MAIL_PASS: + MAIL_FROM: + MAIL_REPLY_TO: + + +apiVersion: v1 +kind: Secret +metadata: + name: textbee-web-secrets +type: Opaque +stringData: + AUTH_SECRET= # https://generate-secret.vercel.app/32 + NEXT_PUBLIC_SITE_URL: http://localhost:80 + NEXT_PUBLIC_GOOGLE_CLIENT_ID: + NEXT_PUBLIC_TAWKTO_EMBED_URL: + DATABASE_URL: mongodb://adminUser:adminPassword@textbee-db:27017/textbee?authSource=admin + MAIL_HOST: + MAIL_PORT: + MAIL_USER: + MAIL_PASS: + MAIL_FROM: + ADMIN_EMAIL: \ No newline at end of file diff --git a/charts/textbee/templates/_helpers.tpl b/charts/textbee/templates/_helpers.tpl new file mode 100644 index 0000000..de18a87 --- /dev/null +++ b/charts/textbee/templates/_helpers.tpl @@ -0,0 +1,52 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "textbee.name" -}} +{{- default .Chart.Name .Values.api.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 "textbee.fullname" -}} +{{- if .Values.api.fullnameOverride }} +{{- .Values.api.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.api.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 "textbee.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "textbee.labels" -}} +helm.sh/chart: {{ include "textbee.chart" . }} +{{ include "textbee.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "textbee.selectorLabels" -}} +app.kubernetes.io/name: {{ include "textbee.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + diff --git a/charts/textbee/templates/deployment.yaml b/charts/textbee/templates/deployment.yaml new file mode 100644 index 0000000..c7a4b08 --- /dev/null +++ b/charts/textbee/templates/deployment.yaml @@ -0,0 +1,131 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "textbee.fullname" .}}-api + labels: + {{- include "textbee.labels" . | nindent 4 }} +spec: + {{- if not .Values.api.autoscaling.enabled }} + replicas: {{ .Values.api.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "textbee.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.api.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "textbee.labels" . | nindent 8 }} + {{- with .Values.api.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + containers: + {{- with .Values.api.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + - name: {{ .Chart.Name }}-api + {{- with .Values.api.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.api.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.api.service.port }} + protocol: TCP + env: + - name: PORT + value: "{{ .Values.api.service.port }}" + {{- if .Values.api.redis.enabled }} + - name: REDIS_URL + value: "{{ .Values.api.redis.dsn }}" + - name: USE_SMS_QUEUE + value: "true" + {{- else }} + - name: USE_SMS_QUEUE + value: "false" + {{- end }} + {{- if .Values.web.enabled }} + - name: FRONTEND_URL + value: "http://{{ include "textbee.fullname" .}}-web:{{ .Values.web.service.port }}" + {{- end}} + envFrom: + - secretRef: + name: {{ include "textbee.fullname" .}}-api-secrets + {{- with .Values.api.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.api.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.api.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.api.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.api.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + +--- +{{- if not .Values.web.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "textbee.fullname" .}}-web + labels: + {{- include "textbee.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "textbee.fullname" .}}-web + template: + metadata: + labels: + app: {{ include "textbee.fullname" .}}-web + spec: + containers: + - name: {{ include "textbee.fullname" .}}-web + image: "{{ .Values.web.image.repository }}:{{ .Values.web.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.api.image.pullPolicy }} + ports: + - containerPort: {{ .Values.web.service.port }} + env: + - name: PORT + value: "{{ .Values.web.service.port }}" + - name: NEXT_PUBLIC_API_BASE_URL + value: "http://{{ include "textbee.fullname" .}}-api:{{ .Values.web.service.port }}/api/v1" + envFrom: + - secretRef: + name: {{ include "textbee.fullname" .}}-web-secrets +{{- end }} \ No newline at end of file diff --git a/charts/textbee/templates/hpa.yaml b/charts/textbee/templates/hpa.yaml new file mode 100644 index 0000000..671f337 --- /dev/null +++ b/charts/textbee/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.api.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "textbee.fullname" . }} + labels: + {{- include "textbee.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "textbee.fullname" . }} + minReplicas: {{ .Values.api.autoscaling.minReplicas }} + maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} + metrics: + {{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/textbee/templates/ingress.yaml b/charts/textbee/templates/ingress.yaml new file mode 100644 index 0000000..97b1339 --- /dev/null +++ b/charts/textbee/templates/ingress.yaml @@ -0,0 +1,88 @@ +{{- if .Values.api.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "textbee.fullname" . }} + labels: + {{- include "textbee.labels" . | nindent 4 }} + {{- with .Values.api.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.api.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.api.ingress.tls }} + tls: + {{- range .Values.api.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.api.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "textbee.fullname" $ }} + port: + number: {{ $.Values.api.service.port }} + {{- end }} + {{- end }} +{{- end }} +--- + +{{- if .Values.web.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "textbee.fullname" . }} + labels: + {{- include "textbee.labels" . | nindent 4 }} + {{- with .Values.web.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.api.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.web.ingress.tls }} + tls: + {{- range .Values.web.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.web.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "textbee.fullname" $ }} + port: + number: {{ $.Values.web.service.port }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/textbee/templates/service.yaml b/charts/textbee/templates/service.yaml new file mode 100644 index 0000000..d95dbe6 --- /dev/null +++ b/charts/textbee/templates/service.yaml @@ -0,0 +1,41 @@ +--- +{{- if .Values.web.service.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "textbee.fullname" . }}-web + labels: + {{- include "textbee.labels" . | nindent 4 }} +spec: + selector: + app: {{ include "textbee.fullname" . }}-web + {{- if .Values.web.service.annotations }} + annotations: + {{- toYaml .Values.web.service.annotations | nindent 4 }} + {{- end }} + ports: + - port: {{ .Values.web.service.port | default 80 }} + targetPort: {{ .Values.web.service.targetPort | default 80 }} + type: {{ .Values.web.service.type | default "ClusterIP" }} + +{{- end }} +--- +{{- if .Values.api.service.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "textbee.fullname" . }}-api + labels: + {{- include "textbee.labels" . | nindent 4 }} +spec: + selector: + app: {{ include "textbee.fullname" . }}-web + {{- if .Values.api.service.annotations }} + annotations: + {{- toYaml .Values.api.service.annotations | nindent 4 }} + {{- end }} + ports: + - port: {{ .Values.api.service.port | default 80 }} + targetPort: {{ .Values.api.service.targetPort | default 80 }} + type: {{ .Values.api.service.type | default "ClusterIP" }} +{{- end }} \ No newline at end of file diff --git a/charts/textbee/values.yaml b/charts/textbee/values.yaml new file mode 100644 index 0000000..5ce48ea --- /dev/null +++ b/charts/textbee/values.yaml @@ -0,0 +1,142 @@ + +api: + replicaCount: 1 + image: + repository: ghcr.io/vernu/textbee/api + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + imagePullSecrets: [] + # This is to override the chart name. + nameOverride: "" + fullnameOverride: "" + + # Redis enabled means API SMS QUEUE is enabled. + redis: + enabled: true + dsn: "" + + # This is the name of the secret that contains the environment variables for the API. + # If not set, it will default to the chart name with '-env' suffix. + envSecretName: "" + + + + # This is for setting Kubernetes Annotations to a Pod. + # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ + podAnnotations: {} + # This is for setting Kubernetes Labels to a Pod. + # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ + podLabels: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + # This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ + service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + annotations: {} + labels: {} + + # This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ + ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + + # This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + # Additional volumes on the output Deployment definition. + volumes: [] + # - name: foo + # secret: + # secretName: mysecret + # optional: false + + # Additional volumeMounts on the output Deployment definition. + volumeMounts: [] + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true + + nodeSelector: {} + + tolerations: [] + + affinity: {} + +web: + enabled: false + image: + repository: ghcr.io/vernu/textbee/web + pullPolicy: IfNotPresent + tag: "" + + service: + type: ClusterIP + port: 80 + labels: {} + annotations: {} + + ingress: + enabled: false + className: "" + annotations: {} + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific From bce5afaeb531d2cec814645078f32cc831844a1c Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 05:06:09 +0400 Subject: [PATCH 02/16] fix: remove not statement --- charts/textbee/Chart.yaml | 2 +- charts/textbee/templates/deployment.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index b15e05a..5edb446 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.0 +version: 0.1.1 appVersion: "v2.6.2" diff --git a/charts/textbee/templates/deployment.yaml b/charts/textbee/templates/deployment.yaml index c7a4b08..32feb56 100644 --- a/charts/textbee/templates/deployment.yaml +++ b/charts/textbee/templates/deployment.yaml @@ -6,7 +6,7 @@ metadata: labels: {{- include "textbee.labels" . | nindent 4 }} spec: - {{- if not .Values.api.autoscaling.enabled }} + {{- if .Values.api.autoscaling.enabled }} replicas: {{ .Values.api.replicaCount }} {{- end }} selector: @@ -97,7 +97,7 @@ spec: {{- end }} --- -{{- if not .Values.web.enabled -}} +{{- if .Values.web.enabled -}} apiVersion: apps/v1 kind: Deployment metadata: From 799ed7adeece8f7a038c64f80b19b0b2eebfec3d Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 05:07:05 +0400 Subject: [PATCH 03/16] fix: fix not --- charts/textbee/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/textbee/templates/deployment.yaml b/charts/textbee/templates/deployment.yaml index 32feb56..496ece8 100644 --- a/charts/textbee/templates/deployment.yaml +++ b/charts/textbee/templates/deployment.yaml @@ -6,7 +6,7 @@ metadata: labels: {{- include "textbee.labels" . | nindent 4 }} spec: - {{- if .Values.api.autoscaling.enabled }} + {{- if not .Values.api.autoscaling.enabled }} replicas: {{ .Values.api.replicaCount }} {{- end }} selector: From 60b093c4360b7c5ac038217c63e81f53e5cd4be1 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 05:07:45 +0400 Subject: [PATCH 04/16] chore: bump version --- charts/textbee/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index 5edb446..55e9884 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.1 +version: 0.1.2 appVersion: "v2.6.2" From 706af6bf8aa83654b102255c2929803d0e213f75 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 20:25:20 +0400 Subject: [PATCH 05/16] fix: update helm logic --- charts/textbee/Chart.yaml | 2 +- charts/textbee/example/values.yaml | 30 +++++ charts/textbee/templates/NOTES.txt | 98 +++++++++----- charts/textbee/templates/_helpers.tpl | 1 - .../{deployment.yaml => api-deployment.yaml} | 79 +++-------- charts/textbee/templates/api-hpa.yaml | 32 +++++ charts/textbee/templates/api-ingress.yaml | 43 ++++++ charts/textbee/templates/api-service.yaml | 21 +++ charts/textbee/templates/hpa.yaml | 4 +- charts/textbee/templates/ingress.yaml | 88 ------------- charts/textbee/templates/service.yaml | 41 ------ charts/textbee/templates/web-deployment.yaml | 74 +++++++++++ charts/textbee/templates/web-ingress.yaml | 43 ++++++ charts/textbee/templates/web-service.yaml | 21 +++ charts/textbee/values.yaml | 123 +++++++++++++++--- 15 files changed, 456 insertions(+), 244 deletions(-) create mode 100644 charts/textbee/example/values.yaml rename charts/textbee/templates/{deployment.yaml => api-deployment.yaml} (53%) create mode 100644 charts/textbee/templates/api-hpa.yaml create mode 100644 charts/textbee/templates/api-ingress.yaml create mode 100644 charts/textbee/templates/api-service.yaml delete mode 100644 charts/textbee/templates/ingress.yaml delete mode 100644 charts/textbee/templates/service.yaml create mode 100644 charts/textbee/templates/web-deployment.yaml create mode 100644 charts/textbee/templates/web-ingress.yaml create mode 100644 charts/textbee/templates/web-service.yaml diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index 55e9884..ac76555 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.2 +version: 0.1.3 appVersion: "v2.6.2" diff --git a/charts/textbee/example/values.yaml b/charts/textbee/example/values.yaml new file mode 100644 index 0000000..54cf168 --- /dev/null +++ b/charts/textbee/example/values.yaml @@ -0,0 +1,30 @@ +web: + enabled: true + service: + enabled: true + type: LoadBalancer + annotations: + tailscale.com/expose: "true" + tailscale.com/hostname: "textbee-web" +api: + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 80 + service: + enabled: true + ingress: + enabled: true + hosts: + - host: textbee-api.demo.com + paths: + - path: / + pathType: Prefix + className: nginx + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + tls: + - secretName: textbee-api-tls + hosts: + - textbee-api.demo.com \ No newline at end of file diff --git a/charts/textbee/templates/NOTES.txt b/charts/textbee/templates/NOTES.txt index f996bf6..09e9693 100644 --- a/charts/textbee/templates/NOTES.txt +++ b/charts/textbee/templates/NOTES.txt @@ -1,44 +1,84 @@ -Text Bee is ready ! -Don't forget to create a secret +######################## +# IMPORTANT # +######################## +TextBee is almost ready ! + +Create those secrets below: +--- apiVersion: v1 kind: Secret metadata: - name: textbee-api-secrets + name: {{ include "textbee.fullname" . }}-secrets + namespace: {{ .Release.Namespace }} type: Opaque stringData: - MONGO_URI: mongodb://adminUser:adminPassword@textbee-db:27017/textbee?authSource=admin - JWT_SECRET: supersecret + JWT_SECRET: "" # https://generate-secret.vercel.app/32 JWT_EXPIRATION: 60d - FIREBASE_PROJECT_ID: - FIREBASE_PRIVATE_KEY_ID: - FIREBASE_PRIVATE_KEY: - FIREBASE_CLIENT_EMAIL: - FIREBASE_CLIENT_ID: - FIREBASE_CLIENT_C509_CERT_URL: - MAIL_HOST: - MAIL_PORT: - MAIL_USER: - MAIL_PASS: - MAIL_FROM: - MAIL_REPLY_TO: + # Go to Firebase Console -> Press on cog (Project Settings) -> Service Accounts -> Generate new private key + FIREBASE_PROJECT_ID: "" + FIREBASE_PRIVATE_KEY_ID: "" + FIREBASE_PRIVATE_KEY: "" + FIREBASE_CLIENT_EMAIL: "" + FIREBASE_CLIENT_ID: "" + FIREBASE_CLIENT_C509_CERT_URL: "" + MAIL_HOST: "" + MAIL_PORT: "" + MAIL_USER: "" + MAIL_PASS: "" + MAIL_FROM: "" + MAIL_REPLY_TO: "" + +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "textbee.fullname" . }}-web-secrets + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + NEXT_PUBLIC_GOOGLE_CLIENT_ID: "" + NEXT_PUBLIC_TAWKTO_EMBED_URL: "" + MAIL_HOST: "" + MAIL_PORT: "" + MAIL_USER: "" + MAIL_PASS: "" + MAIL_FROM: "" + ADMIN_EMAIL: "" + +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "textbee.fullname" . }}-web-secrets + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + NEXT_PUBLIC_GOOGLE_CLIENT_ID: "" + NEXT_PUBLIC_TAWKTO_EMBED_URL: "" + MAIL_HOST: "" + MAIL_PORT: "" + MAIL_USER: "" + MAIL_PASS: "" + MAIL_FROM: "" + ADMIN_EMAIL: "" +--- apiVersion: v1 kind: Secret metadata: - name: textbee-web-secrets + name: {{ .Values.globals.mongo_uri.secretName }} + namespace: {{ .Release.Namespace }} type: Opaque stringData: - AUTH_SECRET= # https://generate-secret.vercel.app/32 - NEXT_PUBLIC_SITE_URL: http://localhost:80 - NEXT_PUBLIC_GOOGLE_CLIENT_ID: - NEXT_PUBLIC_TAWKTO_EMBED_URL: - DATABASE_URL: mongodb://adminUser:adminPassword@textbee-db:27017/textbee?authSource=admin - MAIL_HOST: - MAIL_PORT: - MAIL_USER: - MAIL_PASS: - MAIL_FROM: - ADMIN_EMAIL: \ No newline at end of file + uri: "" # mongodb://user:password@host:port/database + +--- + +######################## +# IMPORTANT # +######################## + +Create those secrets above! \ No newline at end of file diff --git a/charts/textbee/templates/_helpers.tpl b/charts/textbee/templates/_helpers.tpl index de18a87..1fcf6ec 100644 --- a/charts/textbee/templates/_helpers.tpl +++ b/charts/textbee/templates/_helpers.tpl @@ -46,7 +46,6 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} Selector labels */}} {{- define "textbee.selectorLabels" -}} -app.kubernetes.io/name: {{ include "textbee.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} diff --git a/charts/textbee/templates/deployment.yaml b/charts/textbee/templates/api-deployment.yaml similarity index 53% rename from charts/textbee/templates/deployment.yaml rename to charts/textbee/templates/api-deployment.yaml index 496ece8..003123d 100644 --- a/charts/textbee/templates/deployment.yaml +++ b/charts/textbee/templates/api-deployment.yaml @@ -1,9 +1,9 @@ ---- apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "textbee.fullname" .}}-api labels: + app: {{ include "textbee.fullname" .}}-api {{- include "textbee.labels" . | nindent 4 }} spec: {{- if not .Values.api.autoscaling.enabled }} @@ -11,42 +11,26 @@ spec: {{- end }} selector: matchLabels: - {{- include "textbee.selectorLabels" . | nindent 6 }} + app: {{ include "textbee.fullname" .}}-api template: metadata: - {{- with .Values.api.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} labels: - {{- include "textbee.labels" . | nindent 8 }} - {{- with .Values.api.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} + app: {{ include "textbee.fullname" .}}-api spec: containers: - {{- with .Values.api.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.podSecurityContext }} - securityContext: - {{- toYaml . | nindent 8 }} - {{- end }} - - name: {{ .Chart.Name }}-api - {{- with .Values.api.securityContext }} - securityContext: - {{- toYaml . | nindent 12 }} - {{- end }} + - name: {{ include "textbee.fullname" .}}-api image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.api.image.pullPolicy }} ports: - name: http containerPort: {{ .Values.api.service.port }} - protocol: TCP env: - name: PORT value: "{{ .Values.api.service.port }}" + {{- if .Values.web.enabled }} + - name: FRONTEND_URL + value: "http://{{ include "textbee.fullname" .}}-web:{{ .Values.web.service.port }}" + {{- end}} {{- if .Values.api.redis.enabled }} - name: REDIS_URL value: "{{ .Values.api.redis.dsn }}" @@ -56,13 +40,14 @@ spec: - name: USE_SMS_QUEUE value: "false" {{- end }} - {{- if .Values.web.enabled }} - - name: FRONTEND_URL - value: "http://{{ include "textbee.fullname" .}}-web:{{ .Values.web.service.port }}" - {{- end}} + - name: MONGO_URI + valueFrom: + secretKeyRef: + name: {{ .Values.globals.mongo_uri.secretName }} + key: {{ .Values.globals.mongo_uri.secretKey }} envFrom: - secretRef: - name: {{ include "textbee.fullname" .}}-api-secrets + name: {{ .Values.api.envSecretName | default (include "textbee.fullname" .) }}-api-secrets {{- with .Values.api.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} @@ -94,38 +79,4 @@ spec: {{- with .Values.api.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end }} - ---- -{{- if .Values.web.enabled -}} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "textbee.fullname" .}}-web - labels: - {{- include "textbee.labels" . | nindent 4 }} -spec: - replicas: 1 - selector: - matchLabels: - app: {{ include "textbee.fullname" .}}-web - template: - metadata: - labels: - app: {{ include "textbee.fullname" .}}-web - spec: - containers: - - name: {{ include "textbee.fullname" .}}-web - image: "{{ .Values.web.image.repository }}:{{ .Values.web.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.api.image.pullPolicy }} - ports: - - containerPort: {{ .Values.web.service.port }} - env: - - name: PORT - value: "{{ .Values.web.service.port }}" - - name: NEXT_PUBLIC_API_BASE_URL - value: "http://{{ include "textbee.fullname" .}}-api:{{ .Values.web.service.port }}/api/v1" - envFrom: - - secretRef: - name: {{ include "textbee.fullname" .}}-web-secrets -{{- end }} \ No newline at end of file + {{- end }} \ No newline at end of file diff --git a/charts/textbee/templates/api-hpa.yaml b/charts/textbee/templates/api-hpa.yaml new file mode 100644 index 0000000..389e242 --- /dev/null +++ b/charts/textbee/templates/api-hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.api.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "textbee.fullname" . }}-api-hpa + labels: + {{- include "textbee.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "textbee.fullname" . }}-api + minReplicas: {{ .Values.api.autoscaling.minReplicas }} + maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} + metrics: + {{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/textbee/templates/api-ingress.yaml b/charts/textbee/templates/api-ingress.yaml new file mode 100644 index 0000000..5aeec6e --- /dev/null +++ b/charts/textbee/templates/api-ingress.yaml @@ -0,0 +1,43 @@ +{{- if .Values.api.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-{{ include "textbee.fullname" . }}-api + labels: + {{- include "textbee.labels" . | nindent 4 }} + {{- with .Values.api.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.api.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.api.ingress.tls }} + tls: + {{- range .Values.api.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.api.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: svc-{{ include "textbee.fullname" $ }}-api + port: + number: {{ $.Values.api.service.port }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/textbee/templates/api-service.yaml b/charts/textbee/templates/api-service.yaml new file mode 100644 index 0000000..e345d03 --- /dev/null +++ b/charts/textbee/templates/api-service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: svc-{{ include "textbee.fullname" .}}-api + labels: + app: textbee-api + {{- include "textbee.labels" . | nindent 4 }} + {{- if .Values.api.service.labels }} + {{- toYaml .Values.api.service.labels | nindent 4 }} + {{- end }} + {{- if .Values.api.service.annotations }} + annotations: + {{- toYaml .Values.api.service.annotations | nindent 4 }} + {{- end }} +spec: + selector: + app: {{ include "textbee.fullname" .}}-api + ports: + - port: {{ .Values.api.service.port }} + targetPort: {{ .Values.api.service.port }} + type: {{ .Values.api.service.type }} diff --git a/charts/textbee/templates/hpa.yaml b/charts/textbee/templates/hpa.yaml index 671f337..389e242 100644 --- a/charts/textbee/templates/hpa.yaml +++ b/charts/textbee/templates/hpa.yaml @@ -2,14 +2,14 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: - name: {{ include "textbee.fullname" . }} + name: {{ include "textbee.fullname" . }}-api-hpa labels: {{- include "textbee.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: {{ include "textbee.fullname" . }} + name: {{ include "textbee.fullname" . }}-api minReplicas: {{ .Values.api.autoscaling.minReplicas }} maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} metrics: diff --git a/charts/textbee/templates/ingress.yaml b/charts/textbee/templates/ingress.yaml deleted file mode 100644 index 97b1339..0000000 --- a/charts/textbee/templates/ingress.yaml +++ /dev/null @@ -1,88 +0,0 @@ -{{- if .Values.api.ingress.enabled -}} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ include "textbee.fullname" . }} - labels: - {{- include "textbee.labels" . | nindent 4 }} - {{- with .Values.api.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- with .Values.api.ingress.className }} - ingressClassName: {{ . }} - {{- end }} - {{- if .Values.api.ingress.tls }} - tls: - {{- range .Values.api.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.api.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- with .pathType }} - pathType: {{ . }} - {{- end }} - backend: - service: - name: {{ include "textbee.fullname" $ }} - port: - number: {{ $.Values.api.service.port }} - {{- end }} - {{- end }} -{{- end }} ---- - -{{- if .Values.web.ingress.enabled -}} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ include "textbee.fullname" . }} - labels: - {{- include "textbee.labels" . | nindent 4 }} - {{- with .Values.web.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- with .Values.api.ingress.className }} - ingressClassName: {{ . }} - {{- end }} - {{- if .Values.web.ingress.tls }} - tls: - {{- range .Values.web.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.web.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- with .pathType }} - pathType: {{ . }} - {{- end }} - backend: - service: - name: {{ include "textbee.fullname" $ }} - port: - number: {{ $.Values.web.service.port }} - {{- end }} - {{- end }} -{{- end }} diff --git a/charts/textbee/templates/service.yaml b/charts/textbee/templates/service.yaml deleted file mode 100644 index d95dbe6..0000000 --- a/charts/textbee/templates/service.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -{{- if .Values.web.service.enabled -}} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "textbee.fullname" . }}-web - labels: - {{- include "textbee.labels" . | nindent 4 }} -spec: - selector: - app: {{ include "textbee.fullname" . }}-web - {{- if .Values.web.service.annotations }} - annotations: - {{- toYaml .Values.web.service.annotations | nindent 4 }} - {{- end }} - ports: - - port: {{ .Values.web.service.port | default 80 }} - targetPort: {{ .Values.web.service.targetPort | default 80 }} - type: {{ .Values.web.service.type | default "ClusterIP" }} - -{{- end }} ---- -{{- if .Values.api.service.enabled -}} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "textbee.fullname" . }}-api - labels: - {{- include "textbee.labels" . | nindent 4 }} -spec: - selector: - app: {{ include "textbee.fullname" . }}-web - {{- if .Values.api.service.annotations }} - annotations: - {{- toYaml .Values.api.service.annotations | nindent 4 }} - {{- end }} - ports: - - port: {{ .Values.api.service.port | default 80 }} - targetPort: {{ .Values.api.service.targetPort | default 80 }} - type: {{ .Values.api.service.type | default "ClusterIP" }} -{{- end }} \ No newline at end of file diff --git a/charts/textbee/templates/web-deployment.yaml b/charts/textbee/templates/web-deployment.yaml new file mode 100644 index 0000000..cc531f7 --- /dev/null +++ b/charts/textbee/templates/web-deployment.yaml @@ -0,0 +1,74 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "textbee.fullname" .}}-web + labels: + app: {{ include "textbee.fullname" .}}-web + {{- include "textbee.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "textbee.fullname" .}}-web + template: + metadata: + labels: + app: {{ include "textbee.fullname" .}}-web + spec: + containers: + - name: {{ include "textbee.fullname" .}}-web + image: "{{ .Values.web.image.repository }}:{{ .Values.web.image.tag | default .Chart.AppVersion }}" + ports: + - name: http + containerPort: {{ .Values.web.service.port }} + env: + - name: HOSTNAME + value: 0.0.0.0 + {{- if .Values.web.ingress.enabled }} + - name: NEXT_PUBLIC_SITE_URL + value: "https://{{ .Values.web.ingress.url }}" + {{- end }} + - name: PORT + value: "{{ .Values.web.service.port }}" + - name: NEXT_PUBLIC_API_BASE_URL + value: "http://{{ include "textbee.fullname" .}}-api:{{ .Values.web.service.port }}/api/v1" + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: {{ .Values.globals.mongo_uri.secretName | default (include "textbee.fullname" .) }}-mongo-uri + key: {{ .Values.globals.mongo_uri.secretKey }} + envFrom: + - secretRef: + name: {{ .Values.web.envSecretName | default (include "textbee.fullname" .) }}-web-secrets + {{- with .Values.web.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.web.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.web.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.web.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.web.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.web.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.web.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.web.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/textbee/templates/web-ingress.yaml b/charts/textbee/templates/web-ingress.yaml new file mode 100644 index 0000000..3a54914 --- /dev/null +++ b/charts/textbee/templates/web-ingress.yaml @@ -0,0 +1,43 @@ +{{- if .Values.web.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-{{ include "textbee.fullname" . }}-web + labels: + {{- include "textbee.labels" . | nindent 4 }} + {{- with .Values.web.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.web.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.web.ingress.tls }} + tls: + {{- range .Values.web.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.web.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: svc-{{ include "textbee.fullname" $ }}-web + port: + number: {{ $.Values.web.service.port }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/textbee/templates/web-service.yaml b/charts/textbee/templates/web-service.yaml new file mode 100644 index 0000000..7733e62 --- /dev/null +++ b/charts/textbee/templates/web-service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: svc-{{ include "textbee.fullname" .}}-web + labels: + app: {{ include "textbee.fullname" .}}-web + {{- include "textbee.labels" . | nindent 4 }} + {{- if .Values.web.service.labels }} + {{- toYaml .Values.web.service.labels | nindent 4 }} + {{- end }} + {{- if .Values.web.service.annotations }} + annotations: + {{- toYaml .Values.web.service.annotations | nindent 4 }} + {{- end }} +spec: + selector: + app: {{ include "textbee.fullname" .}}-web + ports: + - port: {{ .Values.web.service.port }} + targetPort: {{ .Values.web.service.port }} + type: {{ .Values.web.service.type }} diff --git a/charts/textbee/values.yaml b/charts/textbee/values.yaml index 5ce48ea..1143edc 100644 --- a/charts/textbee/values.yaml +++ b/charts/textbee/values.yaml @@ -1,6 +1,12 @@ - -api: +globals: + mongo_uri: + secretName: "textbee-mongo-uri-secret" + secretKey: "uri" +api: + # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ replicaCount: 1 + + # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: repository: ghcr.io/vernu/textbee/api # This sets the pull policy for images. @@ -8,23 +14,18 @@ api: # Overrides the image tag whose default is the chart appVersion. tag: "" + + # enable SMS queueing + redis: + enabled: false + dsn: "redis://localhost:6379" + # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: [] # This is to override the chart name. nameOverride: "" fullnameOverride: "" - # Redis enabled means API SMS QUEUE is enabled. - redis: - enabled: true - dsn: "" - - # This is the name of the secret that contains the environment variables for the API. - # If not set, it will default to the chart name with '-env' suffix. - envSecretName: "" - - - # This is for setting Kubernetes Annotations to a Pod. # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ podAnnotations: {} @@ -50,7 +51,9 @@ api: # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports port: 80 annotations: {} - labels: {} + # service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp" + # service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012" + # service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443" # This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ ingress: @@ -95,7 +98,7 @@ api: autoscaling: enabled: false minReplicas: 1 - maxReplicas: 10 + maxReplicas: 100 targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 @@ -119,24 +122,108 @@ api: affinity: {} web: - enabled: false + # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: - repository: ghcr.io/vernu/textbee/web + repository: ghcr.io/vernu/textbee/api + # This sets the pull policy for images. pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. tag: "" + # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + imagePullSecrets: [] + + # This is for setting Kubernetes Annotations to a Pod. + # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ + podAnnotations: {} + # This is for setting Kubernetes Labels to a Pod. + # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ + podLabels: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + # This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports port: 80 - labels: {} annotations: {} + # service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp" + # service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012" + # service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443" + # This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ ingress: enabled: false className: "" annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local paths: - path: / pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + + # This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + # Additional volumes on the output Deployment definition. + volumes: [] + # - name: foo + # secret: + # secretName: mysecret + # optional: false + + # Additional volumeMounts on the output Deployment definition. + volumeMounts: [] + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true + + nodeSelector: {} + + tolerations: [] + + affinity: {} From c89d4050066d6ba057a4125086b8d2069e8aa8cb Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 20:38:21 +0400 Subject: [PATCH 06/16] fix: fix mongo uri --- charts/textbee/Chart.yaml | 2 +- charts/textbee/templates/web-deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index ac76555..ad57cac 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.3 +version: 0.1.4 appVersion: "v2.6.2" diff --git a/charts/textbee/templates/web-deployment.yaml b/charts/textbee/templates/web-deployment.yaml index cc531f7..a834ad9 100644 --- a/charts/textbee/templates/web-deployment.yaml +++ b/charts/textbee/templates/web-deployment.yaml @@ -35,7 +35,7 @@ spec: - name: DATABASE_URL valueFrom: secretKeyRef: - name: {{ .Values.globals.mongo_uri.secretName | default (include "textbee.fullname" .) }}-mongo-uri + name: {{ .Values.globals.mongo_uri.secretName }} key: {{ .Values.globals.mongo_uri.secretKey }} envFrom: - secretRef: From b848e6a89aab16ab2c6a75e2dc20f08893aad253 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 20:41:34 +0400 Subject: [PATCH 07/16] fix: add global domain --- charts/textbee/templates/web-deployment.yaml | 2 +- charts/textbee/values.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/charts/textbee/templates/web-deployment.yaml b/charts/textbee/templates/web-deployment.yaml index a834ad9..01278d9 100644 --- a/charts/textbee/templates/web-deployment.yaml +++ b/charts/textbee/templates/web-deployment.yaml @@ -26,7 +26,7 @@ spec: value: 0.0.0.0 {{- if .Values.web.ingress.enabled }} - name: NEXT_PUBLIC_SITE_URL - value: "https://{{ .Values.web.ingress.url }}" + value: "https://{{ .Values.globals.domain }}" {{- end }} - name: PORT value: "{{ .Values.web.service.port }}" diff --git a/charts/textbee/values.yaml b/charts/textbee/values.yaml index 1143edc..e6ce1cc 100644 --- a/charts/textbee/values.yaml +++ b/charts/textbee/values.yaml @@ -2,6 +2,8 @@ globals: mongo_uri: secretName: "textbee-mongo-uri-secret" secretKey: "uri" + domain: "https://chart-example.local" + api: # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ replicaCount: 1 From 424909dd29bf8137371280242c67193af1ec73c0 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 20:42:25 +0400 Subject: [PATCH 08/16] chore: bump version --- charts/textbee/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index ad57cac..15768f8 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.4 +version: 0.1.5 appVersion: "v2.6.2" From a3373c28e9f2b0ee3deaa7717458859aaf71c88b Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 20:53:11 +0400 Subject: [PATCH 09/16] fix: fix typo --- charts/textbee/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/textbee/values.yaml b/charts/textbee/values.yaml index e6ce1cc..cd5e63e 100644 --- a/charts/textbee/values.yaml +++ b/charts/textbee/values.yaml @@ -126,7 +126,7 @@ api: web: # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: - repository: ghcr.io/vernu/textbee/api + repository: ghcr.io/vernu/textbee/web # This sets the pull policy for images. pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. From 56613c735de6500a10a642c1989e733851e859ae Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 20:53:27 +0400 Subject: [PATCH 10/16] fix: fix typo --- charts/textbee/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index 15768f8..0e3b79b 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.5 +version: 0.1.6 appVersion: "v2.6.2" From 5398dd9608897b6488f4aba71d5976b75ce4e05c Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 20:57:57 +0400 Subject: [PATCH 11/16] fix: remove redundant file --- charts/textbee/Chart.yaml | 2 +- charts/textbee/templates/hpa.yaml | 32 ------------------------------- 2 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 charts/textbee/templates/hpa.yaml diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index 0e3b79b..89e92a7 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.6 +version: 0.1.7 appVersion: "v2.6.2" diff --git a/charts/textbee/templates/hpa.yaml b/charts/textbee/templates/hpa.yaml deleted file mode 100644 index 389e242..0000000 --- a/charts/textbee/templates/hpa.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.api.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "textbee.fullname" . }}-api-hpa - labels: - {{- include "textbee.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "textbee.fullname" . }}-api - minReplicas: {{ .Values.api.autoscaling.minReplicas }} - maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} - metrics: - {{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} From 0183f1f71ee9473f82042c385d7a57ee4b9e23d2 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 21:01:14 +0400 Subject: [PATCH 12/16] docs: add missing docs --- charts/textbee/templates/NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/textbee/templates/NOTES.txt b/charts/textbee/templates/NOTES.txt index 09e9693..ef855bd 100644 --- a/charts/textbee/templates/NOTES.txt +++ b/charts/textbee/templates/NOTES.txt @@ -64,6 +64,7 @@ stringData: MAIL_PASS: "" MAIL_FROM: "" ADMIN_EMAIL: "" + AUTH_SECRET: "" https://generate-secret.vercel.app/32 --- apiVersion: v1 From ecfa2f7f63d59a1a5a60f4232cfc7807d4531aa1 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 21:01:31 +0400 Subject: [PATCH 13/16] feat: bump version --- charts/textbee/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index 89e92a7..3642d9f 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.7 +version: 0.1.8 appVersion: "v2.6.2" From f43983d86f2927c521188c2a1c318ae787d785ea Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 21:14:59 +0400 Subject: [PATCH 14/16] fix: add correct service name --- charts/textbee/Chart.yaml | 2 +- charts/textbee/templates/api-deployment.yaml | 2 +- charts/textbee/templates/web-deployment.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/textbee/Chart.yaml b/charts/textbee/Chart.yaml index 3642d9f..428a09a 100644 --- a/charts/textbee/Chart.yaml +++ b/charts/textbee/Chart.yaml @@ -3,6 +3,6 @@ name: textbee description: A Helm chart to deploy TextBee. type: application -version: 0.1.8 +version: 0.1.9 appVersion: "v2.6.2" diff --git a/charts/textbee/templates/api-deployment.yaml b/charts/textbee/templates/api-deployment.yaml index 003123d..8d3a67f 100644 --- a/charts/textbee/templates/api-deployment.yaml +++ b/charts/textbee/templates/api-deployment.yaml @@ -29,7 +29,7 @@ spec: value: "{{ .Values.api.service.port }}" {{- if .Values.web.enabled }} - name: FRONTEND_URL - value: "http://{{ include "textbee.fullname" .}}-web:{{ .Values.web.service.port }}" + value: "http://svc-{{ include "textbee.fullname" .}}-web:{{ .Values.web.service.port }}" {{- end}} {{- if .Values.api.redis.enabled }} - name: REDIS_URL diff --git a/charts/textbee/templates/web-deployment.yaml b/charts/textbee/templates/web-deployment.yaml index 01278d9..1aa8618 100644 --- a/charts/textbee/templates/web-deployment.yaml +++ b/charts/textbee/templates/web-deployment.yaml @@ -31,7 +31,7 @@ spec: - name: PORT value: "{{ .Values.web.service.port }}" - name: NEXT_PUBLIC_API_BASE_URL - value: "http://{{ include "textbee.fullname" .}}-api:{{ .Values.web.service.port }}/api/v1" + value: "http://svc-{{ include "textbee.fullname" .}}-api:{{ .Values.api.service.port }}/api/v1" - name: DATABASE_URL valueFrom: secretKeyRef: From dda917e737d1dea8afe8f73fca7804f02c090282 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 22 Aug 2025 21:50:35 +0400 Subject: [PATCH 15/16] fix: allow registration outside vercel or NEXTAUTH_URL --- web/lib/auth.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/lib/auth.ts b/web/lib/auth.ts index b534a52..1af6eb5 100644 --- a/web/lib/auth.ts +++ b/web/lib/auth.ts @@ -125,6 +125,13 @@ export const authOptions = { strategy: 'jwt', }, callbacks: { + async redirect({ url, baseUrl }) { + // Always return relative redirects (avoids needing NEXTAUTH_URL) + if (url.startsWith("/")) return `${baseUrl}${url}`; + // Ensure only safe redirects + if (new URL(url).origin === baseUrl) return url; + return baseUrl; + }, async jwt({ token, user, trigger, session }) { if (trigger === 'update') { if (session.name !== token.name) { From 321c4606f5bdf9b63384cc99096d188c6ed60bb6 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Tue, 26 Aug 2025 17:50:52 +0400 Subject: [PATCH 16/16] fix: allow kubernetes --- web/lib/auth.ts | 7 ------- web/lib/httpServerClient.ts | 23 ++++++++++++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/web/lib/auth.ts b/web/lib/auth.ts index 1af6eb5..b534a52 100644 --- a/web/lib/auth.ts +++ b/web/lib/auth.ts @@ -125,13 +125,6 @@ export const authOptions = { strategy: 'jwt', }, callbacks: { - async redirect({ url, baseUrl }) { - // Always return relative redirects (avoids needing NEXTAUTH_URL) - if (url.startsWith("/")) return `${baseUrl}${url}`; - // Ensure only safe redirects - if (new URL(url).origin === baseUrl) return url; - return baseUrl; - }, async jwt({ token, user, trigger, session }) { if (trigger === 'update') { if (session.name !== token.name) { diff --git a/web/lib/httpServerClient.ts b/web/lib/httpServerClient.ts index d4c6177..7b26771 100644 --- a/web/lib/httpServerClient.ts +++ b/web/lib/httpServerClient.ts @@ -5,14 +5,27 @@ import { Session } from 'next-auth' // Create a base URL that works in Docker container network if running in a container // or falls back to the public URL if not in a container -const getServerSideBaseUrl = () => { - // When running server-side in Docker, use the service name from docker-compose +const getServerSideBaseUrl = (): string => { + + // Prefer explicit public API base URL if set + if (process.env.NEXT_PUBLIC_API_BASE_URL) { + return process.env.NEXT_PUBLIC_API_BASE_URL + } + + // Detect Kubernetes environment + if (process.env.KUBERNETES_SERVICE_HOST) { + console.log("Detected Kubernetes environment") + return process.env.NEXT_PUBLIC_API_BASE_URL || '' + } + + // Detect Docker container runtime if (process.env.CONTAINER_RUNTIME === 'docker') { - console.log('Running in Docker container') + console.log("Detected Docker container environment") return 'http://textbee-api:3001/api/v1' } - // Otherwise use the public URL - return process.env.NEXT_PUBLIC_API_BASE_URL || '' + + // Fallback to empty string if nothing else matches + return '' } export const httpServerClient = axios.create({